Search code examples
androidsoundpoolsound-synthesis

Doppler/synthesis effect in Android?


In Android, the SoundPool.play API allows for playing sound effects. I'm wondering how I should alter the parameters to achieve a doppler effect:

public final int  play (
    int soundID,
    float leftVolume,
    float rightVolume,
    int priority,
    int loop,
    float rate) 

Solution

  • Doppler frequency shift formula is: f = f0 * (c + vr) / (c + vs), where vs/vr -- speed of sender and receiver, and c is the speed of the sound (300m/s for air), you may use (c+vr)/(c+vs) as your rate parameter in play().

    Here's additional info on Doppler shift, if you need it.