27 March 2007

monopanner~


monopanner~

discontinued

This block places a mono signal in a stereo panorama. You can choose the panning curve that is applied. An input is also provided to vary the pan parameter externally.
This block is discontinued but it's implementation is used in the series of channel blocks.

version

goginLeft.txt - goginRight.txt

linearLeft.txt - linearRight.txt

rootLeft.txt - rootRight.txt

sineLeft.txt - sineRight.txt

pancurves.m

v1.0: built 27/03/2007 with Pd v0.40-2 [pd]
v1.1: adjustment 28/03/2007 with Pd v0.40-2
the output of the horizontal slider is now connected to the number box above it. This way the value in the number box is updated also when you slide the slider.
v2.0: built 29/03/2007 with Pd v0.40-2 [pd]
extra input for reset
PAN parameter input rescaled for MIDI data: 0-127
separate controls and displays for PAN parameter
rescaling calculated once instead of twice

v2.1: adjustment 1/04/2007 with Pd v0.40-2 [pd][pdf]

Other connections made it able to leave some away, for the initialisation logic

The reset knob only resets the PAN to the center. The table is left untouched.

Initialisation sets the table too, to the root function, because it's a more normal pan control curve than the gogin curve that was the default before.

interface


Input 1: the mono signal you want to pan
Input 2: the pan parameter, that is also included in the front of the block. It's range goes from 0 to 127 in steps of 1, where 0 stands for LEFT and 127 stands for RIGHT. This results in a PAN parameter that changes with a step size of 2, zero is not reachable with this input.
TO DO: re-size the tables, so that the step size of the input as well as the slider is equal.
Input 3: reset the PAN parameter to CENTER. That is the value read on sample 128 of the curves

Output 1 & 2: the stereo output signal.

Controls:
number box and small slider PAN: This displays the current value of the PAN parameter on a scale of -127 for LEFT to 127 for RIGHT with 0 as CENTER (when controlling from the second inlet, the value 0 is not reachable. One can do it with the reset button. This display is included to view the changes while the effect is controlled externally, as you see on the top figure: the current PAN value is 127, apparently controlled from the outside, because the controls themselves are still centered.
reset: resets the pan parameter to 0 or CENTER
number box and horizontal slider: adjust the pan parameter
gogin, linear, root and sine: choose a panning curve. root is the default value after loading the patch.


implementation


For the pan control curves a table is used. Per curve type there are two tables: one for the left and one for the right channel. The vectors are calculated in matlab with the following m-file:

xMin = -128;
xMax = 127;
x = [0:1/(xMax-xMin):1];

% gogin
arg = x*pi-pi/2;
goginLeft = sqrt(2)/2*(cos(arg)-sin(arg));
goginRight = sqrt(2)/2*(cos(arg)+sin(arg));
figure;plot(goginLeft,'b');hold on;plot(goginRight,'r');

% square root
rootLeft = sqrt(1-x);
rootRight = sqrt(x);
figure;plot(rootLeft,'b');hold on;plot(rootRight,'r');

% sine
sineLeft = cos(x*pi/2);
sineRight = sin(x*pi/2);
figure;plot(sineLeft,'b');hold on;plot(sineRight,'r');

% linear
linearLeft = 1-x;
linearRight = x;
figure;plot(linearLeft,'b');hold on;plot(linearRight,'r');

As you might have already remarked a choice is made here about how many values the control curve has. This can be changed afterwards in this m-file. xMin en xMax are defined here the same way as they are defined in the block itself: ranging from -128 to 127. A larger range would result in a smoother transition when panning, but with these values there's already no audible step.
The plotted figures can be seen in the section interface.
After calculating the values, this vector is copy pasted into a .txt-file. This space separated list is directly readable by PureData through the command read placed inside a message box. The values are thus read and written away in an array called left Channel and right Channel.


The inlet accepts values between 0 and 127, the controls range from -127 to +127 and the control curves are written in tables with a width that ranges from 0 to 256. So the range of the inlet must be multiplied with two and a one has to be added. The controls just have to be shifted over 128 samples. Then the tabread block looks up the corresponding value, depending on the chosen control function. This value is used to attenuate the incoming audio signal.

The center values per type are:

  • gogin: L=0.693; R=0.720
  • linear: L=0.494; R=0.505 (-1 is a better center)
  • root: L=0.702; R=0.711 (-1 is a better center)
  • sine: L=0.700; R=0.713 (-1 is a better center)
The table that draws the array as a graph in the patch itself as an y-index that ranges from -1 to 1. The negative values are necessary for representing all the values of the gogin function.
TO DO: maybe I can change the range of the control curves to an odd number of indices, so as to provide a real centered center, with equal loudness for both the left and right channel.

No comments: