Jan-Peter Voigt <jp.vo...@gmx.de> writes: > Thanks, David. > @Vaughan > For a short test ... this compiles, but I can't listen to the resulting > pan in midi ....
> \version "2.18.0" > > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% > %{ > > Auto panner > > Spreads voices evenly from -1 (LEFT) to 1 (RIGHT) > > Usage: > > \include "autopanner.ly" > \SetTotalAutopanStaves #2 % or \SetTotalAutopanVoices [...] > #(define autopan-total-voices 2.0) > > #(define autopan-current-voice -1.0) > > #(define autopan-staff-or-voice 'Staff) > > ResetAutoPanning = > #(define-void-function > (parser location) > () > (set! autopan-current-voice -1.0) > ) > > SetTotalAutopanVoices = > #(define-void-function > (parser location total-voices) > (number?) > (begin > (set! autopan-total-voices total-voices) > (set! autopan-current-voice -1.0) > (set! autopan-staff-or-voice 'Voice) > ) > ) [...] > autopan = > #(define-scheme-function (parser location)() Why define-scheme-function when returning music? > (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. If you want to keep tabs on your current voice, you need to use a score-level context property. -- David Kastrup _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user