lilypond-user
[Top][All Lists]
Advanced

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

Re: Auto-panner


From: David Kastrup
Subject: Re: Auto-panner
Date: Mon, 27 Jan 2014 16:54:27 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Jan-Peter Voigt <address@hidden> 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



reply via email to

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