Re: need help building a Scheme function

2024-06-25 Thread Lukas-Fabian Moser
[Sorry! I wrote this two days ago on a train in one of the famous German cell connection dead zones - and then forgot to actually send it later.] Hi Kieren, The last "m" in your innermost (if ...) is unnecessary: As with the difference between "for" and "map" in plain Scheme, the return value

Re: need help building a Scheme function

2024-06-23 Thread Kieren MacMillan
Hi Lukas! Thanks for the patient and helpful tutorial(s). :) > The last "m" in your innermost (if ...) is unnecessary: As with the > difference between "for" and "map" in plain Scheme, the return value of the > lambda function in for-some-music gets discarded ("for" functions are > supposed

Re: need help building a Scheme function

2024-06-23 Thread Lukas-Fabian Moser
The last "m" in your innermost (if ...) is unnecessary: As with the difference between "for" and "map" in plain Scheme, the return value of the lambda function in for-some-music gets discarded ("for" functions are supposed to _do_ something, not _return_ something). No, it doesn't. It is a

Re: need help building a Scheme function

2024-06-23 Thread Lukas-Fabian Moser
Hi David, If you don't want to call upon undocumented internals of LilyPond (the (@@ (lily) ...) bit), you can just use [with-output-to-string] Wow, thanks! I hadn't encountered this possibility yet. Also thanks for pointing out the possibility of in-place modification. Lukas

Re: need help building a Scheme function

2024-06-23 Thread Lukas-Fabian Moser
Hi Kieren, for-some-music does not return music. It works on music in-place. So the last thing in your music function must not be for-some-music but rather the music that you have been working on. So… %%% SNIPPET BEGINS adjustPitch = #(define-music-function (pitchIn pitchOut music)

Re: need help building a Scheme function

2024-06-22 Thread Kieren MacMillan
Hi David, > for-some-music does not return music. It works on music in-place. So > the last thing in your music function must not be for-some-music but > rather the music that you have been working on. So… %%% SNIPPET BEGINS adjustPitch = #(define-music-function (pitchIn pitchOut music)

Re: need help building a Scheme function

2024-06-22 Thread David Kastrup
Kieren MacMillan writes: > I tried a few times, but got errors (about returning > unspecified). Hints appreciated. for-some-music does not return music. It works on music in-place. So the last thing in your music function must not be for-some-music but rather the music that you have been

Re: need help building a Scheme function

2024-06-22 Thread Kieren MacMillan
Hi David, > This will also adjust eis and eses to e. Note names are numbers and can > be compared with = . (make-music 'NoteEvent m) is silly and creates an > unnecessary copy. You can just use m instead. Thanks — current version: %%% SNIPPET BEGINS \version "2.25.11" adjustPitch =

Re: need help building a Scheme function

2024-06-22 Thread David Kastrup
Kieren MacMillan writes: > Hi again, > >> There is no necessity to return a new NoteEvent; you can just change >> pitch on the existing one. >> >> Music functions are allowed to modify their music arguments in place. > > This is what I have so far, which appears to do what I want: > > %%%

Re: need help building a Scheme function

2024-06-22 Thread Kieren MacMillan
Hi again, > There is no necessity to return a new NoteEvent; you can just change > pitch on the existing one. > > Music functions are allowed to modify their music arguments in place. This is what I have so far, which appears to do what I want: %%% SNIPPET BEGINS \version "2.25.11"

Re: need help building a Scheme function

2024-06-22 Thread David Kastrup
Lukas-Fabian Moser writes: > Elaborating on David's explanation, it might be instructive to study the > output of: > > \version "2.25.9" > > mappingFunction = > #(define-music-function (music) (ly:music?) >(music-map > (lambda (m) > (ly:message "Considering music:\n~a\n-\n"

Re: need help building a Scheme function

2024-06-22 Thread David Kastrup
Lukas-Fabian Moser writes: > But: Whether you use music-map or map-some-music, your helper function > (your lambda) is expected to return the new music into which the given > argument m should be transformed. So in any case, your lambda function > should return music - in the trivial case, it

Re: need help building a Scheme function

2024-06-21 Thread Lukas-Fabian Moser
Hi Kieren, Am 21.06.24 um 20:25 schrieb Kieren MacMillan: Hi all, Thank you for the rapid-iteration non-isochronous Scheme class! :) Before I do the next step, is this optimal at this point? %%% SNIPPET BEGINS \version "2.25.11" adjustPitch = #(define-music-function (pitchIn pitchOut

Re: need help building a Scheme function

2024-06-21 Thread Kieren MacMillan
Hi Lukas, > Elaborating on David's explanation, it might be instructive to study the > output of: > [snip] > In short: music-map really considers every music object in a music tree. That was instructive — thanks! Kieren. __ My work day may look

Re: need help building a Scheme function

2024-06-21 Thread Lukas-Fabian Moser
Hi Kieren, I’m a little confused that the output of %%% SNIPPET BEGINS \version "2.25.11" adjustPitch = #(define-music-function (pitchIn pitchOut music) (ly:pitch? ly:pitch? ly:music?) (music-map (lambda (m) (ly:message "Pitch is: ~a" (ly:music-property m 'pitch)) m)

Re: need help building a Scheme function

2024-06-21 Thread Kieren MacMillan
Hi David, > To say something is "optimal", you have to state your objective. I guess the immediate objective was to output [in the log] a list of pitches given the 'music' input. > music-map is used for changing music, and you don't appear to do any > useful changes to the music. In fact, you

Re: need help building a Scheme function

2024-06-21 Thread David Kastrup
Kieren MacMillan writes: > Hi all, > > Thank you for the rapid-iteration non-isochronous Scheme class! :) > > Before I do the next step, is this optimal at this point? > > %%% SNIPPET BEGINS > \version "2.25.11" > > adjustPitch = > #(define-music-function (pitchIn pitchOut music) (ly:pitch?

Re: need help building a Scheme function

2024-06-21 Thread Kieren MacMillan
Hi all, Thank you for the rapid-iteration non-isochronous Scheme class! :) Before I do the next step, is this optimal at this point? %%% SNIPPET BEGINS \version "2.25.11" adjustPitch = #(define-music-function (pitchIn pitchOut music) (ly:pitch? ly:pitch? ly:music?) (music-map (lambda

Re: need help building a Scheme function

2024-06-21 Thread Kieren MacMillan
Hi David, > If you want to only look at note events, you need to check for them > yourself. music-map is not discriminating. Ah! Lovely Socratic lesson. :) Thanks, Kieren. __ My work day may look different than your work day. Please do not feel

Re: need help building a Scheme function

2024-06-21 Thread David Kastrup
Kieren MacMillan writes: > Hi again, > > I’m a little confused that the output of > > %%% SNIPPET BEGINS > \version "2.25.11" > > adjustPitch = > #(define-music-function (pitchIn pitchOut music) (ly:pitch? ly:pitch? > ly:music?) >(music-map > (lambda (m) > (ly:message "Pitch is:

Re: need help building a Scheme function

2024-06-21 Thread Kieren MacMillan
Hi Timothy, > Your lambda function for the mapping returns the value of ly:message, which > is #. You need to return some music. Changing the lambda > function to > (lambda (m) > (ly:message "Pitch is: ~a" (ly:music-property m 'pitch)) m) > maps the music to itself without any changes.

Re: need help building a Scheme function

2024-06-21 Thread Kieren MacMillan
Hi again, I’m a little confused that the output of %%% SNIPPET BEGINS \version "2.25.11" adjustPitch = #(define-music-function (pitchIn pitchOut music) (ly:pitch? ly:pitch? ly:music?) (music-map (lambda (m) (ly:message "Pitch is: ~a" (ly:music-property m 'pitch)) m) music))

Re: need help building a Scheme function

2024-06-21 Thread Timothy Lanfear
On 21/06/2024 17:36, Kieren MacMillan wrote: Hi Lukas! All right… already back for more specific help. I struggled with map-some-music, and failed. Scanned through Jean’s [amazing] “Extending” docs — yes, yes, I need to RTM on that one, page-by-page! — and found an example with music-map, so

Re: need help building a Scheme function

2024-06-21 Thread Kieren MacMillan
Hi Lukas! All right… already back for more specific help. I struggled with map-some-music, and failed. Scanned through Jean’s [amazing] “Extending” docs — yes, yes, I need to RTM on that one, page-by-page! — and found an example with music-map, so tried that instead. Also failed. %%% SNIPPET

Re: need help building a Scheme function

2024-06-21 Thread Kieren MacMillan
Hi L-F! >> Is map-some-music the correct next move? > Yes. Thanks! > I take it you're only asking for confirmation you're on the right track? :-) Correct. I’ll try to ask more specific questions when I need more than confirmation. > So I only suggest use the ly:pitch? predicate for

Re: need help building a Scheme function

2024-06-21 Thread Lukas-Fabian Moser
Hi Kieren, Am 21.06.24 um 16:39 schrieb Kieren MacMillan: %%% SNIPPET BEGINS \version "2.25.11" adjustPitch = #(define-music-function (pitchIn pitchOut music) (ly:music? ly:music? ly:music?) (ly:message "Pitch is: ~a" (ly:pitch-notename (ly:music-property pitchIn 'pitch))) music)

need help building a Scheme function

2024-06-21 Thread Kieren MacMillan
Hey list! Trying to work up to being a bigger and better contributor to The ’Pond. Found and copied that “transpose major to minor” scale function in the previous thread I contributed to, but (a) don’t really know if it’s the best way to do what the OP wanted, (b) thought it might be overkill