문제

Suppose I have 8-bits (mono and stereo) .wav files. When processing of this file I have to declare pointer to array of samples.

Suppose I create array for samples. Then if it is mono, I read each sample using for(i = 0; i < n; i++ ).

Q: How can I access right and left channels separately (stereo)?

PS

I've read a lot about "mono, stereo and *.wave" but still I can't understand how can I realise access to each channell separately...

도움이 되었습니까?

해결책

You still have array of samples, the question is how you address individual values. This is how you do it:

const UCHAR* pnSamples = ...
if(bMono)
{
  for(INT nIndex = 0; ...)
  {
    const UCHAR nSample = pnSamples[nIndex];
    // ...
  }
} else
if(bStereo)
{
  for(INT nIndex = 0; ...)
  {
    const UCHAR nLeftSample = pnSamples[2 * nIndex + 0];
    const UCHAR nRightSample = pnSamples[2 * nIndex + 1];
    // ...
  }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top