lilypond-user
[Top][All Lists]
Advanced

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

Extracting pitch names from music


From: Michael Ellis
Subject: Extracting pitch names from music
Date: Tue, 7 Dec 2010 10:35:47 -0500

I use LilyPond to create practice scores and etudes. I've figured out how to allow note entry in Moveable Do solfege notation and have a template (see below) that supports displaying the solfege symbols as lyrics beneath the notes. 

At present, I have to manually extract the lyrics from the notation plus markup that generates the music. I've been able to partially automate this with some python and vim code (not shown here), but it is still somewhat unsatisfactory.

It seems to me that the best solution would be to use LilyPond's built-in Scheme interpreter to extract the pitch names while the file is being processed. I've made some attempts to use map with ly:note-pitchname, but so far no success. This is probably because I know squat about Scheme, especially as used in LilyPond scripts.

% Moveable Do as lyrics template

% define some solfege pitchnames
% (in practice, the full set goes into "english.ly")
pitchnames = #`(
    (do . ,(ly:make-pitch -1 0 NATURAL))
    (re . ,(ly:make-pitch -1 1 NATURAL))
    (mi . ,(ly:make-pitch -1 2 NATURAL))
    )
#(ly:parser-set-note-names parser pitchnames)

% compose as though in C major
mynotes =  \relative do' {\key do \major do2 re4( mi4) }

% transpose to desired key
melody = \transpose do mi  { \mynotes }

% I WANT TO AUTOMATICALLY CREATE THE
% THE PITCHNAMES IN THIS BLOCK
% FROM THE CONTENTS OF \mynotes
solfa = \lyricmode {
    \set ignoreMelismata = ##t  % one syllable per note
    do re mi
    \unset ignoreMelismata  % allow normal placement of other lyrics
    }

% Produce score with solfege names as lyrics
\score {
    <<
    \new Voice = "myVoice" {
        \melody
    }
    \new Lyrics \lyricsto "myVoice" \solfa
    >>
    }
\version "2.12.3"          



Note: I've also posted this question at StackOverflow but I'm not sure how many LilyPond gurus are active there, so it seems worthwhile to ask the same question here.

Thanks,
Mike

reply via email to

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