Re: Markup and Score from scheme function
Am So., 14. Okt. 2018 um 12:57 Uhr schrieb Sebastian Käppler : > > Finally, I found that the given answers satisfy all my needs as of now. Thank > you very much! Glad you like it. > > Sebastian Käppler schrieb am Sa., 13. Okt. > 2018, 09:26: >> >> Add-text is even better. Well, 'add-text' is shorter. It's defined as (add-score (list text)), though. >> Still curious if it's possible to get the "context" inside the function. No. Furthermore, my function is void-function, i.e. it _returns_ nothing! Ofcourse it _does_ something. In this case text and score are added to the current bookpart, book or toplevel >> Isn't that what the location parameter is for? Nope, it makes point-and-click work. it's meant to point to a location in your input file. But you can watch what it does. See: \version "2.19.82" foo = #(define-void-function ()() (write (*location*))) { R1 \foo R1 } In my case it display in terminal: # i.e. a certain line and column Cheers, Harm >> Thomas Morley schrieb am Fr., 12. Okt. 2018, >> 10:29: >>> >>> Am Fr., 12. Okt. 2018 um 08:10 Uhr schrieb Jan-Peter Voigt >>> : >>> > >>> > Hello Sebastian, >>> > >>> > what do you mean with "return"? Do want to add the score immediatly or >>> > do you want to return an object containing both? >>> > You used the parser-location arguments in your scheme-function, so I >>> > guess you are using stable (2.18). I created an example for 2.18 >>> > (incomplete) and one for 2.19.82. For three possible functions. >>> > >>> > HTH >>> > Jan-Peter >>> >>> Hi, >>> >>> for immediate addings, why not the simpler: >>> >>> example = >>> #(define-void-function (mrkp scr) (markup? ly:score?) >>> (add-text mrkp) >>> (add-score scr)) >>> >>> \example >>> \markup \bold "Test" >>> \score { c'4 } >>> >>> \example >>> \markup \italic "Test" >>> \score { cis'4 } >>> >>> Cheers, >>> Harm >>> >>> ___ >>> lilypond-user mailing list >>> lilypond-user@gnu.org >>> https://lists.gnu.org/mailman/listinfo/lilypond-user > > ___ > lilypond-user mailing list > lilypond-user@gnu.org > https://lists.gnu.org/mailman/listinfo/lilypond-user ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Markup and Score from scheme function
Finally, I found that the given answers satisfy all my needs as of now. Thank you very much! Sebastian Käppler schrieb am Sa., 13. Okt. 2018, 09:26: > Add-text is even better. Still curious if it's possible to get the > "context" inside the function. Isn't that what the location parameter is > for? > > Thomas Morley schrieb am Fr., 12. Okt. 2018, > 10:29: > >> Am Fr., 12. Okt. 2018 um 08:10 Uhr schrieb Jan-Peter Voigt < >> jp.vo...@gmx.de>: >> > >> > Hello Sebastian, >> > >> > what do you mean with "return"? Do want to add the score immediatly or >> > do you want to return an object containing both? >> > You used the parser-location arguments in your scheme-function, so I >> > guess you are using stable (2.18). I created an example for 2.18 >> > (incomplete) and one for 2.19.82. For three possible functions. >> > >> > HTH >> > Jan-Peter >> >> Hi, >> >> for immediate addings, why not the simpler: >> >> example = >> #(define-void-function (mrkp scr) (markup? ly:score?) >> (add-text mrkp) >> (add-score scr)) >> >> \example >> \markup \bold "Test" >> \score { c'4 } >> >> \example >> \markup \italic "Test" >> \score { cis'4 } >> >> Cheers, >> Harm >> >> ___ >> lilypond-user mailing list >> lilypond-user@gnu.org >> https://lists.gnu.org/mailman/listinfo/lilypond-user >> > ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Markup and Score from scheme function
Add-text is even better. Still curious if it's possible to get the "context" inside the function. Isn't that what the location parameter is for? Thomas Morley schrieb am Fr., 12. Okt. 2018, 10:29: > Am Fr., 12. Okt. 2018 um 08:10 Uhr schrieb Jan-Peter Voigt < > jp.vo...@gmx.de>: > > > > Hello Sebastian, > > > > what do you mean with "return"? Do want to add the score immediatly or > > do you want to return an object containing both? > > You used the parser-location arguments in your scheme-function, so I > > guess you are using stable (2.18). I created an example for 2.18 > > (incomplete) and one for 2.19.82. For three possible functions. > > > > HTH > > Jan-Peter > > Hi, > > for immediate addings, why not the simpler: > > example = > #(define-void-function (mrkp scr) (markup? ly:score?) > (add-text mrkp) > (add-score scr)) > > \example > \markup \bold "Test" > \score { c'4 } > > \example > \markup \italic "Test" > \score { cis'4 } > > Cheers, > Harm > > ___ > lilypond-user mailing list > lilypond-user@gnu.org > https://lists.gnu.org/mailman/listinfo/lilypond-user > ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Markup and Score from scheme function
Am Fr., 12. Okt. 2018 um 08:10 Uhr schrieb Jan-Peter Voigt : > > Hello Sebastian, > > what do you mean with "return"? Do want to add the score immediatly or > do you want to return an object containing both? > You used the parser-location arguments in your scheme-function, so I > guess you are using stable (2.18). I created an example for 2.18 > (incomplete) and one for 2.19.82. For three possible functions. > > HTH > Jan-Peter Hi, for immediate addings, why not the simpler: example = #(define-void-function (mrkp scr) (markup? ly:score?) (add-text mrkp) (add-score scr)) \example \markup \bold "Test" \score { c'4 } \example \markup \italic "Test" \score { cis'4 } Cheers, Harm ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Markup and Score from scheme function
Thanks for your help, I found the add-score function to work in the way I want it to. Never stumbled across it in the documentation, though... Jan-Peter, I want to add both the markup and the score immediately. Another question, is it possible to determine inside the function if it is called from a score context, that means to distinguish these two cases: A: \score { \myfunction } B: \myfunction ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Markup and Score from scheme function
Hello Sebastian, what do you mean with "return"? Do want to add the score immediatly or do you want to return an object containing both? You used the parser-location arguments in your scheme-function, so I guess you are using stable (2.18). I created an example for 2.18 (incomplete) and one for 2.19.82. For three possible functions. HTH Jan-Peter Am 11.10.2018 um 10:22 schrieb Sebastian Käppler: > Hello, > > I wonder if it is possible to return markup AND score from a single > scheme function, something like this: > > example = #(define-scheme-function (parser location) () > #{ > \markup "Test" > \score { > c'4 > } > #} > ) > > I created some scripts for teaching and want to include task-markup > before each score. Using markup and my functions outside of scheme > works, but I couldn't get it to work from a single function. > > Kind regards > > > > ___ > lilypond-user mailing list > lilypond-user@gnu.org > https://lists.gnu.org/mailman/listinfo/lilypond-user > \version "2.19.82" % What do you want to achieve with this function? % return an object containing markup and score exampleA = #(define-scheme-function ()() ; create a (list (cons 'mup #{ \markup "Test" #}) (cons 'mus #{ \score { c'4 } #}) )) exA = \exampleA \exA.mup \exA.mus % add the markup and the score immediatly exampleB = #(define-scheme-function () () (add-score (list #{ \markup "Test" #})) (add-score #{ \score { c'4 } #} )) \exampleB % return a function that adds markup and score exampleC = #(define-scheme-function (mup mus) (markup? ly:score?) (define-void-function ()() (add-score (list mup)) (add-score mus) )) exC = \exampleC Test \score { c'4 } \exC \version "2.18.2" % What do you want to achieve with this function? % return an object containing markup and score exampleA = #(define-scheme-function (parser location) () ; create a (list (cons 'mup #{ \markup "Test" #}) (cons 'mus #{ \score { c'4 } #}) )) exA = \exampleA % this is much nicer in 2.19.82 ... $(ly:assoc-get 'mup exA) $(ly:assoc-get 'mus exA) % add the markup and the score immediatly exampleB = #(define-scheme-function (parser location) () (add-score (ly:parser-clone parser) (list #{ \markup "Test" #})) (add-score (ly:parser-clone parser) #{ \score { c'4 } #} )) \exampleB % return a function that adds markup and score exampleC = #(define-scheme-function (parser location) () (define-void-function (parser location)() (add-score (ly:parser-clone parser) (list #{ \markup "Test" #})) (add-score (ly:parser-clone parser) #{ \score { c'4 } #} ))) exC = \exampleC \exC ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Markup and Score from scheme function
On 2018-10-11 1:22 am, Sebastian Käppler wrote: Hello, I wonder if it is possible to return markup AND score from a single scheme function, something like this: example = #(define-scheme-function (parser location) () #{ \markup "Test" \score { c'4 } #} ) I created some scripts for teaching and want to include task-markup before each score. Using markup and my functions outside of scheme works, but I couldn't get it to work from a single function. Seems to be that the parser cannot figure out what is meant by #{ \markup ... \score ... #} even though both of those items are permitted to appear at the top-level. With #{ \markup ... #} or #{ \score ... #}, the parser appears to do the right thing. While there is probably some clever trick that permits #{ \markup ... \score ... #} to parse correctly, I am not seeing it. So, here are two potential options: either nest the score within the markup or vice versa: \version "2.19.82" \markup "Hello, World!" \score { { a'4 b' g'2 } } scoreInsideMarkup = #(define-scheme-function (label notes) (string? ly:music?) #{ \markup { \column { $label \score { $notes } } } #}) markupInsideScore = #(define-scheme-function (label notes) (string? ly:music?) #{ \score { { \tweak X-offset #(/ -15 1.7573) \mark \markup \fontsize #-2 $label $notes } } #}) \scoreInsideMarkup "Hello, World!" { a'4 b' g'2 } \markupInsideScore "Hello, World!" { a'4 b' g'2 } Note that when using a RehearsalMark, a suitable adjustment to the alignment and font size is needed to match the appearance of the other two. -- Aaron Hill ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Markup and Score from scheme function
Hello, I wonder if it is possible to return markup AND score from a single scheme function, something like this: example = #(define-scheme-function (parser location) () #{ \markup "Test" \score { c'4 } #} ) I created some scripts for teaching and want to include task-markup before each score. Using markup and my functions outside of scheme works, but I couldn't get it to work from a single function. Kind regards ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user