Author Topic: Stereo samples and panning / Surround  (Read 594 times)

Offline TheRealByteraver

  • Inspired artist
  • **
  • Posts: 57
  • Operating System: Windows 7 Pro 64 bit
Stereo samples and panning / Surround
« on: December 10, 2019, 07:37:03 »
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.

Offline Saga Musix

  • OpenMPT Developers
  • *****
  • Posts: 7,009
  • aka Jojo
    • Download music, samples, VST plugins: Saga Musix Website
  • Operating System: Windows 10 x64
Re: Stereo samples and panning / Surround
« Reply #1 on: December 10, 2019, 16:40:58 »
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.

Offline TheRealByteraver

  • Inspired artist
  • **
  • Posts: 57
  • Operating System: Windows 7 Pro 64 bit
Re: Stereo samples and panning / Surround
« Reply #2 on: December 10, 2019, 21:06:34 »
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.

Offline Saga Musix

  • OpenMPT Developers
  • *****
  • Posts: 7,009
  • aka Jojo
    • Download music, samples, VST plugins: Saga Musix Website
  • Operating System: Windows 10 x64
Re: Stereo samples and panning / Surround
« Reply #3 on: December 13, 2019, 23:24:35 »
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.