0
0

Hi,
I’m new to FMOD and audio programming. I am trying to use System::createSound() from WAV samples data in memory in Xcode 4/iOS. I get an "Unsupported file or audio format" exception. When I store this data into a WAV file and read it with System::createSound() it works. Can anyone tell me what I am doing wrong? Thanks!

Code:
FMOD_CREATESOUNDEXINFO info;
memset(&info, 0, sizeof(FMOD_CREATESOUNDEXINFO));
info.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);

                    // When reading from wav file: lengthpcm 740589, lengthbytes 1481178, channels 1, format 2, freq 16000, mode 00000149

                    info.numchannels = num_channels; // 1
                    info.defaultfrequency = sample_rate; // 16000
                    info.format = FMOD_SOUND_FORMAT_PCM16;
                    info.suggestedsoundtype = FMOD_SOUND_TYPE_WAV;
                    info.length = num_channels * num_samples * sizeof(short);

                    FMOD::Sound * sound = 0;

                    system -> createSound((const char *) samples, // samples is where the data is stored
                                                      FMOD_OPENMEMORY | FMOD_CREATESAMPLE | FMOD_SOFTWARE, &info, &sound);

Log:

FMOD: SystemI::createSoundInternal : memory = 0x14ac0000 : mode 00000940
FMOD: SystemI::createSoundInternal : exinfo->cbsize = 136
FMOD: SystemI::createSoundInternal : exinfo->length = 1481178
FMOD: SystemI::createSoundInternal : exinfo->numchannels = 1
FMOD: SystemI::createSoundInternal : exinfo->defaultfrequency = 16000
FMOD: SystemI::createSoundInternal : exinfo->format = 2
FMOD: SystemI::createSoundInternal : exinfo->suggestedsoundtype = 19
FMOD: SystemI::createSoundInternal : 20 codecs found. Scan all until one succeeds
FMOD: CodecWav::openInternal : attempting to open as WAV..
FMOD: Codec::release :
FMOD: Plugin::release : (0xa98f398)
FMOD: Plugin::release : done
FMOD: Codec::release : done
FMOD: SystemI::createSoundInternal : memory = 0x14ac0000 : mode 00000940
FMOD: SystemI::createSoundInternal : exinfo->cbsize = 136
FMOD: SystemI::createSoundInternal : exinfo->length = 1481178
FMOD: SystemI::createSoundInternal : exinfo->numchannels = 1
FMOD: SystemI::createSoundInternal : exinfo->defaultfrequency = 16000
FMOD: SystemI::createSoundInternal : exinfo->format = 2
FMOD: SystemI::createSoundInternal : exinfo->suggestedsoundtype = 19
FMOD: SystemI::createSoundInternal : 20 codecs found. Scan all until one succeeds
FMOD: CodecWav::openInternal : attempting to open as WAV..
FMOD: Codec::release :
FMOD: Plugin::release : (0xac4b9c8)
FMOD: Plugin::release : done
FMOD: Codec::release : done
FMOD: SystemI::createSoundInternal : memory = 0x14ac0000 : mode 00000940
FMOD: SystemI::createSoundInternal : exinfo->cbsize = 136
FMOD: SystemI::createSoundInternal : exinfo->length = 1481178
FMOD: SystemI::createSoundInternal : exinfo->numchannels = 1
FMOD: SystemI::createSoundInternal : exinfo->defaultfrequency = 16000
FMOD: SystemI::createSoundInternal : exinfo->format = 2
FMOD: SystemI::createSoundInternal : exinfo->suggestedsoundtype = 19
FMOD: SystemI::createSoundInternal : 20 codecs found. Scan all until one succeeds
FMOD: CodecWav::openInternal : attempting to open as WAV..
FMOD: Codec::release :
FMOD: Plugin::release : (0x17226638)
FMOD: Plugin::release : done
FMOD: Codec::release : done
FMOD error on line 1210: (25:Unsupported file or audio format. )
(lldb)

  • You must to post comments
0
0

you don’t need to describe the pcm format of the sound, that’s what fmod does when it parses the wav header.

You need the length of the file, in ‘length’ not the decompressed pcm length. That would only apply if you used FMOD_OPENRAW.

  • You must to post comments
0
0

I don’t have a WAV header in memory, only samples. I have the number of channels (1), sample rate (16000), number of samples, and can compute length in bytes from this (channels x number of samples x sizeof(sample)). The samples in memory is an array of short values. I just want FMOD to read the data, perhaps I don’t need to describe the sound type as WAV, but what?

  • You must to post comments
0
0

I am able to create a sound by adding FMOD_OPENRAW flag in createSound() and not supplying the suggested sound type (WAV) in the info data structure. Thanks brett.

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.