FMOD simple problem

Started by
1 comment, last by Emre 22 years, 1 month ago
Hey! I''m having one of those "I know my mistake is so stupid I will hit myself when I figure it out but for now I don''t know what it is for the life of me" problems. The source code I''m using is below, the problem I isolated with the fopen call due to the fact that the error check at FSOUND_Stream_OpenFile returns with "File not found." I have song1.mp3 plastered everywhere in the directory, in the /debug, I just can''t figure out what''s going wrong. Is there a problem with any other part of the code that is perhaps hindering the loading of the mp3? //********************************************** void SoundMusicInit() { FSOUND_STREAM *stream; FSOUND_SetOutput(FSOUND_OUTPUT_DSOUND); FSOUND_Init(44100, 32, 0); FILE * fp; int length; char * data; fp = fopen("song1.mp3", "rb"); fseek(fp, 0, SEEK_END); length = ftell(fp); fseek(fp, 0, SEEK_SET); data = (char *)malloc(length); fread(data, length, 1, fp); fclose(fp); stream = FSOUND_Stream_OpenFile(data,FSOUND_NORMAL|FSOUND_LOOP_NORMAL|FSOUND_MPEGACCURATE, 0); if (!stream) { MessageBox(g_hWnd, FMOD_ErrorString(FSOUND_GetError()) , "FSOUND_Stream_OpenFile error", MB_OK); FSOUND_Close(); } FSOUND_Stream_SetEndCallback(stream, endcallback, 0); FSOUND_Stream_SetSynchCallback(stream, endcallback, 0); if ((channel = FSOUND_Stream_PlayEx(FSOUND_FREE, stream, NULL, TRUE)) == -1) { MessageBox(g_hWnd, FMOD_ErrorString(FSOUND_GetError()) , "FSOUND_Stream_PlayEX error", MB_OK); FSOUND_Close(); } FSOUND_SetPaused(channel, FALSE); system("pause"); FSOUND_Stream_Close(stream); FSOUND_Close(); } //********************************** Thanks! ~Emre
Advertisement
I''ve never worked with FMOD, but you are calling FSOUND_Stream_OpenFile with the first parameter being "data", when data is a char* to a buffer of the info in song1.mp3. I think you may have over-complicated things for yourself, maybe you should just be calling FSOUND_Stream_OpenFile with the first parameter being "song1.mp3" instead of data. I''m not sure about this since I haven''t worked with FMOD, but since it''s saying "file not found", it''ll want the filename somewhere.
hi,

You read the sound file to the "data" buffer, and the you pass this to the FSOUND_Stream_OpenFile(), you must pass then as the last param of these function the FSOUND_LOADMEMORY flag, that FMOD know how to load the file.

Hope that helps.

Mfg Impz0r
Stay Evil & Ugly!

This topic is closed to new replies.

Advertisement