lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Scheme coding] how to turn pitches into music


From: Kieren MacMillan
Subject: Re: [Scheme coding] how to turn pitches into music
Date: Sat, 25 Jan 2020 10:48:22 -0500

Hi Aaron,

> Perhaps the simplest option is to avoid ly:music and instead use splicing to 
> let the parser do the heavy lifting:

I assume you mean the "$@", which is the only thing in this code I don’t 
understand?

> Note that I refactored your nested maps into a single one.

Will the performance be improved, or only the compactness of the code?

Also: I notice that rests and skips are ignored:

%%%  SNIPPET BEGINS
\version "2.19.83"
\language "english"

rowrefs = #'(6 8 7 2 3 12 5 4 11 1 10 9)
test = { ef, fs' s g r d'' cs' }

row-staff-notes =
#(define-music-function (mus) (ly:music?)
 #{ $@(map (lambda (pitch)
             (let* ((semitone (ly:pitch-semitones pitch))
                    (index (modulo semitone (length rowrefs))))
               (ly:make-pitch 0 (list-ref rowrefs index) 0)))
           (music-pitches mus)) #})

\layout {
  \context {
    \Score
    \omit Stem
    \omit TimeSignature
  }
}

{ \cadenzaOn \row-staff-notes \test }
%%%  SNIPPET ENDS

This is intuitive/understandable to me (given the functions we’re using); and 
I’m glad they’re just ignored [rather than causing errors]. But how can I turn 
every rest or skip into a skip [of equivalent duration] in the output? My 
intuition tells me I should use an if statement… but I’m betting there’s a more 
automagic way.  =)

Thanks,
Kieren.
________________________________

Kieren MacMillan, composer (he/him/his)
‣ website: www.kierenmacmillan.info
‣ email: address@hidden




reply via email to

[Prev in Thread] Current Thread [Next in Thread]