[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: #(define (bookGenerator please))
From: |
Pierre-Luc Gauthier |
Subject: |
Re: #(define (bookGenerator please)) |
Date: |
Mon, 16 Nov 2015 21:12:53 -0500 |
So, after reading the "Automated processing of multiple books" thread
and few hours trying to figure this out, I am still not able to make
it work.
The higher order function "for-each" somehow cannot call the
"compilePart" function and Lilyponds GUILE interpreter returns "Wrong
type to apply".
Why?
Simple tests allowed me to prove that "for-each" *can* call functions
like "display" but not my "compilePart".
I am very very new to scheme and let alone scheme inside the pond and
I really got a kick out of this journey finally understanding why
those #, #', #{, #}, $, parser, location, etc were there in the first
place.
It's really satisfying.
Here is the code for my MWE.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\version "2.18.2"
\language "english"
piccoloPart = \new Staff {
\new Voice {
\relative c' {
d4 e fs g |
a1\fermata |
}
}
}
bassPart = \new Staff {
\new Voice {
\relative c {
\clef bass
c4 d e f |
g1\fermata |
}
}
}
compilePart = #(define-void-function ( parser location music name)
;; This function is used to do and engrave a book
;; $music should be a musical expression
;; $name should be a string for the book output suffix
(ly:music? string?)
(let ((paper #{ \paper {} #})
(layout #{ \layout {} #})
(book #{ \book { \score { $music } } #}))
(ly:book-process book paper layout name)))
% _This_ is to test the compilePart function
%\compilePart \piccoloPart #"piccolo"
% \compilePart \bassPart #"bass"
parts = #(list
;; This is a list of pairs containing parts informations
'("piccolo" . piccoloPart)
'("bass" . bassPart))
% _This_ is to test that the data can be extracted succesfully from the list
%\compilePart #(cdr (car parts)) #(car (car parts)) % First entry
%\compilePart #(cdr (car (cdr parts))) #(car (car (cdr parts))) % Second entry
% Somehow _this_ does not work.
%{#(for-each
(lambda (p)
(let ((name (car p))
(music (cdr p)))
(compilePart music name )
))
parts)%}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2015-11-16 14:55 GMT-05:00 Pierre-Luc Gauthier <address@hidden>:
> Possible duplicate!
>
> It appears I have missed the very similar thread "Automated processing
> of multiple books"
>
> I'll digest that first ;-)
>
> --
> Pierre-Luc Gauthier
--
Pierre-Luc Gauthier
BookFunction.ly
Description: Text Data