lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Function to add a drone staff?


From: Paul Morris
Subject: Re: Function to add a drone staff?
Date: Sat, 11 Apr 2015 22:07:43 -0700 (MST)

Gilles Sadowski wrote
> It happens when you use bar checks!
> The sound is continuous without them but it would be quite annoying to
> encode without their help for spotting mistakes... [I use version 
> 2.18.2.]
> 
> In addition, the midi volume and instrument used for the drone must be
> different from that of the main melody (in order not to overwhelm the
> melody lines).

Well, here's where the climb gets steep in trying to make this more robust. 
See below where I added a "music-filter" step that filters out the bar
checks.  This solves the bar check problem, but there will surely be similar
things that will also need to be filtered out.  

These can be added just like for bar checks, but it's a tall order to figure
out which ones to filter out and which to leave in, given the large number
of "music types" to consider.  All the different types are found in the
LilyPond source code under scm/define-music-types.scm  (I glanced through
them, and even briefly tried it the other way around where you only leave in
note events, rest events, and... all other seemingly relevant events, but
this didn't work, as apparently more are relevant than I was leaving in.)

So that's what it will take to make this robust.  Alternatively you could
just add more types to filter out as new problems come up.  

You can uncomment \displayMusic (below) in order to see what's causing
trouble and needs filtering out.

On setting the midi volume and instrument per voice... something like what
you originally had should do the trick.  Maybe something as shown below with
separate scores for midi and layout?

Cheers,
-Paul

%%%%%%%%%%%%%%%%%%%%%%%%

\version "2.18.2"

dronify =
#(define-music-function (parser location drone melody)
   (ly:pitch? ly:music?)
   (let* ((melody-filtered
           (music-filter
            (lambda (m)
              (not (or
                    (music-is-of-type? m 'bar-check)
                    ;; add other types to filter out here, as needed...
                    )))
            melody))
          (prev #{ #})
          (current #{ #})
          (art '())

          (drone-part
           (music-map
            (lambda (m)
              (set! prev current)

              (if (and (music-is-of-type? m 'note-event)
                       (ly:pitch? (ly:music-property m 'pitch)))
                  ;; change the pitch
                  (begin
                   (ly:music-set-property! m 'pitch drone)
                   (if (and (music-is-of-type? prev 'note-event)
                            (ly:pitch? (ly:music-property prev 'pitch)))
                       ;; add tie to previous note
                       ;; avoid overwriting existing articulations
                       (begin
                        (set! art (ly:music-property prev 'articulations
'()))
                        (ly:music-set-property! prev 'articulations
                          (append art (list (make-music (quote
TieEvent)))))))))

              (set! current m)
              prev)
            melody-filtered)))
     #{ #drone-part #current #}))

melody = \relative f' {
  c4 d r e |
  f r g a |
  b c r e |
  f r g a |
  b
}

\score {
  \new Voice {
    \clef G
    \melody
  }
  \layout {}
}

\score {
  <<
    \new Voice {
      \set midiInstrument = "oboe"
      \set midiMinimumVolume = #0.6
      \set midiMaximumVolume = #0.7
      \clef G
      % \displayMusic
      \melody
    }
    \new Voice {
      \set midiInstrument = "accordion"
      \set midiMinimumVolume = #0.2
      \set midiMaximumVolume = #0.3
      % \displayMusic
      \dronify g \melody
    }
  >>
  \midi {}
}



--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/Function-to-add-a-drone-staff-tp174261p174406.html
Sent from the User mailing list archive at Nabble.com.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]