0
0

Hello all,

I try to perform quite basic task and for some reason it fails. I have to play mp3 bitstream from memory (actually, the bitstream comes from the network). Here’s what I do:
[code:16g566u9]
FMOD::System system;
FMOD::Sound *sound;
FMOD::System_Create(&system);
system->init(32, FMOD_INIT_NORMAL, 0);
FMOD_MODE mode = FMOD_2D | FMOD_OPENUSER | FMOD_LOOP_NORMAL | FMOD_CREATESTREAM
/
tried also with this flag| FMOD_CREATECOMPRESSEDSAMPLE*/;
memset(&createsoundexinfo, 0, sizeof(createsoundexinfo));
createsoundexinfo.cbsize = sizeof(createsoundexinfo);
createsoundexinfo.decodebuffersize = 1024 * 100;
createsoundexinfo.numchannels = 1;
createsoundexinfo.defaultfrequency = 8000;
createsoundexinfo.format = FMOD_SOUND_FORMAT_MPEG;
createsoundexinfo.pcmreadcallback = pcmreadcallback;
createsoundexinfo.pcmsetposcallback = pcmsetposcallback;
result = system->createSound(0, mode, &createsoundexinfo, &sound);[/code:16g566u9]
At this point result == FMOD_ERR_FORMAT. I tried to vary some createsoundexinfo fields – nothing helps. If I specify PCM format instead of MPEG – it works.

Any idea would be greatly appreciated!

Thank you.

  • You must to post comments
0
0

yes specifying pcm is what you’re supposed to do. You can’t create an ‘mpeg sample’ the stream has to decode into pcm before it can be played.

the fact that you specified ‘pcmreadcallback’ should have tipped you off. It says pcm in the name.

if you have raw mpeg data its not trivial, you have to set up a decode sample and use filereadcallback instead so that when fmod wants mpeg data to decode, it calls that callback.

  • You must to post comments
0
0

[quote:wxrv3yuc]the fact that you specified ‘pcmreadcallback’ should have tipped you off. It says pcm in the name. [/quote:wxrv3yuc]Well, I hoped it’s only a bad naming :)

[quote:wxrv3yuc]if you have raw mpeg data its not trivial, you have to set up a decode sample and use filereadcallback instead so that when fmod wants mpeg data to decode, it calls that callback.[/quote:wxrv3yuc]By saying "filereadcallback" you probably mean FMOD_CREATESOUNDEXINFO::userread ? If I just set it instead of pcmsetposcallback, I still have the same "bad format" error. Unfortunately, I couldn’t find any example with "userread", so probably you can elaborate a bit more on this? What FMOD_MODE should I use, what other createsoundexinfo fields should set? Note that my mp3 stream is "infinit", i.e. I don’t know its length.

  • You must to post comments
0
0

Well, so is it possible to play with FMODEx API an in-memory infinite MP3 bitstream?

  • You must to post comments
0
0

[quote:3vtwri99]By saying "filereadcallback" you probably mean FMOD_CREATESOUNDEXINFO::userread ?[/quote:3vtwri99]
No, he means this:
[code:3vtwri99]FMOD_RESULT System::attachFileSystem(
FMOD_FILE_OPENCALLBACK useropen,
FMOD_FILE_CLOSECALLBACK userclose,
FMOD_FILE_READCALLBACK userread,
FMOD_FILE_SEEKCALLBACK userseek
);[/code:3vtwri99]

This will override the FMOD file open/close/read/seek functions.

[quote:3vtwri99]Well, so is it possible to play with FMODEx API an in-memory infinite MP3 bitstream?[/quote:3vtwri99]
No. You can play in memory sounds using System::createSound with either of the FMOD_OPENMEMORY/FMOD_OPENMEMORY_POINT flags but the size must be known.

System::createSound is compatible with network streams, have you tried just using createSound with the URL of the stream as the name_or_data parameter.

-Pete

  • You must to post comments
0
0

[quote:sknn0s7b]No. You can play in memory sounds using System::createSound with either of the FMOD_OPENMEMORY/FMOD_OPENMEMORY_POINT flags but the size must be known. [/quote:sknn0s7b]Ok, I see… So I have to pre-decode mp3 and use FMOD for playback of PCM only. Too bad 😥

[quote:sknn0s7b]System::createSound is compatible with network streams, have you tried just using createSound with the URL of the stream as the name_or_data parameter.[/quote:sknn0s7b]I don’t have any standard URL, as the bitstream comes from our proprietry server.

  • You must to post comments
0
0

[quote:1d2yblv7]So I have to pre-decode mp3 and use FMOD for playback of PCM only[/quote:1d2yblv7]
Sorry, I wasn’t very clear, you don’t have to decode the in memory sounds. The in memory sounds can be encoded in mp3 or anything other supported format, as long as the size is known.

-Pete

  • You must to post comments
0
0

[quote="PeterStirling":3emo1vyg]
The in memory sounds can be encoded in mp3 or anything other supported format, as long as the size is known.

-Pete[/quote:3emo1vyg]

Hi
"anything other supported format" does that include OGG and FLAC? due to the docs it’s only MP2, MP3, IMAADPCM or XMA ?

cheers,

  • You must to post comments
Showing 7 results
Your Answer

Please first to submit.