Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Emre

FMOD simple problem

This topic is 6086 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!