9

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!

arul
  • 13,742
  • 1
  • 53
  • 76
  • 1
    It may not feel right because the amplitude at the end of the wav doesn't match the amplitude at the beginning. You might try ensuring that first (using fade in to start the sound) before delving into more complex realms – Vinko Vrsalovic Aug 24 '09 at 23:03
  • The sound is short continuous sample, it sounds "ok", but I can't control the nature of the sound with regard to the balls velocity. It's hard to describe :| – arul Aug 24 '09 at 23:07
  • 11
    Really have to disagree with the SuperUser vote. I mean, why? Arul is not looking for an application to play a sound, he's looking for a method to *generate* a realistic sound. – dmckee --- ex-moderator kitten Aug 24 '09 at 23:12
  • 1
    the faster the ball, the more frames you could skip, so it would sound faster without changing it's pitch. – leolobato Aug 24 '09 at 23:15
  • 2
    There really should have been a confirmation before vote-close reading: "Did you bother reading the question that you're about to close?". – arul Aug 24 '09 at 23:50
  • id recomend adjusting the pitch on a sine wave, should give you the sound you are looking for.... may take some playing around with how you generate the angle from the ball, and sorry i cant help with what software or apis you will need to do this – Stowelly Aug 26 '09 at 09:45

6 Answers6

8

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
  • 480
  • 3
  • 10
  • An interesting idea. Probably better done by changing the cutoff of a lowpass filter than by changing the playback speed of the sound. – Nosredna Aug 25 '09 at 03:04
  • 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 Aug 25 '09 at 03:43
  • This is closest to my current +/- working implementation, so I'm accepting this answer. Thanks everyone for your ideas! – arul Aug 27 '09 at 22:43
6

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
  • 1,959
  • 2
  • 15
  • 22
  • Thats actually a pretty good idea - essentially 1 dimensional tiling. – Charlie Salts Aug 24 '09 at 23:06
  • 3
    don't backwards sounds sound qualitatively different from the the normal sound? – Jimmy Aug 24 '09 at 23:19
  • 2
    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 Aug 24 '09 at 23:24
  • 2
    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 Aug 25 '09 at 02:47
  • 2
    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 Aug 25 '09 at 03:00
  • Any time you get a phase discontinuity (large jump from one amplitude to another) in a sound waveform it will result in a "pop". The play forward/backward works well b/c you keep the same relative waveform characteristics (freq., envelope-amplitude, etc) but you might still get a "pop" depending on where you truncate the waveform. If you use an audio editor (like Audacity) and make sure you end the waveform sample at a peak or trough, this technique should work well. This is why noise seems to work well with this trick, because noise is already comprised of a whole bunch of discontinuities. – Joel B Dec 10 '10 at 19:33
5

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
  • 12,189
  • 7
  • 43
  • 75
  • I'll look into that, is this method suitable for realtime usage under quite resource constrained environment (smart phone)? – arul Aug 24 '09 at 23:11
  • 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 Aug 24 '09 at 23:15
  • 2
    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 Aug 25 '09 at 03:03
3

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
  • 2,279
  • 3
  • 32
  • 50
3

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
  • 990
  • 6
  • 16
2

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.

hhafez
  • 36,343
  • 33
  • 109
  • 143
Kirk Broadhurst
  • 25,044
  • 13
  • 91
  • 149
  • 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 Aug 25 '09 at 03:06