[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lilypond-user
Subject:    Re: duration using variable
From:       Gianmaria Lari <gianmarialari () gmail ! com>
Date:       2016-04-27 20:02:07
Message-ID: CAKhGe3wMT9N-Qg4-Y4vqCC1m-t=uYhhpHX0NECjBzbL0rwAfsw () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Dear Harm,

I made many test, and... it works really well! Thanks a lot for your kind
help!

g.

On Wed, Apr 27, 2016 at 1:12 PM, Thomas Morley <thomasmorley65@gmail.com>
wrote:

> 2016-04-27 10:56 GMT+02:00 Gianmaria Lari <gianmarialari@gmail.com>:
> > I don't know if the following code is well written (suggestions are
> pretty
> > welcome!!) but it works as I like (:)) and let me generate two different
> > output according the tag midiOut or screenOut.
> >
> > \version "2.19.40"
> >
> > mynote = c
> >
> > mynoteExp = {\mynote}
> > mynoteDouble = {<\mynote' \mynote>}
> >
> > cC = {\tag #'midiOut \mynoteDouble
> >       \tag #'screenOut \mynoteExp }
> >
> > music =
> > {
> >   \time 3/4 \clef bass
> >   \cC
> > }
> >
> > \score
> > {
> >   \keepWithTag #'screenOut \music
> >   \layout {}
> > }
> >
> > \score
> > {
> >   \keepWithTag #'midiOut \music
> >   \layout {}
> >   \midi {}
> > }
> >
> >
> > In the attached capture.png you can see the two different output, the
> first
> > when using screenOut and the second using midiOut.
> >
> > * * *
> >
> > Now I would like to be able to increase the lenght of the musical
> expression
> > contained in the cC variable.
> >
> > In the previous example the cC variable contains a quarter note (and a
> > quarter bichord) and I would like to change it to an half note. I tried
> with
> > the "changePitch.ly" snippet
> > (
> http://gillesth.free.fr/Lilypond/changePitch/changePitchDoc-sources/changePitch-doc.pdf
> )
> > writing
> >
> > \changePitch {a2} \cC
> >
> > but this does not work.
> >
> > Here it is the whole code (I highlighted the differences compared to the
> > previous example)
> >
> > \version "2.19.40"
> > \include "changePitch.ly"
> >
> > mynote = c
> >
> > mynoteExp = {\mynote}
> > mynoteDouble = {<\mynote' \mynote>}
> >
> > cC = {\tag #'midiOut \mynoteDouble
> >       \tag #'screenOut \mynoteExp }
> >
> > music =
> > {
> >   \time 3/4 \clef bass
> >   \changePitch {a2} \cC
> > }
> >
> > \score
> > {
> >   \keepWithTag #'screenOut \music
> >   \layout {}
> > }
> >
> > \score
> > {
> >   \keepWithTag #'midiOut \music
> >   \layout {}
> >   \midi {}
> > }
> >
> >
> > and in the attached file capture2 you can find the output for this second
> > scenario.
> >
> > Consider that:
> > - the variable cC will always contain a single note or a single chord
> > - I tried using changepitch but any other (possibly simpler) way is
> welcome
> >
> > Any suggestion?
> > Thank you, g.
>
>
>
> Probably:
>
> \version "2.19.40"
>
> %% nb: this is a pitch:
> mynote = c
>
> %% this is sequential music, with a NoteEvent in 'elements:
> mynoteExp = { \mynote }
>
> %% this is sequential music, with an EventChord in 'elements:
> mynoteDouble = { <\mynote' \mynote> }
>
> setNotesDur =
> #(define-music-function (mus dur)(ly:music? ly:duration?)
> "Set the duration of all 'NoteEvents in `mus' to `dur'"
>   (for-each
>     (lambda (m)
>       (ly:music-set-property! m 'duration dur))
>     (extract-named-music mus 'NoteEvent))
>   mus)
>
> cC = {\tag #'midiOut { \setNotesDur \mynoteDouble 32 }
>       \tag #'screenOut \mynoteExp }
>
> music =
> {
>   \time 3/4 \clef bass
>   \cC
> }
>
> \score
> {
>   \keepWithTag #'screenOut \music
>   \layout {}
> }
>
> \score
> {
>   \keepWithTag #'midiOut \music
>   \layout {}
>   \midi {}
> }
>
> Cheers,
>   Harm
>

[Attachment #5 (text/html)]

<div dir="ltr">Dear Harm,<div><br></div><div>I made many test, and... it works really \
well! Thanks a lot for your kind help!</div><div><br></div><div>g.</div></div><div \
class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 27, 2016 at 1:12 PM, \
Thomas Morley <span dir="ltr">&lt;<a href="mailto:thomasmorley65@gmail.com" \
target="_blank">thomasmorley65@gmail.com</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">2016-04-27 10:56 \
GMT+02:00 Gianmaria Lari &lt;<a \
href="mailto:gianmarialari@gmail.com">gianmarialari@gmail.com</a>&gt;:<br> &gt; I \
don&#39;t know if the following code is well written (suggestions are pretty<br> &gt; \
welcome!!) but it works as I like (:)) and let me generate two different<br> &gt; \
output according the tag midiOut or screenOut.<br> &gt;<br>
&gt; \version &quot;2.19.40&quot;<br>
&gt;<br>
&gt; mynote = c<br>
&gt;<br>
&gt; mynoteExp = {\mynote}<br>
&gt; mynoteDouble = {&lt;\mynote&#39; \mynote&gt;}<br>
&gt;<br>
&gt; cC = {\tag #&#39;midiOut \mynoteDouble<br>
&gt;           \tag #&#39;screenOut \mynoteExp }<br>
&gt;<br>
&gt; music =<br>
&gt; {<br>
&gt;     \time 3/4 \clef bass<br>
&gt;     \cC<br>
&gt; }<br>
&gt;<br>
&gt; \score<br>
&gt; {<br>
&gt;     \keepWithTag #&#39;screenOut \music<br>
&gt;     \layout {}<br>
&gt; }<br>
&gt;<br>
&gt; \score<br>
&gt; {<br>
&gt;     \keepWithTag #&#39;midiOut \music<br>
&gt;     \layout {}<br>
&gt;     \midi {}<br>
&gt; }<br>
&gt;<br>
&gt;<br>
&gt; In the attached capture.png you can see the two different output, the first<br>
&gt; when using screenOut and the second using midiOut.<br>
&gt;<br>
&gt; * * *<br>
&gt;<br>
&gt; Now I would like to be able to increase the lenght of the musical expression<br>
&gt; contained in the cC variable.<br>
&gt;<br>
&gt; In the previous example the cC variable contains a quarter note (and a<br>
&gt; quarter bichord) and I would like to change it to an half note. I tried with<br>
&gt; the &quot;changePitch.ly&quot; snippet<br>
&gt; (<a href="http://gillesth.free.fr/Lilypond/changePitch/changePitchDoc-sources/changePitch-doc.pdf" \
rel="noreferrer" target="_blank">http://gillesth.free.fr/Lilypond/changePitch/changePitchDoc-sources/changePitch-doc.pdf</a>)<br>
 &gt; writing<br>
&gt;<br>
&gt; \changePitch {a2} \cC<br>
&gt;<br>
&gt; but this does not work.<br>
&gt;<br>
&gt; Here it is the whole code (I highlighted the differences compared to the<br>
&gt; previous example)<br>
&gt;<br>
&gt; \version &quot;2.19.40&quot;<br>
&gt; \include &quot;changePitch.ly&quot;<br>
&gt;<br>
&gt; mynote = c<br>
&gt;<br>
&gt; mynoteExp = {\mynote}<br>
&gt; mynoteDouble = {&lt;\mynote&#39; \mynote&gt;}<br>
&gt;<br>
&gt; cC = {\tag #&#39;midiOut \mynoteDouble<br>
&gt;           \tag #&#39;screenOut \mynoteExp }<br>
&gt;<br>
&gt; music =<br>
&gt; {<br>
&gt;     \time 3/4 \clef bass<br>
&gt;     \changePitch {a2} \cC<br>
&gt; }<br>
&gt;<br>
&gt; \score<br>
&gt; {<br>
&gt;     \keepWithTag #&#39;screenOut \music<br>
&gt;     \layout {}<br>
&gt; }<br>
&gt;<br>
&gt; \score<br>
&gt; {<br>
&gt;     \keepWithTag #&#39;midiOut \music<br>
&gt;     \layout {}<br>
&gt;     \midi {}<br>
&gt; }<br>
&gt;<br>
&gt;<br>
&gt; and in the attached file capture2 you can find the output for this second<br>
&gt; scenario.<br>
&gt;<br>
&gt; Consider that:<br>
&gt; - the variable cC will always contain a single note or a single chord<br>
&gt; - I tried using changepitch but any other (possibly simpler) way is welcome<br>
&gt;<br>
&gt; Any suggestion?<br>
&gt; Thank you, g.<br>
<br>
<br>
<br>
</div></div>Probably:<br>
<br>
\version &quot;2.19.40&quot;<br>
<br>
%% nb: this is a pitch:<br>
mynote = c<br>
<br>
%% this is sequential music, with a NoteEvent in &#39;elements:<br>
mynoteExp = { \mynote }<br>
<br>
%% this is sequential music, with an EventChord in &#39;elements:<br>
mynoteDouble = { &lt;\mynote&#39; \mynote&gt; }<br>
<br>
setNotesDur =<br>
#(define-music-function (mus dur)(ly:music? ly:duration?)<br>
&quot;Set the duration of all &#39;NoteEvents in `mus&#39; to `dur&#39;&quot;<br>
   (for-each<br>
      (lambda (m)<br>
         (ly:music-set-property! m &#39;duration dur))<br>
      (extract-named-music mus &#39;NoteEvent))<br>
   mus)<br>
<br>
cC = {\tag #&#39;midiOut { \setNotesDur \mynoteDouble 32 }<br>
<span class="">         \tag #&#39;screenOut \mynoteExp }<br>
<br>
music =<br>
{<br>
   \time 3/4 \clef bass<br>
   \cC<br>
}<br>
<br>
\score<br>
{<br>
   \keepWithTag #&#39;screenOut \music<br>
   \layout {}<br>
}<br>
<br>
\score<br>
{<br>
   \keepWithTag #&#39;midiOut \music<br>
   \layout {}<br>
   \midi {}<br>
}<br>
<br>
</span>Cheers,<br>
   Harm<br>
</blockquote></div><br></div>



_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic