Question

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!

Was it helpful?

Solution

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;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top