Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Ok, so here is a function I created for you, which will allow you to repeat single pitches. The only catch is that it won't use the <code>\relative</code> notation. This is because, in relative notation, the following sequence of notes <code>c' c' c'</code> will obviously be one octave higher than the preceding one. Unfortunately I still could not find a way to have a function such as <code>\function #3 c'</code> that would output <code>c' c c</code>. That said, here is my function and some examples:</p> <pre><code>\version "2.17.28" times = #(define-music-function (parser location N note) (integer? ly:music?) (cond ((&gt;= N 2) #{ \repeat unfold $N { \absolute $note } #} ) ((= N 1) #{ \absolute $note #} ) ) ) { a4 \times #3 b4 R1 \times #4 { c'8 d' } R1 \times #1 { c''1 } } </code></pre> <p>So the syntax is simply <code>\times #"number of repetition" { ...music... }</code>. If only one note is to be repeated, you can omit both <code>{</code> and <code>}</code>: <code>\times #"number of repetition" "single note"</code>. </p> <p>You can use this function in the middle of a <code>\relative</code> passage, but then you should enter the pitches for the function as absolute pitches. Have a look:</p> <pre><code>\version "2.17.28" times = #(define-music-function (parser location N note) (integer? ly:music?) (cond ((&gt;= N 2) #{ \repeat unfold $N { \absolute $note } #} ) ((= N 1) #{ \absolute $note #} ) ) ) \relative c'' { c4 d \times #4 e'' f g } </code></pre> <p>Note that all notes above are in the same octave. The octave position the note <code>f</code> is also NOT influenced by this function, it is influenced by the note preceding the function, i.e., the <code>d</code>.</p> <p>For sure there is a way to write a better code for this, but I wasn't able to do the trick with neither any <code>\relative</code> nor <code>\transpose</code> commands.</p> <hr> <p>And here is some attempt to help you with your parenthesized octave (same function above but with some small alterations):</p> <pre><code>\version "2.17.28" timesP = #(define-music-function (parser location N note) (integer? ly:music?) (cond ((&gt;= N 2) #{ &lt;&lt; \repeat unfold $N { \absolute $note } \transpose c c' \repeat unfold $N { \absolute \parenthesize $note } &gt;&gt; #} ) ((= N 1) #{ &lt;&lt; \absolute $note { \transpose c c' \parenthesize $note } &gt;&gt; #} ) ) ) { a4 \timesP #3 b4 \timesP #8 c'16 \timesP #2 g4 \timesP #4 { c'8 d' } % no parenthesis here because there are two notes as arguments... \timesP #1 { c''1 } % no parenthesis here because of the { } } \relative c'' { c4 d \timesP #4 e'' f g } </code></pre> <p>There are still some catches here: this function will only parenthesize when the argument is a single note written without <code>{ }</code>. This is well commented on the code above.</p> <hr> <p>I hope this will help you somehow. If I come across the solution for the octave transposition problem here, I will update this answer.</p>
 

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