[sdiy] Pan laws - logarithmic or linear? (SSM2164 stereo panning)
cheater cheater
cheater00 at gmail.com
Mon Feb 15 01:09:07 CET 2010
well, let's look at it this way: you need a logarithmic response,
therefore there will be something like y = log(x) in your formula,
where x is your knob position and y is the voltage gain.
the 'sinusoidal shape' that you mention is actually the segment of the
logarithmic curve that starts at x=1 (where the curve touches the
horizontal axis) towards the right. How far towards the right? We can
arbitrarily decide. So x=1 is the minimum of our knob when it's fully
counterclockwise and the curve is the response of the right channel.
Let's assume that the knob is centered when x = 2, and at maximum when
x = 3.
Now at x=2, we have a voltage gain of -3dB, so approx. 0.708V. At x=3
we have the output at 0dB so 1V. At x=1 we have -inf dB so 0V.
So we need a logarithmic curve that goes through these points:
x | y
--------
1 | 0
2 | 0.708
3 | 1
Now we could easily fit a curve of the form y = a*log(x) to two
points. But the third point will never fit: if we try to fit the x=1
and x=3 points, then the x=2 point will not be on the curve, etc. So
we need to 'bend' the curve, i.e. make it bulge out more, i.e. change
its curvature. We can do this by scaling it horizontally:
y = a*log(x/b)
However, for any b other than 1, our constraint that for x=1 we get
y=0 will not hold. The curve will have the right shape, but the zero
crossing will move to the right or left of x=1. So we need to move it
back by offsetting the argument:
y = a*log(x/b + c)
So we have:
a*log(1/b + c) = 0
a*log(2/b + c) = 0.708
a*log(3/b + c) = 1
The first equation can be simplified:
1/b + c = 1
a*log(2/b + c) = 0.708
a*log(3/b + c) = 1
Plug into the other two equations:
1/b + c = 1
a*log(1/b + 1/b + c) = 0.708
a*log(2/b + 1/b + c) = 1
1/b + c = 1
a*log(1/b + 1) = 0.708
a*log(2/b + 1) = 1
Divide the second by the third:
log(1/b + 1)/log(2/b + 1) = 0.708
Wolfram alpha gives us b if we paste in the above equation:
b = 0.3544212...
Therefore
c = -1.821502...
We have
a*log(2/0.3544212 + 1) = 1
therefore:
a = 0.5281...
Try these values. If they don't work, try some other values. =)
In the end, y = alog(x/b + c) = 0.5281 * log((x / 0.3544212) -1.821502)
This is the plot:
http://tinyurl.com/ydfkom6
full url here:
http://www.wolframalpha.com/input/?i=plot+0.5281+*+log%28%28x+%2F+0.3544212%29+-1.821502%29+from+1+to+3
So this looks like what we're looking for. However our free variable,
x, has to assume values from 1 to 3, which is not good. Let's first
normalize it by making it assume values from 0 to 1:
0.5281 * log((x / 0.3544212) -1.821502) needs x = 1..3
0.5281 * log(((x+1) / 0.3544212) -1.821502) needs x = 0..2
0.5281 * log(((2x+1) / 0.3544212) -1.821502) needs x = 0..1
Your knob will probably assume values from 0 to 255, or generally from 0 to M.
0.5281 * log(((2x/255+1) / 0.3544212) -1.821502) needs x = 0..255
So the final formula you are looking for is:
0.5281 * log(((2x/M+1) / 0.3544212) -1.821502)
Here's the graph for M=255:
http://preview.tinyurl.com/y8f9t7x
full url:
http://www.wolframalpha.com/input/?i=plot+0.5281+*+log%28%28%282x%2F255%2B1%29+%2F+0.3544212%29+-1.821502%29+from+0+to+255
The graph still looks like what we are looking for - so we didn't mess
anything up.
Here are some more exact values of a,b,c:
a ~= 0.528104659875393
b ~= 0.354421246832857
c ~= -1.821501275490954
Our final formula is:
y = a * log(((2x/M+1) / b) + c)
for the right channel and
y = a * log(((2(M-x)/M+1) / b) + c)
for the left channel.
Similarly you can solve this for any other voltage gain in the center.
You could even find the formulas for a,b,c based on the value of the
center attenuation.
Similarly you can fit any other curves. For example an y = sqrt(x)
curve can also be defined with three points. Similarly many other
simple, useful curves can work well for you.
HTH
D.
On Sun, Feb 14, 2010 at 21:16, Tom Wiltshire <tom at electricdruid.net> wrote:
> Hi all,
>
> I wonder if someone can help me get something clear in my head. I'm getting
> muddled up between logarithmic and linear scales.
>
> I'm trying to implement a sensible-sounding pan on my dual stereo SSM2164
> VCA. This is considerably complicated by the fact that the SSM2164 has a log
> response on its control input. The effect of this is that if you simply fade
> down the left channel linearly whilst fading up the right channel linearly,
> you get a massive hole in the middle. The sound moves a little towards the
> centre, but disappears. Finally it re-emerges over by the right speaker.
>
> I understand that the classic pan law is 3dB down in the middle. In theory,
> it should need to be 6dB down, but in practice 3dB is usually enough.
> This reduction is achieved by using something that looks like a cosine curve
> from 0 to Pi/2 on the left channel, and the same reversed on the right. In
> the centre, both channels are at about 2/3rds or 3/4 of full output.
>
> Now what I don't understand is what the Y-scale is on this cosine graph - is
> it logarithmic or linear?
>
> I'm controlling the two VCA channels from software using a 12-bit DAC, so
> what I'm going to finish up doing is using a lookup table to compensate for
> the log control response and give me something more like the function I'm
> after. clues as to what this table should look like appreciated.
>
> I think I might be suffering from Sunday night burnout. I've been developing
> this circuit all weekend, but now I've got a 'Pan' variable and a 'Volume'
> variable, and I've got to convert them into a 'Left CV' and a 'Right CV' and
> the response of those two CVs is logarithmic and it's all just muddling up
> in my head.
>
> The 'design process' wisdom was to go and take a break, right? I'm on it....
>
> Thanks,
> Tom
> _______________________________________________
> Synth-diy mailing list
> Synth-diy at dropmix.xs4all.nl
> http://dropmix.xs4all.nl/mailman/listinfo/synth-diy
>
More information about the Synth-diy
mailing list