0
0

Hello,

I’m using an i-mate jam Pocket PC device, running on CE4.2. My application simply loads a MS PCM .wav file into memory, accesses smaller chunks of the data and plays the smaller chunks. Currently no processing is done on the smaller chunks of data, but I’ll be adding that in later.

The code runs but all I hear on the speaker is noise, instead of the sounds contained in the original .wav file. Could you let me know what I’m doing wrong in my code below?

Another question is, does FMOD only support MS PCM .wav files on Pocket PC? I tried to load a .au file but FSOUND_Sample_Load() returns null.

Thanks for your help.


signed short *ptrFirstPart,*ptrSecondPart;
unsigned int firstPartLen, secondPartLen;
int sampLen, sampLenByte, channel;
FSOUND_SAMPLE *samp = NULL;
FSOUND_SAMPLE   *resultSamp = NULL;

bool bResult = FSOUND_Init(44100, 32, 0);

samp = FSOUND_Sample_Load(FSOUND_FREE, "Recording2.wav", FSOUND_NORMAL, 0, 0);

resultSamp = FSOUND_Sample_Alloc(FSOUND_FREE, NUM_SAMPLES, FSOUND_NORMAL, 8000, 255, 128, 1);

sampLen = FSOUND_Sample_GetLength(samp); //get length of the file in SAMPLES
sampLenByte = sampLen * 2; //length of the file in BYTES (1 SAMPLE = 2 BYTES)

for (int j=0; j<(sampLenByte/NUM_SAMPLES-1); j++)
{
    bResult = FSOUND_Sample_Lock(samp, j*NUM_SAMPLES, NUM_SAMPLES, (void**)&ptrFirstPart, (void**)&ptrSecondPart, &firstPartLen, &secondPartLen);

    if (bResult)
    {
        if (FSOUND_Sample_Upload(resultSamp, (void*)&ptrFirstPart, FSOUND_NORMAL))
        {

              if (FSOUND_PlaySound(FSOUND_FREE, resultSamp))
              {
                  m_cListBox.AddString(_T("played sound correctly"));
              }

        bool bResult2 = FSOUND_Sample_Unlock(samp, (void*)&ptrFirstPart, (void*)&ptrSecondPart, firstPartLen, secondPartLen);
        }
    }
    else
    {
        m_cListBox.AddString(_T("Unable to lock sample"));
    }
}
  • You must to post comments
0
0

Hi Brett,

Thanks for your reply.

Maybe for now just ignore that code. I probably need to work on it more. Basically what I was trying to do here was to load a .wav file and play certain portions of the file. For example, suppose my .wav file is simply a voice saying “Hello, how are you? Nice weather today.” What I was trying to do was play only the “how are you?” portion. Is this possible?

If yes, could you recommend a better approach to doing this than what I have done?

In answer to your question, yes, the source wav is 16bit mono, 8000Hz.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.