mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 14:29:03 +02:00
Merge pull request #1415 from birarda/injected-audio
hook throw and catch sounds to Hand ball tests
This commit is contained in:
commit
e29b366b7e
4 changed files with 26 additions and 10 deletions
|
@ -94,11 +94,10 @@ void AudioMixerClientData::pushBuffersAfterFrameSend() {
|
||||||
audioBuffer->shiftReadPosition(NETWORK_BUFFER_LENGTH_SAMPLES_PER_CHANNEL);
|
audioBuffer->shiftReadPosition(NETWORK_BUFFER_LENGTH_SAMPLES_PER_CHANNEL);
|
||||||
|
|
||||||
audioBuffer->setWillBeAddedToMix(false);
|
audioBuffer->setWillBeAddedToMix(false);
|
||||||
} else if (audioBuffer->isStarved()) {
|
} else if (audioBuffer->hasStarted() && audioBuffer->isStarved()) {
|
||||||
// this was previously the kill for injected audio from a client
|
// this is an empty audio buffer that has starved, safe to delete
|
||||||
// fix when that is added back
|
delete audioBuffer;
|
||||||
// delete audioBuffer;
|
_ringBuffers.erase(_ringBuffers.begin() + i);
|
||||||
// _ringBuffers.erase(_ringBuffers.begin() + i);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,9 @@ Hand::Hand(Avatar* owningAvatar) :
|
||||||
_collisionDuration(0),
|
_collisionDuration(0),
|
||||||
_pitchUpdate(0),
|
_pitchUpdate(0),
|
||||||
_grabDelta(0, 0, 0),
|
_grabDelta(0, 0, 0),
|
||||||
_grabDeltaVelocity(0, 0, 0)
|
_grabDeltaVelocity(0, 0, 0),
|
||||||
|
_throwInjector(QUrl("https://dl.dropboxusercontent.com/u/1864924/hifi-sounds/throw.raw")),
|
||||||
|
_catchInjector(QUrl("https://dl.dropboxusercontent.com/u/1864924/hifi-sounds/catch.raw"))
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MAX_HANDS; i++) {
|
for (int i = 0; i < MAX_HANDS; i++) {
|
||||||
_toyBallInHand[i] = false;
|
_toyBallInHand[i] = false;
|
||||||
|
@ -61,6 +63,10 @@ Hand::Hand(Avatar* owningAvatar) :
|
||||||
_whichBallColor[i] = 0;
|
_whichBallColor[i] = 0;
|
||||||
}
|
}
|
||||||
_lastControllerButtons = 0;
|
_lastControllerButtons = 0;
|
||||||
|
|
||||||
|
// the throw and catch sounds should not loopback, we'll play them locally
|
||||||
|
_throwInjector.setShouldLoopback(false);
|
||||||
|
_catchInjector.setShouldLoopback(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hand::init() {
|
void Hand::init() {
|
||||||
|
@ -119,7 +125,10 @@ void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, f
|
||||||
_ballParticleEditHandles[handID] = caughtParticle;
|
_ballParticleEditHandles[handID] = caughtParticle;
|
||||||
caughtParticle = NULL;
|
caughtParticle = NULL;
|
||||||
// Play a catch sound!
|
// Play a catch sound!
|
||||||
app->getAudio()->startDrumSound(1.0, 300, 0.5, 0.05);
|
_catchInjector.setPosition(targetPosition);
|
||||||
|
|
||||||
|
// inject the catch sound to the mixer and play it locally
|
||||||
|
_catchInjector.injectViaThread(app->getAudio());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,8 +231,11 @@ void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, f
|
||||||
delete _ballParticleEditHandles[handID];
|
delete _ballParticleEditHandles[handID];
|
||||||
_ballParticleEditHandles[handID] = NULL;
|
_ballParticleEditHandles[handID] = NULL;
|
||||||
|
|
||||||
// Play a throw sound
|
// move the throw injector to inject from the position of the ball
|
||||||
app->getAudio()->startDrumSound(1.0, 3000, 0.5, 0.02);
|
_throwInjector.setPosition(ballPosition);
|
||||||
|
|
||||||
|
// inject the throw sound and play it locally
|
||||||
|
_throwInjector.injectViaThread(app->getAudio());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
|
|
||||||
#include <AvatarData.h>
|
#include <AvatarData.h>
|
||||||
|
#include <AudioInjector.h>
|
||||||
#include <HandData.h>
|
#include <HandData.h>
|
||||||
#include <ParticleEditHandle.h>
|
#include <ParticleEditHandle.h>
|
||||||
|
|
||||||
|
@ -110,7 +111,9 @@ private:
|
||||||
|
|
||||||
glm::vec3 _grabDelta;
|
glm::vec3 _grabDelta;
|
||||||
glm::vec3 _grabDeltaVelocity;
|
glm::vec3 _grabDeltaVelocity;
|
||||||
|
|
||||||
|
AudioInjector _throwInjector;
|
||||||
|
AudioInjector _catchInjector;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -62,6 +62,8 @@ public:
|
||||||
|
|
||||||
bool isStarved() const { return _isStarved; }
|
bool isStarved() const { return _isStarved; }
|
||||||
void setIsStarved(bool isStarved) { _isStarved = isStarved; }
|
void setIsStarved(bool isStarved) { _isStarved = isStarved; }
|
||||||
|
|
||||||
|
bool hasStarted() const { return _hasStarted; }
|
||||||
protected:
|
protected:
|
||||||
// disallow copying of AudioRingBuffer objects
|
// disallow copying of AudioRingBuffer objects
|
||||||
AudioRingBuffer(const AudioRingBuffer&);
|
AudioRingBuffer(const AudioRingBuffer&);
|
||||||
|
|
Loading…
Reference in a new issue