דוגמא:
//=============================================================================================== // STREAM.EXE // Copyright (c), Firelight Technologies Pty, Ltd, 1999-2003. // // This example takes a command line parameter, a wav/mp2/mp3/ogg etc file, and uses the streamer // system to play it back. //=============================================================================================== #include <string.h> #include <stdio.h> #include <math.h> #include <windows.h> #include <conio.h> #include "../../api/inc/fmod.h" #include "../../api/inc/fmod_errors.h" // optional int done = 0; signed char F_CALLBACKAPI endcallback(FSOUND_STREAM *stream, void *buff, int len, int param) { done = 1; return TRUE; } int initStuff() { if (FSOUND_GetVersion() < FMOD_VERSION) { printf("Error : You are using the wrong DLL version! You should be using FMOD %.02f\n", FMOD_VERSION); return 0; } FSOUND_SetOutput(FSOUND_OUTPUT_WINMM); FSOUND_SetDriver(0); // Select sound card (0 = default) if (!FSOUND_Init(44100, 32, 0)) { printf("Error!\n"); printf("%s\n", FMOD_ErrorString(FSOUND_GetError())); FSOUND_Close(); return 0; } FSOUND_Stream_SetBufferSize(1000); return 1; } FSOUND_STREAM *playSong(char *filename) { int channel = -1; FSOUND_STREAM *stream; stream = FSOUND_Stream_Open(filename, FSOUND_NORMAL | FSOUND_MPEGACCURATE, 0, 0); if (!stream) { printf("Error!\n"); printf("%s\n", FMOD_ErrorString(FSOUND_GetError())); FSOUND_Close(); return NULL; } FSOUND_Stream_SetEndCallback(stream, endcallback, 0); channel = FSOUND_Stream_PlayEx(FSOUND_FREE, stream, NULL, TRUE); FSOUND_SetPaused(channel, FALSE); return stream; } void closeStuff(FSOUND_STREAM *s) { FSOUND_Stream_Close(s); FSOUND_Close(); } int main(int argc, char *argv[]) { FSOUND_STREAM *s; initStuff(); s = playSong("c:/children of bodom - 05 cowards dead end.mp3"); while((!done) && (!kbhit())) { } closeStuff(s); return 0; }