views:

898

answers:

7

I'm looking for the most realistic way of playing sound of a rolling ball. Currently I'm using a Wav sample that I play over and over as long as the ball is moving - which just doesn't feel right.

I've been thinking about completely synthesizing the sound, which I know very little about (almost nothing), I'd be grateful for any tutorials/research materials/samples concerning synthesis of sound of a ball made of particular material rolling on surface made of another material. Also if this idea is completely wrong, please suggest another way of doing this.

Thanks!

+5  A: 

Have you tried playing the sound forward, then playing it backward, and looping that? I use this trick graphically to creating repeating patterns. I don't know much about sound but it might work?

jeef3
Thats actually a pretty good idea - essentially 1 dimensional tiling.
Charlie Salts
don't backwards sounds sound qualitatively different from the the normal sound?
Jimmy
if it's a short clip, it won't be noticeable. this is actually a great way to make a loop sound seamless without crossfading.
leolobato
Whether or not this works really depends on the sound. For some sounds, it's really noticeable even with a relatively short source clip. The closer your sound approximates true 'noise,' the better this works.
Quintus
Appending a backwards version of a sound to itself doesn't eliminate the need to crossfade. There can still be discontinuities in different frequency ranges that can cause a pop.
Nosredna
+5  A: 

One approach might be to analyze the sound of a rolling ball, and decompose it into its component waveforms. Then you'd be able to generate your own wav file with synthesized waves.
You should be able to do this using an FFT on a sample of the sound.

One drawback is that the sound will likely sound synthesized - you'll have to add noise and such to make it sound more realistic. Getting it to sound real enough may be the hardest part.

Charlie Salts
I'll look into that, is this method suitable for realtime usage under quite resource constrained environment (smart phone)?
arul
Honestly - I don't know. If you know that the ball will make a certain sound under known conditions, then the sound parameters are known. Therefore, you should be able to 'cache' enough of the synthesized sound so that you can create a loopable wav file. I just remember the FFT from my university days, and seemed like a good approach.
Charlie Salts
Going from FFT to synthesize a sound is a reasonable thing to do, but probably not in this case. What's interesting about a rolling ball is the moment-to-moment changes in the spectrum. You could use the whole processor up resynthesizing the sound. Especially if you you use a morphing additive synthesis.
Nosredna
+3  A: 

I don't think you need the trouble to synthesize that. It would be way too hard to even sound convincing.

Depending on how your scene is, you could loop the sound foward/backwards and simulate a doppler effect applying a low pass filter and/or changing it's pitch.

By the way, freesoung.org is a great place for free samples. They are not professionally recorded but are a good starting point for manipulation. On the other hand, sound ideas has some great sample cds (they're actually industry standard) if you can find them on the cheap. You just have to search for which one has rolling ball sounds.

leolobato
+7  A: 

I would guess that you'll get the biggest bang for your buck by doing a dynamic frequency adjustment on the sound that makes the playback frequency proportional to the velocity of the ball. I don't know what type of sound library you use, but most will support some variant of this.

For example, in FMOD you could use the Channel::setFrequency method. Ideally, you would compute your desired playback frequency based on your WAV's original sample frequency (Fo), the ball's current velocity (Vc), and the ball's 'ideal' velocity at which the default WAV sounds right (Vi). Something generally like:

F = Fo * ( Vc / Vi )

This will tend to break down as the ball gets farther away from the 'ideal' velocity. You might want to have several different WAVs that are appropriate for different speed ranges that you switch to at certain threshold velocities. Within each WAV's bracket, you'd do the same kind of frequency adjustment.

Another note: this is probably not something that is worth doing every frame. I'd guess that doing this more than 20 times per second would be a waste of time.

ADDENDUM: Playback frequency scaling like this can also be used for simulating the Doppler effect as well. Once you have your adjusted playback frequency, you'd perform another scale of the Frequency based on the velocity of the ball relative to the 'listener' (the camera).

Quintus
An interesting idea. Probably better done by changing the cutoff of a lowpass filter than by changing the playback speed of the sound.
Nosredna
That wouldn't really accomplish the same thing. The sound of something rolling at different speeds is more than just a frequency spread - it has to do with the overall speed of the sound. Imagine running the sound of a car's engine through a low-pass filter. No matter where you set the cutoff, the 'speed' (RPMs) of the engine won't sound any different. Additionally - playback frequency adjustments are easier/cheaper to do in real-time.
Quintus
This is closest to my current +/- working implementation, so I'm accepting this answer. Thanks everyone for your ideas!
arul
+2  A: 

My question is 'why?' - do you see some benefit in this, or is it just for fun? Your question implies that you aren't happy with the wav you are using but I strongly believe that synthesising your own is going to sound far inferior.

If your wav sample doesn't sound right, I'd suggest try to find another sample. Synthesising a sound is not easy and is never going to sound as realistic as your sample.

Real time synthesis may require more resources for processing and computation. You may very well end up prerendering your synthesised sound into a wav file and performing a playback.

If you want to simulate the sound of different materials then you can use some DSP, or even simple tricks like slowing or speeding the wav playback. The simplest way is the prerender these in another application and store one copy of the file for each use.

Kirk Broadhurst
There are many kinds of synthesis methods that would take a tiny fraction of the processor. Sample playback will always be repetitive and obvious, so I think it's a good idea to think about synthesis possibilities.
Nosredna
+2  A: 

I really like the approach described in this SIGGRAPH paper:

http://www.cs.ubc.ca/~kvdoel/publications/foleyautomatic.pdf

It describes synthesizing the sound of a rock rolling in a wok (no, really :). The idea is to use modal synthesis (i.e. convolved impulse responses), and the results can be very convincing.

Here's a link to the video demo that goes with the paper:

http://www.cs.ubc.ca/~kvdoel/publications/foleyautomatic.mpeg

And here's a link to the JASS library (written by one of the authors), which was used to create the sound for the video:

http://www.cs.ubc.ca/~kvdoel/jass/jass.html

I'm not sure if you could make it run on a smart phone, but with an efficient enough convolution routine/approximation you might be able to do something interesting...

datageist
Impressive reading, thanks.
arul
Glad you liked it. Good luck with the synthesis.
datageist
A: 

Arul, Have been able to create this rolling ball effect? I am some what lost when it comes to implementing the accepted solution above for iphone. Would you be able to give me a code sample on how you modify frequency based on velocity? I am using chipmunk and Open AL on a accelerometer based labyrinth game. Thanks in advance.

Jagan