Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to abbreviate 'note with the same note an octave higher, parenthesized' in Lilypond?
    primarykey
    data
    text
    <p>Currently I write <a href="/questions/tagged/lilypond" class="post-tag" title="show questions tagged &#39;lilypond&#39;" rel="tag">lilypond</a> code that looks like this:</p> <pre><code>\version "2.14.2" P = #parenthesize \relative c, { \clef bass &lt;c \P c'&gt; &lt;e \P e'&gt; &lt;g \P g'&gt;2 &lt;c, \P c'&gt;4 &lt;d \P d'&gt; &lt;e \P e'&gt;2 } </code></pre> <p>where I repeatedly mean '<em>this</em> note, together with the same note one octave higher, parenthesized'.</p> <p>I'd like a way to abbreviate this, so that I can write something like this:</p> <pre><code>\version "2.14.2" poct = ... \relative c, { \clef bass \poct c \poct e \poct g2 \poct c,4 \poct d \poct e2 } </code></pre> <p>As suggested in <a href="https://stackoverflow.com/a/19412939/223837">a helpful answer to an earlier question of mine</a>, I have tried to use <a href="http://lilypond.org/doc/stable/Documentation/notation/using-music-functions" rel="nofollow noreferrer">a music function</a>, but there is no way I can get this to work. The closest I can get is</p> <pre><code>poct = #(define-music-function (parser location note) (ly:music?) #{ &lt;&lt; $note \transpose c c \parenthesize $note &gt;&gt; #}) </code></pre> <p>but this uses <code>&lt;&lt;</code> .. <code>&gt;&gt;</code> instead of <code>&lt;</code> .. <code>&gt;</code>, which does not render the way I want (and with warnings), and I have no idea why the <code>\transpose c c</code> actually transposes anything. </p> <p>Finally, tangentially related, when experimenting with music functions I found it even impossible just to create a music function that mimicks <code>\repeat unfold 2</code>; the following jumps down an octave between the third and fourth <code>c</code>:</p> <pre><code>\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 } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload