Sign in to follow this  
lordimmortal2

Game Sound

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 this post


Link to post
Share on other sites
I find SDL pretty easy then, try here:
[url="http://lazyfoo.net/SDL_tutorials/lesson01/index.php"]For setting up SDL with your program.[/url]
[url="http://lazyfoo.net/SDL_tutorials/lesson11/index.php"]Using sounds.[/url]

I hear SFML is easy too.

Share this post


Link to post
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 this post


Link to post
Share on other sites
[quote]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 this post


Link to post
Share on other sites
[quote name='lordimmortal2' timestamp='1311089824' post='4837443']
[quote]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?

[/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 this post


Link to post
Share on other sites
[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.[/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:

[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();
}[/code]

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:
[img]http://i52.tinypic.com/whe3d0.jpg[/img]

As always, any help and replies are greatly appreciated.

Share this post


Link to post
Share on other sites
Post this on the sfml audio sub-forum. The author is very quick to help out and answer questions.
[quote name='lordimmortal2' timestamp='1311732798' post='4840916']
[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.[/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:

[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();
}[/code]

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:
[img]http://i52.tinypic.com/whe3d0.jpg[/img]

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this