Quest
Quest

Reputation: 2843

FMOD API - Can't load sound from memory

int main(int arg, char *args[])
{
FMOD::System *System;
FMOD::Sound *Sound;
FMOD::Channel *Channel = 0;
FMOD_CREATESOUNDEXINFO exinfo;
FMOD_RESULT result;
void *Buffer = 0;
int Key;
ZIPENTRY ze;
HZIP hz = OpenZip("C:\\Users\\Lukas\\Desktop\\Music.pak", "");
FindZipItem(hz, "Recording 1.mp3", true, NULL, &ze);
Buffer = malloc(ze.unc_size);
UnzipItem(hz, ze.index, Buffer, ze.unc_size);
CloseZip(hz);

ZeroMemory(&exinfo, sizeof(FMOD_CREATESOUNDEXINFO));
exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
exinfo.length = ze.unc_size;
result = FMOD::System_Create(&System);
result = System->init(32, FMOD_INIT_NORMAL, 0);
result = System->createSound((const char*)Buffer, FMOD_HARDWARE | FMOD_OPENMEMORY, &exinfo, &Sound);
result = System->playSound(FMOD_CHANNEL_FREE, Sound, false, &Channel);
while(TRUE)
{
    if(_kbhit())
    {
        Key = _getch();
        if(Key == 27)break;
    }
}
Sound->release();
System->close();
System->release();
return 0;
}

Sound is loaded into memory correctly. but i have problem with System->createSound() function. It throws FMOD_INVALID_PARRAM but everything should be okay. (compared with FMOD examples) Thanks for answers.

Upvotes: 1

Views: 1151

Answers (1)

Quest
Quest

Reputation: 2843

Everything is okay i just forgot to copy the DLL file^^

Upvotes: 2

Related Questions