[Top][All Lists]

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

Re: Custom note names, or meta-score?

From: Jean Abou Samra
Subject: Re: Custom note names, or meta-score?
Date: Sat, 31 Jul 2021 22:32:41 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0

Le 31/07/2021 à 19:43, Craig Comstock a écrit :

I am writing a piece for a 9 piece ensemble in which I want the players to choose 9 different pitches along with articulations and/or other additional symbols to indicate extended techniques and such. I want to take those 81 different “glyphs” if you will and generate a score and parts. The part I specify as the composer is only rhythm and which glyph to use.

I would like to bring along the pitch level and say stocatto, accent, things like that but keep them separated from rhythm.

So say ‘aa’ is middle C stocatto I could write { aa4 aa2 aa aa } which would be the same as { c’4-. c2-. c-. c-. }

At first I thought I might just use variables like

aa = { ‘c }
{ \aa4 \aa2 \aa \aa }

But that didn’t parse and is also an extra backslash and such I’d rather not have in there if possible.

So said another way, I’d like to write a meta-score like { aa4 aa2 aa aa ab ab ab ac ac ca ca } and those note names relate to a set of pitches determined maybe in another file (not code hopefully) so that as the pitches are chosen/changed it is easy to regenerate the score/parts.

So maybe something near <> I could add in a list of pitch names from another file included in the score somehow?



This is perfectly doable, but not as simple as defining a
custom language for pitches, because the languages map note
names to mere pitches, and not full-fledged notes that can
contain articulations. Therefore, the code below arrives at
the end result via two steps, first mapping the note names
to dummy pitches chosen to be unique, then replacing those
with the real pitches, adding the articulations at the
same time.

\version "2.22.1"

%% Code

#(define note-name-to-dummy-pitch-alist '())
#(define dummy-pitch-to-note-table (make-hash-table))
#(define dummy-pitch-counter 0)

defineName =
#(define-void-function (name note) (symbol? ly:music?)
   (set! note-name-to-dummy-pitch-alist
         (acons name
                (ly:make-pitch dummy-pitch-counter 0 0)
   (hashv-set! dummy-pitch-to-note-table dummy-pitch-counter note)
   (set! dummy-pitch-counter (1+ dummy-pitch-counter)))

endDefinitions =
#(define-void-function () ()
   (ly:parser-set-note-names note-name-to-dummy-pitch-alist))

replaceDummyPitches =
#(define-music-function (music) (ly:music?)
     (lambda (m)
       (if (music-is-of-type? m 'note-event)
           (let* ((pitch (ly:music-property m 'pitch))
                  (octave (ly:pitch-octave pitch)))
             (hashv-ref dummy-pitch-to-note-table octave))

% Not pretty, but effective
#(set! toplevel-music-functions
       (cons replaceDummyPitches toplevel-music-functions))

%% Note definitions

\defineName astaccato a-.
\defineName aaccent a->
\defineName bstaccato b-.
% etc.


%% Usage

{ astaccato aaccent bstaccato }

Best regards,

reply via email to

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