Bug: pan.ny should not use "int"

The Panning plug-in (updated January 10, 2006, last modified: Feb 2008) (R.I.P. David Sky) defines the control value as an “int”, so it’s either fully-left or fully-right. The control should be a “float” or a “real” - someone with more knowledge than I can decide which. I made it a float, and It Works For Me.

In all honesty, I rarely use this plug-in, because it converts Stereo to Mono, then pans that, but I greatly prefer to keep the original stereo signal. This time, though, I started with a mono signal…

  • Win

Yes,you’re right.

That link goes to the “old” Audacity stuff (http://old.audacityteam.org/nyquist/pan.ny) which has been retained purely as a historical archive. I’m not able to modify anything on that site as it is “frozen in history” (it’s “read only”).

We do however link to it form the Audacity wiki (Missing features - Audacity Support).
What I’ll have to do is to “replace” that plug-in with a new version.

As it is a “version 1” plug-in, it would be correct to change “int” to “real”, but as we are updating it, then we may as well update it to “version 4”, in which case the correct syntax is “float”.


If we’re “updating” the plug-in, then I think we need to retain it’s original functionality, but we could add an option that retains the original stereo signal. There’s a number of different ways that could be done. Each “choice” needs a name.

What options would you like this plug-in to have?

Perfect, for both actions! As soon as I saw “old” in the link name, I knew it would take something other than just updating in-place.

You’re right about multiple-choice panning options - I saw one method (possibly from you, but I forget) which preserved overall-equal power by reducing the input by 3dB. While it’s well-intentioned, I’m pretty sure I’d never use that approach. I’m going to be experimenting later, but I think what I’m looking for is reducing the panned-away side of the stereo signal, and adding that “reduced” signal to the other side. Obviously, that risks clipping on the panned-to side…

My first choice would be the “obvious” one - do what the Pan control (on the Track Control Panel) does. I’ve never looked into exactly what that does, but I’m guessing it reduces the panned-away side, leaving the panned-to side untouched. It’s been fine for my (limited) needs in the past.

  • Win

Yes, that’s what it does.

I think the disadvantage of this approach for stereo tracks, is that it isn’t actually “panning”, it’s just adjusting the amount of left and right channels (sometimes referred to as “balance”). The term “panning” in a strict sense refers to the left/right positioning of sounds in the stereo image.

Here’s some code that I think should do “real” stereo panning. It can be run in the Nyquist Prompt.

;version 4
;type process

;control pan "Left / Right" float "" 0 -1 1

(setf left-chan
    (if (> pan 0) ;pan right
        (mult (aref *track* 0) (- 1 pan))
        (mult (/ (1+ (abs pan)))
              (sum (aref *track* 0)
                   (mult (aref *track* 1) pan)))))

(setf right-chan
    (if (> pan 0)
        (mult (/ (1+ pan))
              (sum (aref *track* 1)
                   (mult (aref *track* 0) pan)))
        (mult (aref *track* 1) (+ 1 pan))))

(vector left-chan right-chan)

What I’d suggest is that the plug-in offers a choice of:

  • Mono Pan (like the current plug-in version)
  • Balance (like the Audacity Pan slider)
  • Stereo Pan (similar to the above code snippet)

A big Up-Vote for this! Thanks, Steve.

  • Win

Please try this plug-in and say if you find any problems, or can suggest any improvements:
panning.ny (2.16 KB)
“Pan mono” is similar to the original ‘Panning’ plug-in effect
in that it mixes the track to mono, and then pans the mono sound.
Unlike the original ‘Panning’ effect, which had a tendency to clip,
this implementation ensures overall unity gain.

“Pan Stereo” is ‘true stereo’ panning. When panning to the right, a
portion of the left channel is moved to the right channel, and the right
channel is scaled for overall unity gain. Panning to the left is achieved
in like fashion.

“Balance” is equivalent Audacity’s track pan.

This is exactly what I was looking for, and I’ve exercised it enough to know that it works “as it says on the tin.” Thank you very, very much!

(…and it only took me three weeks to get back to you! Sorry about that.)

  • Win