Re: Problems with chord glissandos with articulations and tablature

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Problems with chord glissandos with articulations and tablature

Carl Sorensen



On 4/15/10 9:09 PM, "Bernardo Barros" <[hidden email]> wrote:

> Thanks a lot, Carl.
>
> Let me know if you make this work with any number of notes.
>
> I'm sure that would be a great feature to add to the next version of
> Lilypond. 
>
> I'm new to Lilypond, but I'm finding a pretty good programme. 
> I'm a composer and I'm checking this kind of thing to be sure I can work also
> with big projects.
> This was one of the things that made me scared, but not anymore with this
> solution.
>
>

Well, I thought I could put it away, but I couldn't....

Here's a copy of chordGlissando that automatically detects chord lengths and
creates glissandos for chords of up to 8 notes.  And if one wanted to add to
that limit, it would be trivial to do so.

HTH,

Carl

%%%%% Start cut and paste

\version "2.13.3"

chordGlissando =
#(define-music-function (parser location mus1 mus2) (ly:music? ly:music?)
  "Make a glissando between the notes of triads @code{mus1} and
@code{mus2}."

  (define (add-glissando musChord)
     (let ((els (ly:music-property musChord 'elements)))
      (ly:music-set-property! musChord 'elements (append els (list
(make-music 'GlissandoEvent))))
      musChord))

  (define (get-notes musicChord)
   (filter (lambda(x) (eq? (ly:music-property x 'name) 'NoteEvent))
           (ly:music-property musicChord 'elements)))

  (define (select-note musChord index)
    (let* ((notes (get-notes musChord))
           (non-notes (filter (lambda (x)
                               (not (eq? (ly:music-property x 'name)
                                         'NoteEvent)))
                              (ly:music-property musChord 'elements)))
           (selected-note (list-ref notes index))
           (new-els (cons selected-note non-notes))
           (new-mus (ly:music-deep-copy musChord)))
     (ly:music-set-property! new-mus 'elements new-els)
     new-mus))

  (define (add-glissando-line mus1 mus2 index)
    #{
       \new Voice {
         \hideNotes
         \once \override Glissando #'thickness = #2
         $(add-glissando (select-note mus1 (1- index)))
         $(select-note mus2 (1- index))
       }
    #})

  (let* ((notes1 (get-notes mus1))
         (notes2 (get-notes mus2))
         (note-count (min (length notes1) (length notes2))))

    #{
       \once \override Glissando #'minimum-length = #5
       \once \override Glissando #'springs-and-rods =
#ly:spanner::set-spacing-rods
       \once \override Glissando #'thickness = #2
     <<
       {
         $(add-glissando mus1)
         $mus2
       }
       $(if (> note-count 1) (add-glissando-line mus1 mus2 1))
       $(if (> note-count 2) (add-glissando-line mus1 mus2 2))
       $(if (> note-count 3) (add-glissando-line mus1 mus2 3))
       $(if (> note-count 4) (add-glissando-line mus1 mus2 4))
       $(if (> note-count 5) (add-glissando-line mus1 mus2 5))
       $(if (> note-count 6) (add-glissando-line mus1 mus2 6))
       $(if (> note-count 7) (add-glissando-line mus1 mus2 7))
    >>
  #}))


\relative c' {
 \new Staff  {
   d8 [ \chordGlissando <c e g>16 <d f a>] e4 <e g c> d |
   \chordGlissando <c e g>4 <e c f> \chordGlissando <c e g> <d f a> |
   \chordGlissando <c e>4 <e g>4
   \chordGlissando <c e g c>4 <e g c e>4
 }
}



Reply | Threaded
Open this post in threaded view
|

Re: Problems with chord glissandos with articulations and tablature

Carl Sorensen



On 4/16/10 6:23 AM, "Kieren MacMillan" <[hidden email]>
wrote:

> Carl,
>
> 1. This is awesome!

Thanks!  I had fun doing it, and learned more about Scheme programming in
LilyPond.

> 2. I get "clashing note columns" errors < is that a known side-effect, to be
> ignored?

Yes, it is.  There are more than two voices with notes in the same position,
so LilyPond complains.  But the excess notes are transparent, so they don't
cause any problems.

Thanks,

Carl



Reply | Threaded
Open this post in threaded view
|

Re: Problems with chord glissandos with articulations and tablature

Carl Sorensen
In reply to this post by Carl Sorensen



On 4/16/10 7:27 AM, "Phil Holmes" <[hidden email]> wrote:

> You can override this:
>
> http://lsr.dsi.unimi.it/LSR/Item?id=457


Thanks for the tip!

Here's a revised version, with the warning message turned off during the
chordGlissando and back on afterwards:

%%%%% Start of cut and paste section

\version "2.13.3"

chordGlissando =
#(define-music-function (parser location mus1 mus2) (ly:music? ly:music?)
  "Make a glissando between the notes of triads @code{mus1} and
@code{mus2}."

  (define (add-glissando musChord)
     (let ((els (ly:music-property musChord 'elements)))
      (ly:music-set-property! musChord 'elements (append els (list
(make-music 'GlissandoEvent))))
      musChord))

  (define (get-notes musicChord)
   (filter (lambda(x) (eq? (ly:music-property x 'name) 'NoteEvent))
           (ly:music-property musicChord 'elements)))

  (define (select-note musChord index)
    (let* ((notes (get-notes musChord))
           (non-notes (filter (lambda (x)
                               (not (eq? (ly:music-property x 'name)
                                         'NoteEvent)))
                              (ly:music-property musChord 'elements)))
           (selected-note (list-ref notes index))
           (new-els (cons selected-note non-notes))
           (new-mus (ly:music-deep-copy musChord)))
     (ly:music-set-property! new-mus 'elements new-els)
     new-mus))

  (define (add-glissando-line mus1 mus2 index)
    #{
       \new Voice {
         \hideNotes
         \override NoteColumn #'ignore-collision = ##t
         \once \override Glissando #'thickness = #2
         $(add-glissando (select-note mus1 (1- index)))
         $(select-note mus2 (1- index))
       }
    #})

  (let* ((notes1 (get-notes mus1))
         (notes2 (get-notes mus2))
         (note-count (min (length notes1) (length notes2))))

    #{
       \once \override Glissando #'minimum-length = #5
       \once \override Glissando #'springs-and-rods =
#ly:spanner::set-spacing-rods
       \once \override Glissando #'thickness = #2
     <<
       \override NoteColumn #'ignore-collision = ##t
       {
         $(add-glissando mus1)
         $mus2
       }
       $(if (> note-count 1) (add-glissando-line mus1 mus2 1))
       $(if (> note-count 2) (add-glissando-line mus1 mus2 2))
       $(if (> note-count 3) (add-glissando-line mus1 mus2 3))
       $(if (> note-count 4) (add-glissando-line mus1 mus2 4))
       $(if (> note-count 5) (add-glissando-line mus1 mus2 5))
       $(if (> note-count 6) (add-glissando-line mus1 mus2 6))
       $(if (> note-count 7) (add-glissando-line mus1 mus2 7))
    >>
    \revert NoteColumn #'ignore-collision
  #}))


\relative c' {
 \new Staff  {
   \override NoteColumn #'ignore-collision = ##t
   d8 [ \chordGlissando <c e g>16 <d f a>] e4 <e g c> d |
   \chordGlissando <c e g>4 <e c f> \chordGlissando <c e g> <d f a> |
   \break
   \chordGlissando <c e>4 <e g>4
   \chordGlissando <c e g c>4 <e g c e>4
 }
}
 



Reply | Threaded
Open this post in threaded view
|

Re: Problems with chord glissandos with articulations and tablature

Carl Sorensen
In reply to this post by Carl Sorensen



On 4/16/10 8:30 AM, "Bernardo Barros" <[hidden email]> wrote:

> Hi Carl and others,
>
> Very good job indeed! I'm trying now to notate the chord glissando I mentioned
> in the first email. The problem is that it is actually a re attacked chord
> glissando, so I would need to hide some noteheads and the glissando should
> "jump" to the next note head. I'm thinking in the best way to do this job.
> What should I do?

Check out the attached files for one possibility.  Note that I've moved the
chordGlissando function to its own .ly file so it can be included in any .ly
file you desire to write, without having to copy it in an editor.

HTH,

Carl

P.S.  If you're going to be here on lilypond-user a lot (and I hope you'll
stay a user), you should know that there are two items of list etiquette
that you haven't been following in your posts:

1) No top posting -- your new message should not be at the top of the
previous message, but below the relevant parts of the previous message

2) Trimming unnecessary parts of the previous message -- instead of
including the whole thing, only include the parts that are necessary to
understand your new comment or questions.


Following  these two points will help you get the most experienced
developers to pay attention to your questions.



chord-glissando.ly (3K) Download Attachment
chord-gliss-attacked.ly (498 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Problems with chord glissandos with articulations and tablature

Marc Hohl
Carl Sorensen schrieb:

>
> On 4/16/10 8:30 AM, "Bernardo Barros" <[hidden email]> wrote:
>
>  
>> [...]
>>    
>
> Check out the attached files for one possibility.  Note that I've moved the
> chordGlissando function to its own .ly file so it can be included in any .ly
> file you desire to write, without having to copy it in an editor.
>  
Hello Carl,

thanks for your work - this extension is great! However, in combination
with tab staves, the explicit declaration of "\new Voice" in
add-glissando-line
creates spurious staves below the tablature. Is there a way to switch
to TabVoice automatically, i.e. to get the current context, and if it is a
Staff, then use Voice, if it is TabStaff, use TabVoice?

Thank you!

Marc



Reply | Threaded
Open this post in threaded view
|

Re: Problems with chord glissandos with articulations and tablature

Carl Sorensen



On 4/23/10 1:48 AM, "Marc Hohl" <[hidden email]> wrote:

> Carl Sorensen schrieb:
>>
>> On 4/16/10 8:30 AM, "Bernardo Barros" <[hidden email]> wrote:
>>
>>  
>>> [...]
>>>    
>>
>> Check out the attached files for one possibility.  Note that I've moved the
>> chordGlissando function to its own .ly file so it can be included in any .ly
>> file you desire to write, without having to copy it in an editor.
>>  
> Hello Carl,
>
> thanks for your work - this extension is great! However, in combination
> with tab staves, the explicit declaration of "\new Voice" in
> add-glissando-line
> creates spurious staves below the tablature. Is there a way to switch
> to TabVoice automatically, i.e. to get the current context, and if it is a
> Staff, then use Voice, if it is TabStaff, use TabVoice?

There is a way to accomplish this, but AFAICS it will require fundamental
changes in the format of the code.

The problem is that the context is not available during parsing, which is
when the music functions are evaluated.  In order to make it work, the \new
Voice has to be replaced with some kind of (make-music 'contextSpeccedMusic
...) that will apply during the translation stage, when grobs are evaluated.

The way to do that is demonstrated in the revert-beam-setting function of
scm/beam-settings.scm.  It uses ly:export, and context-spec-music, and
make-apply-context.

Now, in this case, we probably don't need to use ly:export, since we aren't
trying to change property settings.  But I think we will need to use
make-apply-context, which will eventually be called with a context as an
argument.

Unfortunately, I don't have time to pursue this right now.  But I'd be happy
to provide any support to you that I can.

It may be possible to create a hack that works with parser variables.  That
is, we might be able to use something like the following

parserSetVoiceSymbol =
#(define-music-funtion (parser location voice-symbol) (symbol?)
  (ly:parser-define! parser 'voiceSymbol voice-symbol))


then put a check in chord-glissando.ly  using (ly:parser-lookup parser
'voiceSymbol)

and in your music do

<<
\new Staff {
  \new Voice {
     \parserSetVoiceSymbol #'Voice
     \myMusicIncludingChordGlissando
  }
}
\new TabStaff {
  \new TabVoice {
     \parserSetVoiceSymbol #'TabVoice
     \myMusicIncludingChordGlissando
  }
}
>>

Note: I haven't tested any of the above code, it's just an idea I had.

HTH,

Carl



Reply | Threaded
Open this post in threaded view
|

Re: Problems with chord glissandos with articulations and tablature

Carl Sorensen
In reply to this post by Marc Hohl



On 4/23/10 1:48 AM, "Marc Hohl" <[hidden email]> wrote:

> Carl Sorensen schrieb:
>>
>> On 4/16/10 8:30 AM, "Bernardo Barros" <[hidden email]> wrote:
>>
>>  
>>> [...]
>>>    
>>
>> Check out the attached files for one possibility.  Note that I've moved the
>> chordGlissando function to its own .ly file so it can be included in any .ly
>> file you desire to write, without having to copy it in an editor.
>>  
> Hello Carl,
>
> thanks for your work - this extension is great! However, in combination
> with tab staves, the explicit declaration of "\new Voice" in
> add-glissando-line
> creates spurious staves below the tablature. Is there a way to switch
> to TabVoice automatically, i.e. to get the current context, and if it is a
> Staff, then use Voice, if it is TabStaff, use TabVoice?
OK, I couldn't keep away from it while I was at my son's graduation
exercise.

I've attached replacement code that now works for both a staff and tabstaff.
One issue -- you need to explicitly set string numbers for the chord,
because the glissando ends up being drawn one note pair at a time, so the
string selection algorithm doesn't work.

Again, it's probably a hack rather than a real solution; the real solution
would find the string numbers from the first chord if it's a TabVoice and
use those numbers automatically.

But it's a hack that is reasonably useful.

HTH,

Carl


chord-glissando.ly (4K) Download Attachment
chord-gliss-tab.ly (436 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Problems with chord glissandos with articulations and tablature

Marc Hohl
Carl Sorensen schrieb:

>
> On 4/23/10 1:48 AM, "Marc Hohl" <[hidden email]> wrote:
>
>  
>> Carl Sorensen schrieb:
>>    
>>> On 4/16/10 8:30 AM, "Bernardo Barros" <[hidden email]> wrote:
>>>
>>>  
>>>      
>>>> [...]
>>>>    
>>>>        
>>> Check out the attached files for one possibility.  Note that I've moved the
>>> chordGlissando function to its own .ly file so it can be included in any .ly
>>> file you desire to write, without having to copy it in an editor.
>>>  
>>>      
>> Hello Carl,
>>
>> thanks for your work - this extension is great! However, in combination
>> with tab staves, the explicit declaration of "\new Voice" in
>> add-glissando-line
>> creates spurious staves below the tablature. Is there a way to switch
>> to TabVoice automatically, i.e. to get the current context, and if it is a
>> Staff, then use Voice, if it is TabStaff, use TabVoice?
>>    
>
> OK, I couldn't keep away from it while I was at my son's graduation
> exercise.
>  
Hehe, sounds familiar :-)
> I've attached replacement code that now works for both a staff and tabstaff.
> One issue -- you need to explicitly set string numbers for the chord,
> because the glissando ends up being drawn one note pair at a time, so the
> string selection algorithm doesn't work.
>
> Again, it's probably a hack rather than a real solution; the real solution
> would find the string numbers from the first chord if it's a TabVoice and
> use those numbers automatically.
>  
Thank you for investigating further. It has one serious drawback - it
seems to be impossible
to use music variables. Your posted chord-gliss-tab.ly works properly,
but if I use

test = { \chordGlissando <c\3 e\2 g\1 >8 <f\3 a\2 c\1 >8 }

\relative c' {
  <<
 \new Staff {
   \new Voice {
     \parserSetVoiceSymbol #'Voice
     \test
   }
 }
 \new TabStaff {
   \new TabVoice {
     \parserSetVoiceSymbol #'TabVoice
     \test
   }
 }
 >>
}
it creates three separate staves below.

I wonder whether it would be possible to define something like
\new Bottom { ... }
which will be expanded to a Voice within Staff and
to [Tab|Drum]Voice within [Tab|Drum]Staff.

Perhaps I am wrong, but this should simplify things a lot.

Marc
> But it's a hack that is reasonably useful.
>
> HTH,
>
> Carl
>
>  



Reply | Threaded
Open this post in threaded view
|

Re: Problems with chord glissandos with articulations and tablature

Carl Sorensen



On 4/24/10 1:39 AM, "Marc Hohl" <[hidden email]> wrote:

> Carl Sorensen schrieb:
 

>>
>> OK, I couldn't keep away from it while I was at my son's graduation
>> exercise.
>>  
> Hehe, sounds familiar :-)
>> I've attached replacement code that now works for both a staff and tabstaff.
>> One issue -- you need to explicitly set string numbers for the chord,
>> because the glissando ends up being drawn one note pair at a time, so the
>> string selection algorithm doesn't work.
>>
>> Again, it's probably a hack rather than a real solution; the real solution
>> would find the string numbers from the first chord if it's a TabVoice and
>> use those numbers automatically.
>>  
> Thank you for investigating further. It has one serious drawback - it
> seems to be impossible
> to use music variables. Your posted chord-gliss-tab.ly works properly,
> but if I use
>
> test = { \chordGlissando <c\3 e\2 g\1 >8 <f\3 a\2 c\1 >8 }
>
> \relative c' {
>   <<
>  \new Staff {
>    \new Voice {
>      \parserSetVoiceSymbol #'Voice
>      \test
>    }
>  }
>  \new TabStaff {
>    \new TabVoice {
>      \parserSetVoiceSymbol #'TabVoice
>      \test
>    }
>  }
>>>
> }
> it creates three separate staves below.

Oh, yes, of course. At the time test is parsed, we don't have a
\parserSetVoiceSymbol setting active.  So my hack won't work.

I guess it's back to the difficult and complicated problem of making it
happen during translation.

>
> I wonder whether it would be possible to define something like
> \new Bottom { ... }
> which will be expanded to a Voice within Staff and
> to [Tab|Drum]Voice within [Tab|Drum]Staff.
>
> Perhaps I am wrong, but this should simplify things a lot.

Yes, it would.  But I have no idea how to do such a thing.  In fact, I don't
even know how I'd get started on it.

Thanks,

Carl