lilypond-user
[Top][All Lists]
Advanced

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

[Scheme coding] how to turn pitches into music


From: Kieren MacMillan
Subject: [Scheme coding] how to turn pitches into music
Date: Sat, 25 Jan 2020 09:42:08 -0500

Hi all,

I’m continuing my Scheme learning journey. I can already feel the momentum 
building, so that’s a good thing!

Despite it perhaps not being the optimal thing to build while learning Scheme, 
I’m continuing to work with this dodecaphonic manipulation work from my 
Salzburg presentation. Right now, I’m trying to figure out a way to take some 
music, compare it to a reference row, and output the music in a transformed 
condition (the exact transformation being irrelevant to solving my current 
issue).

So far, I have this, which compiles without error:

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

rowrefs = #'(6 8 7 2 3 12 5 4 11 1 10 9)

test = { ef, fs' g d'' cs' }

row-staff-notes =
#(define-music-function (mus) (ly:music?)
   (ly:make-music
    (map (lambda (n) (ly:make-pitch 0 n 0))
      (map (lambda (l) (list-ref rowrefs l))
        (map (lambda (m) (modulo m 12))
          (map ly:pitch-semitones (music-pitches mus)))))))

\score {
  \row-staff-notes #test
}
%%%  SNIPPET ENDS

Having previously used

#(display
  (map (lambda (n) (ly:make-pitch 0 n 0))
    (map (lambda (l) (list-ref rowrefs l))
      (map (lambda (m) (modulo m 12))
        (map ly:pitch-semitones (music-pitches test))))))

I know that the scheme function is returning a set of pitches, and they are the 
correct ones [based on how I want to manipulate the "test" music]. The errors I 
got when I tried to create a music function led me to find ly:make-music, which 
eliminated the errors. But now I can’t display the pitches. How do I fix the 
row-staff-notes function so that it displays pitches on a staff?

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]