Does juce support pan when playback?

hi, jules
How are you?
Is there any class support pan for playback? It is that we can adjust volume for left output channel for certain percentage, and same thing happens for right output channel.

any method now in juce lib?

Cheers!
Leon

Don’t think there’s anything in there, actually. It’s pretty trivial to perform a pan though…

This is a fairly old topic, but I thought it was better to pst a reply than to open a new one.

I found that volume-neutral stereo panning is not trivial at all. The simple solution would be:

buffer.applyGain (0, 0, buffer.getNumSamples(), pan);
buffer.applyGain (1, 1, buffer.getNumSamples(), 1.0f - pan); 

But that would reduce the volume by 0.5 in center position. Also it does not account for the fact that a pan knob does not behave linear. There is also no easy way to skip the above code if pan == 0.5f.

What I am looking for is a panner that is <1.0, 1.0> in center position (neutral) and logarithmically reduces one channel while slightly boosting the opposite channel when the pan is turned off center, perhaps like < 0.0012, 1.10>

Or am I missing something? Is it normal that each panner decreases the volume?

[quote=“ans”]What I am looking for is a panner that is <1.0, 1.0> in center position (neutral) and logarithmically reduces one channel while slightly boosting the opposite channel when the pan is turned off center, perhaps like < 0.0012, 1.10>

Or am I missing something? Is it normal that each panner decreases the volume?[/quote]

No, you aren’t missing anything you are correct. What you want is a pan-law that preserves total power output. Here is the relevant paper:

“Pan-Rules”
http://www.rs-met.com/documents/tutorials/PanRules.pdf

The author’s website (check out the Tutorials section)
http://www.rs-met.com/

And this is a good place to ask audio-related questions:

Wow, thanks so much for the pointers. Very helpful!