Advertisement Jump to content


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


Need help streaming wav with fmod

This topic is 6266 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

Hello, I am trying to stream a 5 megabyte wave file using fmod. This should be an easy task, but I am unfortunately an idiot. I tried to do this with DirectSound but it was too difficult. I was able to play sounds with DirectSound, just not stream sounds with it. That is why I am using fmod. Here is the code I am using to load and play the wave in a console window. The program compiles fine and runs, but I hear nothing. It isn''t terribly long. #include #include #include #include #include #include #include int main(){ FSOUND_STREAM *stream; FSOUND_SetOutput(FSOUND_OUTPUT_DSOUND); FSOUND_Init(44100, 32, 0); FILE * fp; int length; char * data; fp = fopen("file.wav", "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_LOADMEMORY, length); FSOUND_Stream_PlayEx(FSOUND_FREE, stream, NULL, TRUE); system("pause"); FSOUND_Stream_Close(stream); FSOUND_Close(); return 0; } Any help is greatly appreciated. Thank you.

Share this post

Link to post
Share on other sites
Well -- I never bothered with streaming; I loaded the sample directly... it may not help, but you can fall back on this is needed:

#include "fmod.h"


//Player -- "file" is a string:

FSOUND_PlaySound(0, FSOUND_Sample_Get(0));



Obviously you mess around with this.... all you need is to include the library as well.

The zeros (in the player section) are the channels and sample indexes. In my game, is has eight channels and cycles them -- the first call uses sample 0, the next sample 1 etc....


Edited by - Cirian on November 23, 2001 6:49:47 AM

Share this post

Link to post
Share on other sites
Yes - check your return values!

- check that FSOUND_Stream_OpenFile() doesn''t return NULL
- check that FSOUND_Stream_PlayEx() doesn''t return -1

For that matter, you don''t even check that fopen() succeeds, either.

Return values are there to help you... if you add code to check them, and they''re all working, ask again. If they''re not all working, that should give you a clue as to what is going wrong.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!