mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 17:01:18 +02:00
Merge pull request #843 from PhilipRosedale/master
Better collision and click voxel sounds
This commit is contained in:
commit
60119ddd52
2 changed files with 17 additions and 5 deletions
|
@ -952,7 +952,16 @@ void Application::mousePressEvent(QMouseEvent* event) {
|
||||||
_hoverVoxelOriginalColor[1] = _hoverVoxel.green;
|
_hoverVoxelOriginalColor[1] = _hoverVoxel.green;
|
||||||
_hoverVoxelOriginalColor[2] = _hoverVoxel.blue;
|
_hoverVoxelOriginalColor[2] = _hoverVoxel.blue;
|
||||||
_hoverVoxelOriginalColor[3] = 1;
|
_hoverVoxelOriginalColor[3] = 1;
|
||||||
_audio.startCollisionSound(1.0, HOVER_VOXEL_FREQUENCY * _hoverVoxel.s * TREE_SCALE, 0.0, HOVER_VOXEL_DECAY);
|
const float RED_CLICK_FREQUENCY = 1000.f;
|
||||||
|
const float GREEN_CLICK_FREQUENCY = 1250.f;
|
||||||
|
const float BLUE_CLICK_FREQUENCY = 1330.f;
|
||||||
|
const float MIDDLE_A_FREQUENCY = 440.f;
|
||||||
|
float frequency = MIDDLE_A_FREQUENCY +
|
||||||
|
(_hoverVoxel.red / 255.f * RED_CLICK_FREQUENCY +
|
||||||
|
_hoverVoxel.green / 255.f * GREEN_CLICK_FREQUENCY +
|
||||||
|
_hoverVoxel.blue / 255.f * BLUE_CLICK_FREQUENCY) / 3.f;
|
||||||
|
|
||||||
|
_audio.startCollisionSound(1.0, frequency, 0.0, HOVER_VOXEL_DECAY);
|
||||||
_isHoverVoxelSounding = true;
|
_isHoverVoxelSounding = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -704,7 +704,7 @@ void Audio::addProceduralSounds(int16_t* inputBuffer,
|
||||||
float speed = glm::length(_lastVelocity);
|
float speed = glm::length(_lastVelocity);
|
||||||
float volume = VOLUME_BASELINE * (1.f - speed / MAX_AUDIBLE_VELOCITY);
|
float volume = VOLUME_BASELINE * (1.f - speed / MAX_AUDIBLE_VELOCITY);
|
||||||
|
|
||||||
int sample;
|
float sample;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Travelling noise
|
// Travelling noise
|
||||||
|
@ -724,13 +724,16 @@ void Audio::addProceduralSounds(int16_t* inputBuffer,
|
||||||
if (_collisionSoundMagnitude > COLLISION_SOUND_CUTOFF_LEVEL) {
|
if (_collisionSoundMagnitude > COLLISION_SOUND_CUTOFF_LEVEL) {
|
||||||
for (int i = 0; i < numSamples; i++) {
|
for (int i = 0; i < numSamples; i++) {
|
||||||
t = (float) _proceduralEffectSample + (float) i;
|
t = (float) _proceduralEffectSample + (float) i;
|
||||||
|
|
||||||
sample = sinf(t * _collisionSoundFrequency) +
|
sample = sinf(t * _collisionSoundFrequency) +
|
||||||
sinf(t * _collisionSoundFrequency / DOWN_TWO_OCTAVES) +
|
sinf(t * _collisionSoundFrequency / DOWN_TWO_OCTAVES) +
|
||||||
sinf(t * _collisionSoundFrequency / DOWN_FOUR_OCTAVES * UP_MAJOR_FIFTH);
|
sinf(t * _collisionSoundFrequency / DOWN_FOUR_OCTAVES * UP_MAJOR_FIFTH);
|
||||||
sample *= _collisionSoundMagnitude * COLLISION_SOUND_MAX_VOLUME;
|
sample *= _collisionSoundMagnitude * COLLISION_SOUND_MAX_VOLUME;
|
||||||
inputBuffer[i] += sample;
|
|
||||||
outputLeft[i] += sample;
|
|
||||||
outputRight[i] += sample;
|
inputBuffer[i] += (int) sample;
|
||||||
|
outputLeft[i] += (int) sample;
|
||||||
|
outputRight[i] += (int) sample;
|
||||||
_collisionSoundMagnitude *= _collisionSoundDuration;
|
_collisionSoundMagnitude *= _collisionSoundDuration;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue