• 12
• 12
• 9
• 10
• 13

# Game Sound

This topic is 2429 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have been attempting to learn some way to implement sound and music in a game but I seem to not be getting anywhere.

So, what is the most recommended way to play sound and music inside a game? And if possible, are there any tutorials on it? Preferably for a beginner (it's hard for me to read complicated code and extract what it does).

##### Share on other sites
What programming language are you using, and on what platform?

##### Share on other sites
Gah, always forget that >.<. C++ and I'm on Windows XP.

##### Share on other sites
I find SDL pretty easy then, try here:
For setting up SDL with your program.
Using sounds.

I hear SFML is easy too.

##### Share on other sites
Check into libraries like OpenAL or FMOD.

##### Share on other sites
I've use SDL, FMOD, and SFML for audio. I would skip SDL all together. FMOD was easy to use, but, I found SFML was the best. Add to the fact SFML has great support for Video and Input, and it sits on top of OpenAL, I'd use SFML all the way.

In my most recent game, I used SFML, and I have spatial sound work, and it wasn't too difficult.

##### Share on other sites
I've use SDL, FMOD, and SFML for audio. I would skip SDL all together. FMOD was easy to use, but, I found SFML was the best. Add to the fact SFML has great support for Video and Input, and it sits on top of OpenAL, I'd use SFML all the way.

In my most recent game, I used SFML, and I have spatial sound work, and it wasn't too difficult.[/quote]

So would you recommend SFML over DirectX (which is what I'm using to handle graphics and input but I am always open to other methods)? And why would you not recommend SDL? Hard to use?

##### Share on other sites

I've use SDL, FMOD, and SFML for audio. I would skip SDL all together. FMOD was easy to use, but, I found SFML was the best. Add to the fact SFML has great support for Video and Input, and it sits on top of OpenAL, I'd use SFML all the way.

In my most recent game, I used SFML, and I have spatial sound work, and it wasn't too difficult.

So would you recommend SFML over DirectX (which is what I'm using to handle graphics and input but I am always open to other methods)? And why would you not recommend SDL? Hard to use?

[/quote]

Yes, I would suggest SFML over SDL and DX. SDL is easy to use, but it's doesn't have near the performance SFML does (SFML runs on OpenGL, SDL does software rendering), nor does it have the features SFML provides (just have a look at the SFML 2.0 release). Use SFML over DX for ease of use mainly, as I think SFML is much easier to use; it's also portable. SFML uses a C++ interface as well, which can make things easier too.

##### Share on other sites
Yes, I would suggest SFML over SDL and DX. SDL is easy to use, but it's doesn't have near the performance SFML does (SFML runs on OpenGL, SDL does software rendering), nor does it have the features SFML provides (just have a look at the SFML 2.0 release). Use SFML over DX for ease of use mainly, as I think SFML is much easier to use; it's also portable. SFML uses a C++ interface as well, which can make things easier too.[/quote]

I can see what you're saying about why you recommend SFML a lot. It does seem very user-friendly and simple to use. It suits my purposes quite well (wish I had known about it before I started using DX for my graphics, but meh).

I have a problem with it right now though. It's probably just my own ignorance but here it is: while trying to get a test for making game sounds working (just to get a feel of it), the game crashes when trying to reference 0x00000000. It seems to be trying to access some 64-bit code which is strange since there aren't any different library sets from SFML beyond different OSes, or so I can tell. I am on Windows XP 32-bit. Here is the code:

 void LoadSound() { sf::SoundBuffer Buffer; sf::Sound Sound; if (!Buffer.LoadFromFile("Test.wav")) { // Error return; } Sound.SetBuffer(Buffer); Sound.SetLoop(true); Sound.SetVolume(100); Sound.Play(); }

I used a piece of music on my computer to test, it crashed that way, so I thought it might be long/big of a file (which was supported by the tutorial of music on SFML). I cut it down to about half a second and that didn't work, so I tried using a sound effect that came with the samples of SFML. That didn't work either.

The error:

As always, any help and replies are greatly appreciated.

##### Share on other sites
Post this on the sfml audio sub-forum. The author is very quick to help out and answer questions.

Yes, I would suggest SFML over SDL and DX. SDL is easy to use, but it's doesn't have near the performance SFML does (SFML runs on OpenGL, SDL does software rendering), nor does it have the features SFML provides (just have a look at the SFML 2.0 release). Use SFML over DX for ease of use mainly, as I think SFML is much easier to use; it's also portable. SFML uses a C++ interface as well, which can make things easier too.

I can see what you're saying about why you recommend SFML a lot. It does seem very user-friendly and simple to use. It suits my purposes quite well (wish I had known about it before I started using DX for my graphics, but meh).

I have a problem with it right now though. It's probably just my own ignorance but here it is: while trying to get a test for making game sounds working (just to get a feel of it), the game crashes when trying to reference 0x00000000. It seems to be trying to access some 64-bit code which is strange since there aren't any different library sets from SFML beyond different OSes, or so I can tell. I am on Windows XP 32-bit. Here is the code:

 void LoadSound() { sf::SoundBuffer Buffer; sf::Sound Sound; if (!Buffer.LoadFromFile("Test.wav")) { // Error return; } Sound.SetBuffer(Buffer); Sound.SetLoop(true); Sound.SetVolume(100); Sound.Play(); }

I used a piece of music on my computer to test, it crashed that way, so I thought it might be long/big of a file (which was supported by the tutorial of music on SFML). I cut it down to about half a second and that didn't work, so I tried using a sound effect that came with the samples of SFML. That didn't work either.

The error:

As always, any help and replies are greatly appreciated.
[/quote]