0

Suppose I've got a 16-bit PCM audio file. I wanna pan all of it completely to the left. How would I do this, purely through byte manipulation? Do I just mix the samples of the right channel with those of the left channel?

I'd also like to ask (since it seems related), how would I go about turning stereo samples into mono samples?

I'm doing this with Haxe, but code in something like C (or just an explanation of the method) should be sufficient. Thanks!

puggsoy
  • 1,270
  • 1
  • 11
  • 34

1 Answers1

1

You'll first need to convert the raw bytes into int arrays. Your output for the left channel will be the sum divided by 2.

for (int i = 0 ; i < numFrames ; ++i)
{
   *pOutputL++ = (*pInputL++ + *pInputR++) >> 1;
   *pOutputR++ = 0;
}
jaket
  • 9,140
  • 2
  • 25
  • 44
  • Why divide by two? Is that simply to avoid clipping, or is that how it's always done? – puggsoy Mar 08 '14 at 09:10
  • 1
    Yes - this is how it's always done - you don't expect the gain a hard-panned channel to be twice that of the centre position. – marko Mar 08 '14 at 15:49