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 12:38:27 -0500

Hi Aaron,

> I must confess I have no idea what row-reduction means in a musical context.

In this case, I’m trying to take all the pitch events (i.e., a note played at a 
given moment) and represent them [without octave information] on a 6-line staff 
where the bottom line is the 0th element of the tone row and the space on top 
of the top line is the 11th element.

> Regardless, it sounds like I missed a fun presentation.  (:

Well, *I* had fun anyway… you’ll have to ask others whether *they* found it any 
fun.  ;)

> Here's a "spicier" take on your code that uses an engraver:

Nice! This seems so much more to my purpose(s). See the example with slightly 
richer data:

%%%
\version "2.19.83"
\language "english"

\paper {
  line-width = 4\in
  ragged-right = ##f
}

rowrefs = #'(6 8 7 2 3 12 5 4 11 1 10 9)
test = { ef4. <fs' a'>8 g2 r4 <b d''>8 cs' }
testier = { bf4 a4 ~ 8 cs''8 4 d'1 }

RowReduce_engraver = #(lambda (...)
 `((listeners
     (note-event .
       ,(lambda (engraver event)
         (let* ((elem (ly:event-property event 'music-cause))
                (pitch (ly:music-property elem 'pitch))
                (semitone (ly:pitch-semitones pitch))
                (index (modulo semitone (length rowrefs))))
           (ly:music-set-property! elem 'pitch
             (ly:make-pitch 0 (list-ref rowrefs index) 0))))))))

\layout {
  \context {
    \Staff
    \name RowReductionStaff
    \alias Staff
    \inherit-acceptability RowReductionStaff Staff
    \override StaffSymbol.line-count = #6
    \consists \RowReduce_engraver
    \omit Clef
    \omit TimeSignature
    \omit Stem
    \omit Flag
    \omit Beam
    \omit Dots
    \omit Rest
    \omit Tie
    \omit BarLine
    \override NoteHead.duration-log = #4
  }
}

\score {
  <<
    \new Staff { \test }
    \new Staff { \testier }
    \new RowReductionStaff { \new Voice << \test \testier >> }
  >>
}
%%%

I’m hoping eventually to understand how to manipulate each element well enough 
to (e.g.) eliminate tied notes, have it "duration independent" (in the sense of 
not throwing "incompatible stem" errors), etc.

> Note that one aspect of this that needs refactoring is the rowrefs array 
> itself.  This probably should be a context property rather than a global.  
> That way you could say:
> %%%%
>  \new RowReductionStaff
>    \with { rowrefs = #'(8 6 7 5 3 0 9) }
>    { \test }
> %%%%

Yes! Nice.

> I have posted about custom context properties before, but let me know if you 
> need pointers.

Well… I’ll try my hand at "fishing" first, and get back to you if I find myself 
too hungry.  :)

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]