Stereo samples and panning / Surround

Started by TheRealByteraver, December 10, 2019, 07:37:03

Previous topic - Next topic

TheRealByteraver

Sorry for spamming the forum a bit, but I have another simple question. I wanted to write a new float mixer that supports stereo samples. My question is:
- How does panning affect a stereo sample? Should it affect a stereo sample at all? Or is the left channel of a stereo sample always played hard left, and the right channel hard right?

And a second, loosely related question:
- Does the surround effect only invert the phase on the right channel? Meaning the effect does nothing if the channel is panned hard left? Or is there more to it?

Thank you.

Saga Musix

There are many different possible pan laws, but in IT the left channel is always only heard on the left speaker and the right channel is only heard on the right speaker (which is balance rather than panning, strictly speaking). It is implemented using exactly the same logic as mono sample panning, except that for the left channel output, you multiply the left sample channel with the left pan factor and for the right channel output, you multiply the right sample channel with the right pan factor.

Surround is also implemented exactly the same way as for mono samples (inverting the right channel), but you have to keep in mind that in IT, surround and panning are mutually exclusive, i.e. a sample channel be panned hard-left and surround at the same time.
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.

TheRealByteraver

Thanks for clearing that up. I just realized that the surround thing is a bit tricky since I don't keep track of panning inside my mixer, only volume left and volume right. Hmm.. I suppose I can implement the surround sound effect as hard pan left + invert phase flag or something. Or rather than an invert phase flag, I could just have negative volume values for the right channel ;D. Not sure if that would be considered good style. I'll have to ponder over that a bit.

Saga Musix

Surround can/should be easily implemented as a flag in the channel state, yes.
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.