mirror of
https://github.com/overte-org/overte.git
synced 2025-08-17 02:25:13 +02:00
Added new cooler movement sound that is velocity sensitive.
This commit is contained in:
parent
ddc97a6ac9
commit
4bb8f49132
1 changed files with 4 additions and 3 deletions
|
@ -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) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue