Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I would like to add sound effects to a basic 2D game. For example, a stone sphere is rolling on wood surface. Let's say I have a 2 second audio recording of this. How could I use the sample to add sound for an arbitrary duration ?

So far I have two solutions in mind:

a/ record the sound for an amount of time that is greater than the maximum expected duration, and play only a part of it;

b/ extract a small portion of the sample and play it in a loop for the duration of the move; however I'm not sure if it makes sense with an audio wave.

share|improve this question
    
Use an audio library? Seriously though, I think this question is better suited to avp.stackexchange.com simply because it sounds like you're after the sound design aspect of this rather than the sound programming element. –  Ray Dey Jun 5 '12 at 23:52
1  
@RayDey The asker is wondering how they're meant to design sound for games, so it's a game development question and completely appropriate here. –  Jonathan Hobbs Jun 6 '12 at 13:49
    
Yeah after re-reading this today I can see the interactive element to it. That being said, I'm still a bit iffy about it. If you take out the first sentence, what difference is there if you wanted to have an arbitrarily long sample in a song you were producing? –  Ray Dey Jun 6 '12 at 21:31

3 Answers 3

The typical method is to have a sample with loop points in the middle. It loops for as long as necessary then it can cross-fade into the end of the sample when it is supposed to stop. To do this, you need to know the loop points within your sample, and know where the end section of the sample is, and you need a sound library capable of doing these operations (which depends on the language and platform you're using).

share|improve this answer
2  
+1 This is how music is often handled too. I've made a diagram to describe this a little further. –  Jonathan Hobbs Jun 6 '12 at 14:49

Answer to your question depends on the audio API you're using in your project.

If an API allows you to use wave samples of an arbitrary length and play them with specified volume and pitch, you can make a sliding sound volume and pitch depend on the speed of a sliding object. The faster object slides, the louder the sample plays and it's more pitched up.

For a length of a sample - I would use a looping sample of longer duration, let's say 10s, with extra texture in it (e.g. a mixed grain of sand in a friction sound for a sliding cube, or some louder bumps in sound of a rolling sphere on a wooden surface). It would improve overall quality of this trick. Short samples tend to be perceived as repeatable.

share|improve this answer
    
I'm going to use CoreAudio (OS X audio API) –  Antoine Lecaille Jun 6 '12 at 13:34
    
As I quickly peeked into CoreAudio docs, a part of a CoreAudio API is a MacOS X's implementation of OpenAL so it's definitely possible to play pitched sample data. –  Helbreder Jun 6 '12 at 14:02

Your ideas are good. I would attempt to go with something of a mixture between option A and B. Make a sound that's long enough for most scenarios, but also loopable. This way you can get a sound that doesn't sound like it's on a tight loop, but which won't get "cut off" if you were to have a situation where the sound might play too long. I haven't started the sounds part of my game yet, so I don't know a lot about what tools are available. There are a few that I have bookmarked for future use, which might be useful.

  1. bfxr This one and number two are for generating sounds effects. I have no idea what 75% of the sliders do, but I just slide them around until I get something like what I want.
  2. sfxr
  3. Dynamically composing music and sound effects - Don't follow that one too closely ;)
  4. Creating and playing synthetic sound - Just something to get started with, then create algorithms for the sounds I want.
  5. Audacity I use this now for editing the voice overs on my videos, great program. Unfortunately it doesn't help the feeling that I sound weird to myself.
share|improve this answer
    
Point 3 reminds me of iMuse used in Monkey Island 2 for the musical transitions between scenes. This was incredible the first time I heard it. –  Antoine Lecaille Jun 6 '12 at 11:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.