0
0

Hi, I saw on Gamedev.net that this new version was released, so I figured I’d try something new, and work with a sound library. I just read the ‘basics’ section of the documentation and tried to do what it said – I’m trying to play an MP3. I’ll post my code here, it’s not very long. If someone could tell me why I can’t hear anything, and why my FSOUND_Stream_Play is failing, I’d greatly appreciate it.

The code:
[code:2af17v1h]

include <iostream>

include <string>

include <fmod.h>

int main()
{
FSOUND_Init(44100,32,0);

FSOUND_STREAM* SoundStream = 0;

SoundStream=FSOUND_Stream_OpenFile(&quot;Aerosmith - Dream On&quot;,FSOUND_MPEGACCURATE | FSOUND_HW3D,0);

int channel=FSOUND_Stream_Play(FSOUND_FREE,SoundStream);

std::cout &lt;&lt; channel &lt;&lt; &quot;\n&quot; &lt;&lt; &quot;Press a key quit. \n&quot;;

char foo;

std::cin&gt;&gt;foo;

return 1;

}[/code:2af17v1h]

Yes, I’ve linked the proper library, set all the directories up properly in MSVC++ 6.0, and I’ve copied the .dll and the mp3 to the executable directory. This is the output:

-1
Press a key to quit.

Can anyone help, or at least point me to an example without all the driver and compiler compatibility stuff that’s included in the samples?[/code]

  • You must to post comments
0
0

Have you tried changing the first parameter to “Aerosmith – Dream On.mp3”? FMOD doesn’t automatically add file extensions for you if you forget them…

The name of that song is “Sing With Me,” by the way (as opposed to “Dream On”)… sorry, just an offtopic correction; you’ll get used to my perfectionism after a while (I’m [b:2jan9gzt]really[/b:2jan9gzt] bad… if I had access to your computer, I’d have renamed that file by now; that’s just how exacting I am)

  • You must to post comments
0
0

Wow….I feel dumb. I suppose that’s what I get for coding without caffeine. Let me try it…

Oh. Damn. Still doesn’t work. Same output. But thank you for your help, any other ideas?

Oh, and are you sure it isn’t ‘Dream On’? I get a lot more google results for ‘Dream On’ than ‘Sing With Me’. Yes, I’m a perfectionist too – if you turn out to be correct, it’ll be renamed.

  • You must to post comments
0
0

Have you tried calling FSOUND_GetError and seeing what the error actually is? Have you tried just using FSOUND_NORMAL for the flags parameter?

  • You must to post comments
0
0

Change :

[code:2mnfswu7]
SoundStream=FSOUND_Stream_OpenFile("Aerosmith – Dream On",FSOUND_MPEGACCURATE | FSOUND_HW3D, 0);
[/code:2mnfswu7]

with

[code:2mnfswu7]
SoundStream=FSOUND_Stream_OpenFile(“Aerosmith – Dream On.mp3”,FSOUND_MPEGACCURATE | FSOUND_HW2D, 0);
[/code:2mnfswu7]

It can be a limitation of your soundcard drivers.

  • You must to post comments
0
0

Thanks for all the replies.

FSOUND_NORMAL doesn’t work, and neither does changing it to FSOUND_HW2D.

My question is: what do I call FSOUND_GetError on? The stream? The channel (which actually, it never gets). Do I simply call FSOUND_GetError on the FSOUND_Stream_Play function call?

  • You must to post comments
0
0

You do not call FSOUND_GetError() ‘on’ anything. If something fails, then call FSOUND_GetError() next to find out why it failed.

The next thing I’d try is to put the full path to the MP3 in the call to FSOUND_Stream_OpenFile(). It may be just that it cannot find the file.

If that fails, then try this…

[code:3bmy2mt0]

include <iostream>

include <string>

include <fmod.h>

include <fmod_errors.h>

int main()
{
if (!FSOUND_Init(44100, 32, 0))
{
std::cout << FMOD_ErrorString(FSOUND_GetError());
return 1;
}

FSOUND_STREAM *stream = FSOUND_Stream_OpenFile("Aerosmith – Dream On.mp3", FSOUND_NORMAL, 0);
if (!stream)
{
std::cout << FMOD_ErrorString(FSOUND_GetError());
return 1;
}
int channel = FSOUND_Stream_Play(FSOUND_FREE, stream);

std::cout << channel << "\n" << "Press a key quit. \n";
char foo;
std::cin>>foo;

FSOUND_Stream_Stop(stream);
FSOUND_Close();

return 0;
}
[/code:3bmy2mt0]

Note the inclusion of fmod_errors.h to get access to FMOD_ErrorString(). This converts an error code returned by FSOUND_GetError() into a string description of the error.

  • You must to post comments
0
0

Cool, it works, thanks Sly. The error was ‘File not found’, so I just typed in the whole pathname. Maybe it wasn’t working the first time I tried that because I wasn’t properly using the \ escape code (for backslashes). Thanks again!

  • You must to post comments
0
0

[quote="cyphr":3gpfoqmr]Oh, and are you sure it isn’t ‘Dream On’? I get a lot more google results for ‘Dream On’ than ‘Sing With Me’. Yes, I’m a perfectionist too – if you turn out to be correct, it’ll be renamed.[/quote:3gpfoqmr]

I get this a lot, and not just with this song. What I think happens is someone names the file wrong, then it gets distributed over the internet under the wrong filename, so there ends up being a lot of results under an incorrect name. However, the name of the song [b:3gpfoqmr]is[/b:3gpfoqmr] “Sing With Me”–if not, it’d be the first song I ever heard of with a title based on the song’s bridge (99.9% of song titles, if you ever noticed, are based on the chorus)…

  • You must to post comments
Showing 8 results
Your Answer

Please first to submit.