On 27.01.2014 16:54, David Kastrup wrote:
>> autopan =
>> > #(define-scheme-function (parser location)()
> Why define-scheme-function when returning music?
Perhaps this function had another meaning in the first place?
I overlooked this, when injecting my ApplyContext lines.
>> >    (begin
>> >     (set! autopan-current-voice (+ autopan-current-voice 1.0))
>> >     (make-music
>> >      'ApplyContext
>> >      'procedure
>> >      (lambda (context)
>> >        (let ((ctx (ly:context-find context autopan-staff-or-voice)))
>> >          (if (not (ly:context? ctx)) (set! ctx context))
>> >          ;(ly:message "context ~A" ctx)
>> >          (ly:context-set-property! ctx 'midiPanPosition
>> >            (+ -1.0
>> >              (* autopan-current-voice
>> >                (/ 2.0
>> >                  (- autopan-total-voices 1.0)
> Doesn't work.  At the time the function gets called, _all_ instances of
> the function get to see the same value of autopan-current-voice.
Good point. Now all Voices turned to the right ;)
> If you want to keep tabs on your current voice, you need to use a
> score-level context property.
What about a closure?
%%%%%%%%%%%%%%
autopan =
#(define-music-function (parser location)()
   (let ((mypan (+ autopan-current-voice 1.0)))
    (set! autopan-current-voice mypan)
    (make-music
     'ApplyContext
     'procedure
     (lambda (context)
       (let ((ctx (ly:context-find context autopan-staff-or-voice)))
         (if (not (ly:context? ctx)) (set! ctx context))
         (ly:message "context ~A pan ~A" ctx mypan)
         (ly:context-set-property! ctx 'midiPanPosition
           (+ -1.0
             (* mypan
               (/ 2.0
                 (- autopan-total-voices 1.0)
                 )
               )
             )))
       ))
     ))
%%%%%%%%%%%%%%

At least now every Staff gets its own midiPanPosition.

I like the idea of auto-stereo-spreading midi channels. Now it should
also work, if autopan is used inside a global variable.
Still, I'd recommend usage of either a global context property or a
performer/engraver that keeps track of all contexts using autopan.
Perhaps it is possible to count all contexts joining autopan automatically.

But thats out of scope for me right now ;) (i might come back later on
this topic)

Best, Jan-Peter


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

Reply via email to