0
0

Hello,
if I want to make FMOD to play raw data, do I have to append format on it ?

[code:2y5f7o2l]
myWAV wav_file("1.wav"); // constructor
char* tempData = (char *)malloc( wav_file.getBuffLen() );

FMOD_CREATESOUNDEXINFO exinfo;

memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
exinfo.cbsize           = sizeof(FMOD_CREATESOUNDEXINFO);
exinfo.length           = infile.getBuffLen(); //length;

printf( "buffer length = %d\n", wav_file.getBuffLen() );

strcpy( tempData, wav_file.getBuff() );
result = system->createSound( tempData, FMOD_HARDWARE | FMOD_OPENMEMORY | FMOD_2D, &exinfo, &sound);

[/code:2y5f7o2l]

after read in "1.wav", myWAV will save raw sound chunk into buffer.
wav_file.getBuffLen() can get the size of the buffer,
wav_file.getBuff() will return the buffer.

after compiled, I run the executable file,
it shows :
buffer length = 630784
FMOD error! (25) Unsupported file or audio format.

is FMOD able to read raw data or I have to append the format to raw data and make it like a wav file?
thanks
[/code]

  • You must to post comments
0
0

The FMOD_CREATESOUNDEXINFO strcut contains a format parameter:
FMOD_SOUND_FORMAT format;

You can try setting the format directly to one of the following:
[code:1fw4ocnm]
FMOD_SOUND_FORMAT_PCM8,
FMOD_SOUND_FORMAT_PCM16,
FMOD_SOUND_FORMAT_PCM24,
FMOD_SOUND_FORMAT_PCM32,
FMOD_SOUND_FORMAT_PCMFLOAT,
[/code:1fw4ocnm]

Hope this helps,

-Pete

  • You must to post comments
0
0

Hi,

It is runable after setting FMOD_SOUND_FORMAT_PCM16 into exinfo,
but now I cannot hear anything after the raw sound chunk sent into playSound. The length of raw sound chunk is right, I don’t know if I miss anything here.

[code:2ovmtl0x]
myWAV wav_file("1.wav"); // constructor
char* tempData = (char *)malloc( wav_file.getBuffLen() );

FMOD_CREATESOUNDEXINFO exinfo;

memset( &exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO ) );
exinfo.cbsize           = sizeof( FMOD_CREATESOUNDEXINFO );
exinfo.length           = wav_file.getBuffLen(); //length;
exinfo.format           = FMOD_SOUND_FORMAT_PCM16; 
exinfo.defaultfrequency = 22050;
exinfo.numchannels      = 1;

printf( "buffer length = %d\n", wav_file.getBuffLen() );

strcpy( tempData, wav_file.getBuff() );
result = system->createSound( (const char* ) tempData, FMOD_SOFTWARE | FMOD_OPENMEMORY | FMOD_2D | FMOD_OPENUSER, &exinfo, &sound);  

[/code:2ovmtl0x]

  • You must to post comments
0
0

any one can help?
the raw chunk data is fine, I push the headers back to the raw chunk data and the file is playable.
still can’t figure out why my code doesn’t work.

  • You must to post comments
0
0

You should try adding FMOD_OPENRAW to the create sound FMOD_MODE.
[code:gublhfch]
FMOD_OPENRAW

Will ignore file format and treat as raw pcm. Use FMOD_CREATESOUNDEXINFO to specify format. Requires at least defaultfrequency, numchannels and format to be specified before it will open. Must be little endian data. [/code:gublhfch]

This will skip the headers.

-Pete

  • You must to post comments
0
0

yes

very thanks for the help!

I misunderstood the definition of FMOD_OPENRAW, i think its gonna skip the format i set into FMOD_CREATESOUNDEXINFO, but it works after FMOD_OPENRAW inserted!

result = system->createSound( (const char* )sound_buffer, FMOD_HARDWARE | FMOD_2D | FMOD_OPENMEMORY | FMOD_OPENRAW, &exinfo, &sound);

I can hear the raw audio data now.

  • You must to post comments
Showing 5 results
Your Answer

Please first to submit.