0
0

Good afternoon,
I’m able to call FMOD and play the mp3 perfectly well, but when I try to use the readData function, FMOD gives me FMOD_ERR_UNSUPPORTED
This way I know that the mp3 is of supported format and I don’t have any errors with my file structure
I understand that this is caused by plugin incompatibility, but the dll I’m using has the plugins included internally.

Below is my code
[code:7st2u3a1]

include "fmod.hpp"

include "fmod_errors.h"

include "math.h"

include <iostream>

pragma comment(lib, "fmodexL_vc.lib")

void ERRCHECK(FMOD_RESULT result)
{
if (result != FMOD_OK)
{
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
}
}

// Helper functions

int main()
{
// create system
FMOD::System* system;
FMOD_RESULT result = FMOD::System_Create(&system);
// load sound
system->setOutput(FMOD_OUTPUTTYPE_WINMM );
system->init(32, FMOD_INIT_NORMAL, NULL);
FMOD::Sound* sound;
result = system->createSound("MLFY.mp3", FMOD_LOOP_NORMAL, NULL,&sound);
// play sound
FMOD::Channel* channel = 0;
result = system->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
system->update();

ERRCHECK(result);
float freq = 0;
// Fetch song parameters
/* In my case it is:
freq=44100, Format=FMOD_SOUND_FORMAT_PCM16, Channels=2, Bits=16
Length=221570 ms, PCM=9771264, Bytes=39085056 */
FMOD_SOUND_FORMAT format; 
int channels, bits;
unsigned int lenMs, lenPcm, lenPcmBytes;
sound-&gt;getDefaults(&amp;freq, 0, 0, 0);
sound-&gt;getFormat(0, &amp;format, &amp;channels, &amp;bits);
sound-&gt;getLength(&amp;lenMs,       FMOD_TIMEUNIT_MS);
sound-&gt;getLength(&amp;lenPcm,      FMOD_TIMEUNIT_PCM);
sound-&gt;getLength(&amp;lenPcmBytes, FMOD_TIMEUNIT_PCMBYTES);
//StartMusic(freq, format, channels, bits, lenMs, lenPcm, lenPcmBytes);
ERRCHECK(result);
// Decode song data
//static const unsigned int BUF_SIZE = 0x10000;
 #define BUF_SIZE 4096
sound-&gt;seekData(0);
//unsigned int buf[BUF_SIZE];
void *buf;       
buf = malloc(BUF_SIZE);
bool processing = true;
do
{
    unsigned int bytesRead;
    result = sound-&gt;readData((char *)buf, BUF_SIZE, &amp;bytesRead); ///ERROR CAUSED HERE &lt;------------
    ERRCHECK(result);
    if (result == FMOD_ERR_FILE_EOF)
        processing = false;
    //ProcessMusicBuf(buf, bytesRead);
}
while (processing);

//StopMusic();
sound-&gt;release();
system-&gt;release();

// Initialization

}

[/code:7st2u3a1]

Thanks,
-D

  • You must to post comments
0
0

I verified that the code below crashes on the first run, and not after reading the data several times

The error I get from the error message is:

FMOD error! <80> A command issues we not supported by this object. Possibly a plugin without certain callbacks specified.

Please help me fix this error, I cannot find any information on what may be causing it.

Thanks,
_D

  • You must to post comments
0
0

You cannot call Sound::readData on a FMOD::Sound opened as FMOD_CREATESAMPLE (the default).
Internally the file handle is opened, the entire compressed MP3 is decoded to PCM, then the file handle is closed.
Sound::readData revolves around reading chunks of data in a piece at a time, which cannot be done with a closed file handle.

You can access the decoded PCM by using Sound::lock, or if you want to use readData for chunk decoding, load the sound as FMOD_CREATESTREAM | FMOD_OPENONLY.

  • You must to post comments
0
0

I’m sorry but I do not see FMOD_CREATESAMPLE anywhere in my code,

Where do I need to insert FMOD_CREATESTREAM | FMOD_OPENONLY?

I tried using sound->setMode(FMOD_CREATESTREAM | FMOD_OPENONLY); this still gave me FMOD_ERR_UNSUPPORTED when I tried calling ReadData

I also tried changing
result = system->createSound("MLFY.mp3", FMOD_LOOP_NORMAL, NULL,&sound); to
result = system->createSound("MLFY.mp3", FMOD_CREATESTREAM | FMOD_OPENONLY, NULL,&sound);

Still the same error. Could you please advise where I should place those statements.

Additionally, I would like to know what is the preferred way of doing this,
I understand from this article that for music fules it’s better to use readdata
http://stackoverflow.com/questions/3732 … sound-lock

Thanks,
-D

  • You must to post comments
0
0

FMOD_CREATESAMPLE is the default, i.e. it’s set if you don’t specify stream vs sample.

Your example should work:
[code:n6y07npy]result = system->createSound("MLFY.mp3", FMOD_CREATESTREAM | FMOD_OPENONLY, NULL, &sound);
result = sound->readData((char *)buf, BUF_SIZE, &bytesRead);[/code:n6y07npy]
Can you verify this is still giving an error?

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.