Added new cooler movement sound that is velocity sensitive.

This commit is contained in:
Philip Rosedale 2013-05-08 20:02:29 -07:00
parent ddc97a6ac9
commit 4bb8f49132

View file

@ -30,13 +30,14 @@ AudioData::~AudioData() {
// Take a pointer to the acquired microphone input samples and add procedural sounds
void AudioData::addProceduralSounds(int16_t* inputBuffer, int numSamples) {
const float MAX_AUDIBLE_VELOCITY = 3.0;
const float MAX_AUDIBLE_VELOCITY = 6.0;
const float MIN_AUDIBLE_VELOCITY = 0.1;
const float VOLUME = 200;
float speed = glm::length(_lastVelocity);
float volume = 400 * (1.f - speed/MAX_AUDIBLE_VELOCITY);
// Add a noise-modulated sinewave with volume that tapers off with speed increasing
if ((speed > MIN_AUDIBLE_VELOCITY) && (speed < MAX_AUDIBLE_VELOCITY)) {
for (int i = 0; i < numSamples; i++) {
inputBuffer[i] += (int16_t) ((randFloat() - 0.5f) * VOLUME * speed) ;
inputBuffer[i] += (int16_t) ((cosf((float)i / 8.f * speed) * randFloat()) * volume * speed) ;
}
}