[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: New hosting for Urs Liska's Scheme WIP book
From: |
Jean Abou Samra |
Subject: |
Re: New hosting for Urs Liska's Scheme WIP book |
Date: |
Fri, 4 Nov 2022 12:09:42 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 |
Le 04/11/2022 à 00:13, Karlin High a écrit :
Could a music function or something be shorthand for that? Let's see...
<https://lilypond.org/doc/v2.23/Documentation/notation/substitution-function-syntax>
That page is pretty ideal. Here's the general form, what it contains,
and how it can be used.
Well yes; however, the Scheme tutorials at hand are mostly about
the Scheme language itself, not so much about its integration with
LilyPond. In other words, they're kind of a substitute for this part
of the official documentation:
https://lilypond.org/doc/v2.23/Documentation/extending/introduction-to-scheme
That part is (from experience) mostly useless as a beginner. It
does not even mention let* !
I ended up with this:
%
\version "2.23.80"
uniTwo = #(define-music-function
(uniNote)
(ly:music?)
#{
<< { \voiceOne #uniNote }
\new Voice { \voiceTwo #uniNote }
>> \oneVoice
#})
{ c'4 \uniTwo e' g' }
%
I may end up replacing all the chords with the temporary-polyphony
construct. And I may get told my \uniTwo function is very far from
best practice.
Better use $uniNote for at least one of the two occurrences,
so as to make a copy of the note. Otherwise, you might
have surprises when applying music functions to the result,
because the note is shared. For example:
\version "2.23.80"
uniTwo = #(define-music-function
(uniNote)
(ly:music?)
#{
% Using $uniNote instead of #uniNote would fix the problem.
<< { \voiceOne #uniNote }
\new Voice { \voiceTwo #uniNote }
>> \oneVoice
#})
% Transposition should yield G notes, but yields B flat notes
% as it is done twice, due to sharing.
\new Staff \transpose e' g' { \uniTwo e' \uniTwo e' }
Also, you will have surprises with \relative because
the note appears twice, with its octave marks. You
can use make-relative to fix that.
So, overall, better do:
\version "2.23.80"
uniTwo =
#(define-music-function (uniNote) (ly:music?)
(make-relative
(uniNote)
uniNote
#{
<< { \voiceOne $uniNote }
\new Voice { \voiceTwo $uniNote }
>> \oneVoice
#}))
\new Staff \transpose e' g' \relative { \uniTwo e' \uniTwo e' }
Best,
Jean
OpenPGP_signature
Description: OpenPGP digital signature