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: Thu, 9 Apr 2015 10:26:54 -0700 (MST)

Sven Axelsson-3 wrote
> Intersting. I have never tried to generate midi output for bagpipe
> music. I suspect grace notes are not handled well. But in regards to
> the dronification, all of the music, both melody and drone, should be
> played legato. Is that also something that could be set up easily with
> a music function?

Yes, I think so, although I'm not sure exactly how to do it off the top of
my head.

Below is a simpler version of dronify and a way to get both drone notes in
one voice by using this automatic octaves snippet:
http://lsr.di.unimi.it/LSR/Item?id=445

Cheers,
-Paul

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

dronify =
#(define-music-function (parser location drone melody)
   (ly:pitch? ly:music?)
   (music-map
    (lambda (m)
      (if (ly:pitch? (ly:music-property m 'pitch))
          (ly:music-set-property! m 'pitch drone))
      m)
    melody))

#(define (octave-up m t)
   (let* ((octave (1- t))
          (new-note (ly:music-deep-copy m))
          (new-pitch (ly:make-pitch
                      octave
                      (ly:pitch-notename (ly:music-property m 'pitch))
                      (ly:pitch-alteration (ly:music-property m 'pitch)))))
     (set! (ly:music-property new-note 'pitch) new-pitch)
     new-note))

#(define (octavize-chord elements t)
   (cond ((null? elements) elements)
     ((eq? (ly:music-property (car elements) 'name) 'NoteEvent)
      (cons (car elements)
        (cons (octave-up (car elements) t)
          (octavize-chord (cdr elements) t))))
     (else (cons (car elements) (octavize-chord (cdr elements ) t)))))

#(define (octavize music t)
   (if (eq? (ly:music-property music 'name) 'EventChord)
       (ly:music-set-property! music 'elements (octavize-chord
                                                (ly:music-property music
'elements) t)))
   music)

makeOctaves = #(define-music-function (parser location arg mus) (integer?
ly:music?)
                 (music-map (lambda (x) (octavize x arg)) (event-chord-wrap!
mus)))

melody = \relative f' {
  c4 r c8 d8 r4
  g2 r4 b4
}

<<
  \melody
  \makeOctaves #1 \dronify g \melody
>>



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



reply via email to

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