hook throw and catch sounds to Hand class ball tests

This commit is contained in:
Stephen Birarda 2013-12-19 17:24:30 -08:00
parent 87e5579e52
commit a01a17c30a
2 changed files with 20 additions and 5 deletions

View file

@ -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());
} }
} }

View file

@ -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>
@ -111,6 +112,8 @@ private:
glm::vec3 _grabDelta; glm::vec3 _grabDelta;
glm::vec3 _grabDeltaVelocity; glm::vec3 _grabDeltaVelocity;
AudioInjector _throwInjector;
AudioInjector _catchInjector;
}; };
#endif #endif