0
0

hi,I’m a high school student and from chinese….

my english is poor……

I know the fmod from the url:

http://www.azure.com.cn/article.asp?id=77

my compiler is ms2003.net

I am a new learner ,but i can not play a mp3 files in my code………

the code As follows
[code:19as84hw]

include <windows.h>

include <iostream>

include "Fmod.h"

include <conio.h>

using namespace std;

pragma comment(lib,".\FmodVC.lib")

void main()
{
char filename[255];
cout<<"please input the mod files complete paths....:";
cin>>filename;
cout<<"press the Esc to end..."<<endl;
cout<<"begin play......"<<endl;

if (!FSOUND_Init(44100, 32, 0))
{
    return;
}


FMUSIC_MODULE* mod;
mod = FMUSIC_LoadSong(filename);
FMUSIC_PlaySong(mod);

//start the spectrum analysis
FSOUND_DSP_SetActive(FSOUND_DSP_GetFFTUnit(), TRUE); //ok but this time set it to TRUE...mabey it will work...


while(GetAsyncKeyState(27)==0)
{

}

FSOUND_DSP_SetActive(FSOUND_DSP_GetFFTUnit(), FALSE);
FMUSIC_StopSong(mod);
FMUSIC_FreeSong(mod);
mod = NULL;

}
[/code:19as84hw]

tankyou alls…

  • You must to post comments
0
0

You forget to init and close FMOD using FSOUND_Init and FSOUND_Close.

  • You must to post comments
0
0

Actually, it looks like you’re initializing FMOD okay, but you’re trying to use the FMUSIC functions to play MP3s. You need to look at the FSOUND functions. The FMUSIC functions play sequenced files, such as MIDIs, MODs, XMs, etc. FSOUND functions play sampled files, such as WAVs, MP3s, Oggs, etc.

Oh, but KarLKoX is right that it doesn’t look like you’re shutting FMOD down properly with FSOUND_Close().

Good luck!

  • Guy
  • You must to post comments
0
0

thankyou KarLKoX and Adiss….
^_^
my new code…
[code:1urs695i]

include <windows.h>

include <iostream>

include "Fmod.h"

include <conio.h>

using namespace std;

pragma comment (lib,".\FmodVC.lib")

void main()
{
char filename[255];
cout<<"please input the mp3 files complete paths:";
cin>>filename;
cout<<"press the Esc to close"<<endl;
cout<<"begin play......"<<endl;

if (!FSOUND_Init(44100, 32, 0))
{
    return;
}


FSOUND_SAMPLE* handle;
handle = FSOUND_Sample_Load (0,filename,0, 0, 0);   FSOUND_PlaySound (0,handle);

while(GetAsyncKeyState(27)==0)
{

}

FSOUND_Sample_Free (handle);
            FSOUND_Close();

}
[/code:1urs695i]

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.