0
0

when i run the code, it doesn’t give any errors (message box wise), but i can’t hear anything. perhaps im forgetting to initialize something…any clue?

[code:3rw65xix]
FSOUND_SAMPLE *sample;

if(!FSOUND_SetOutput(FSOUND_OUTPUT_WINMM)){
    MessageBox(NULL,FMOD_ErrorString(FSOUND_GetError()),"Error 1",MB_OK);
    return false;
}

if(!FSOUND_SetDriver(0)){
    MessageBox(NULL,FMOD_ErrorString(FSOUND_GetError()),"Error 2",MB_OK);
    return false;
}

if(!FSOUND_Init(44000, 32, FSOUND_INIT_GLOBALFOCUS)){
    MessageBox(NULL,FMOD_ErrorString(FSOUND_GetError()),"Error 3",MB_OK);
    return false;
}

if((sample = FSOUND_Sample_Load(FSOUND_UNMANAGED, "c:\\Nabeel\\test.wav", FSOUND_NORMAL, 0))==NULL){
    MessageBox(NULL,FMOD_ErrorString(FSOUND_GetError()),"Error 4",MB_OK);
    return false;
}

FSOUND_Sample_SetMode(sample, FSOUND_LOOP_OFF);

//end of loopy loopy loo
if(FSOUND_PlaySound(FSOUND_FREE, sample)==-1){
    MessageBox(NULL, FMOD_ErrorString(FSOUND_GetError()), "Error 5", MB_OK);
    return false;
}

//clean up
FSOUND_Close(); [/code:3rw65xix]

also, how would i play lets say from sample 100 to sample 500, is there a way to do that? thanks

  • You must to post comments
0
0

Between FSOUND_PlaySound and FSOUND_Close, add a loop, the pb is the sound play then fmod shutdown :)
ie :

[code:fpl9s6lr]
...

//end of loopy loopy loo
if(FSOUND_PlaySound(FSOUND_FREE, sample)==-1){
MessageBox(NULL, FMOD_ErrorString(FSOUND_GetError()), "Error 5", MB_OK);
return false;
}

while ( (ch = getch()) != 27)
{
// print some funny values here

}

FSOUND_Close();
[/code:fpl9s6lr][/code]

  • You must to post comments
0
0

it is a GUI app, so how should I go about doing the loop?

i was going to do something like

while( file is playing)
lalala

but i cant find anything in the documentation on seeing whether its still playing or not

  • You must to post comments
0
0

In a gui app, you musn’t do this way, FMOD will play ’til the app exist, here is a snippet :

[code:2fn5hmgh]
BOOL CALLBACK guiproc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_INITDIALOG:
{
// here you can init FMOD
return TRUE;
}

  switch (LOWORD(wParam))
  {
         case IDC_PLAY:
         {
          if((sample = FSOUND_Sample_Load(FSOUND_UNMANAGED, "c:\\Nabeel\\test.wav", FSOUND_NORMAL, 0))==NULL){
       MessageBox(NULL,FMOD_ErrorString(FSOUND_GetError()),"Error 4",MB_OK);
       return false;
        }

        FSOUND_Sample_SetMode(sample, FSOUND_LOOP_OFF);

        //end of loopy loopy loo
       if(FSOUND_PlaySound(FSOUND_FREE, sample)==-1){
       MessageBox(NULL, FMOD_ErrorString(FSOUND_GetError()), "Error 5", MB_OK);
  return false;
      } 
     break;
    }
  }

return FALSE;

}
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow)
{
MSG msg;

DialogBox(inst,MAKEINTRESOURCE(IDD_GUI), 0,&guiproc);


while (1) {
    if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
        if (!GetMessage(&msg, NULL, 0, 0))
            break;
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    } else
        WaitMessage();
}

return 0;

}
[/code:2fn5hmgh]

  • You must to post comments
0
0

hmm, i dont get it. wlel I’m also using MFC, but im trying to see what you did. i added a Sleep(), but that is really useless, since i the sound samples itll be reading in are different sizes.

i tried adding a “sendendcalllback” and having a global boolean variable that will gets switched when its done with the stream, but that doesnt seem to be working either. any other ideas?

  • You must to post comments
0
0

My idea is that it isn’t a fmod related pb but it is the way your gui interact with fmod 😉
Keep an eye on the code or see the Fmod player source code.

  • You must to post comments
Showing 5 results
Your Answer

Please first to submit.