Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to abbreviate 'note with the same note an octave higher, parenthesized' in Lilypond?

Currently I write lilypond code that looks like this:

\version "2.14.2"

P = #parenthesize

\relative c, {
  \clef bass 
    <c \P c'> <e \P e'> <g \P g'>2 <c, \P c'>4 <d \P d'> <e \P e'>2
}

where I repeatedly mean 'this note, together with the same note one octave higher, parenthesized'.

I'd like a way to abbreviate this, so that I can write something like this:

\version "2.14.2"

poct = ...

\relative c, {
  \clef bass 
  \poct c \poct e \poct g2 \poct c,4 \poct d \poct e2
}

As suggested in a helpful answer to an earlier question of mine, I have tried to use a music function, but there is no way I can get this to work. The closest I can get is

poct = #(define-music-function
     (parser location note)
     (ly:music?)
   #{
     << $note \transpose c c \parenthesize $note >>
   #})

but this uses << .. >> instead of < .. >, which does not render the way I want (and with warnings), and I have no idea why the \transpose c c actually transposes anything.

Finally, tangentially related, when experimenting with music functions I found it even impossible just to create a music function that mimicks \repeat unfold 2; the following jumps down an octave between the third and fourth c:

\version "2.14.2"

double = #(define-music-function
     (parser location note)
     (ly:music?)
   #{
     $note $note
   #})

\relative c, {
  \clef bass 
  \double c \double e \double g2 \double c,4 \double d \double e2
}
like image 608
MarnixKlooster ReinstateMonica Avatar asked Oct 19 '13 08:10

MarnixKlooster ReinstateMonica


People also ask

How do you notate an octave?

In scientific pitch notation, a specific octave is indicated by a numerical subscript number after note name. In this notation, middle C is C4, because of the note's position as the fourth C key on a standard 88-key piano keyboard, while the C an octave higher is C5.

Why are two notes an octave apart called the same notes?

When two musical notes are an octave apart, one has double the frequency of the other yet we hear them as the “same” note – a “C” for example. Why is this? This question has a false premise. I hear two notes an octave apart as different notes.

What is the strongest note in music?

We hear this low C note as the strongest note, but it has a series of harmonic overtones. The sound also contains a C one octave higher, a G a fifth higher than that, a C two octaves higher and many more overtones and dissonances reaching eventually beyond the range of the human ear. These overtones become progressively weaker as they go higher.

Why do different notes perceive each other differently?

As such, these notes share a unique mathematical relationship with each other that they don’t share with other notes. Since the brain creates pitch perception based on grouping harmonically related sounds, it isn’t surprising that we perceive related notes similarly. There are some exceptions to this.


1 Answers

I just got this answer from David Kastrup, one of the developers of LilyPond:


The "octave transposition" happens because basically \transpose c c is the same as \absolute (as LilyPond does not apply \relative to transposed music).

\absolute is not necessary in connection with \repeat unfold: \repeat unfold knows how to deal with relative music.

Version 2.14.2 is awfully old. At any rate, there is currently issue http://code.google.com/p/lilypond/issues/detail?id=3673 in the LilyPond tracker, and the respective code can be found at https://codereview.appspot.com/30890043/diff/40001/scm/music-functions.scm

And there we get indeed into Scheme programming. The respective defmacro-public would likely work even in 2.14 though #{ #} might not work properly.

With that definition, your double definition would become:

double = #(define-music-function (parser location note) (ly:music?) (make-relative (note) note #{ $note $note #}))

and would then work in both absolute and relative mode. If the 2.14 #{ #} does not jibe with make-relative, writing (make-sequential-music (list (ly:music-deep-copy note) (ly:music-deep-copy note))) should serve as a Scheme replacement.

The original problem becomes easier to understand once you realize that it's just a simple code replacement, so \relative { \double c' } becomes \relative { c' c' } using different octaves. The make-relative macro will to the \relative operation only on a single note, and then paste the results into the music expression.

like image 64
gilbertohasnofb Avatar answered Oct 16 '22 23:10

gilbertohasnofb