0
0

Hi Gang,

Our game uses mostly 22khz mono 16-bit sounds. We’d like to ship them as compressed (vorbis) sounds but decompress them when users install the game. What’s the easiest way to decode Ogg files into adpcm with fmod? I tried the following:

1) load my ogg file into memory

2) call FSOUND_Sample_Load() with the appropriate flags (LOADMEMORY,SIGNED,MONO) <- this should in theory decode the Ogg file into PCM data

3A) At this point if I call FSOUND_Channel_PlaySound() the sound plays, but after a long delay. If I leave my tool running in a while() loop with a Sleep() call, the sound plays up to 10-15 seconds later.

OR

3B) call FSOUND_Sample_Lock() to retrieve the data from the sample buffer. To determine the amount of data to retrieve, I query FSOUND_Sample_GetLenght() (to get the # of samples), and FSOUND_Sample_GetMode() (to determine how many bits per sample)

In theory the locked buffer now contains PCM data, and if I generate a WAVEFORMATEX header and dump it out to file I should hear a wave sound. Instead I’m hearing tons of static and I can’t find any switches and dials to fix it.

All that static sounds like I have to wait for fmod to finish decoding the OGG before I can lock the sample buffer, but I don’t know how long to wait and the call to FSOUND_Sample_Load() returns right away. How do I find out when it’s ok to read from the sample buffer?

Thanks in advance,
Jeff

  • You must to post comments
0
0

Hi Brett,

I looked at the Record sample and fixed all the problems, that and I discovered the WAVEFORMATEX structure in windows’ MM system. =)

So I’m able to successfully convert from 44khz ogg to 44khz wave data, is there a way to downsample the wave to 22khz at the same time? I was sorta hoping I could do that by calling FSOUND_Init() with a sample rate of 22050hz and hoping that it would internally take care of the downsample when I loaded the sample but that turned out not to be the case. Any advice would be appreciated!

Jeff

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.