mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 20:14:02 +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
assignment-client/src/audio
interface/src/avatar
libraries/audio/src
|
@ -94,11 +94,10 @@ void AudioMixerClientData::pushBuffersAfterFrameSend() {
|
|||
audioBuffer->shiftReadPosition(NETWORK_BUFFER_LENGTH_SAMPLES_PER_CHANNEL);
|
||||
|
||||
audioBuffer->setWillBeAddedToMix(false);
|
||||
} else if (audioBuffer->isStarved()) {
|
||||
// this was previously the kill for injected audio from a client
|
||||
// fix when that is added back
|
||||
// delete audioBuffer;
|
||||
// _ringBuffers.erase(_ringBuffers.begin() + i);
|
||||
} else if (audioBuffer->hasStarted() && audioBuffer->isStarved()) {
|
||||
// this is an empty audio buffer that has starved, safe to delete
|
||||
delete audioBuffer;
|
||||
_ringBuffers.erase(_ringBuffers.begin() + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,9 @@ Hand::Hand(Avatar* owningAvatar) :
|
|||
_collisionDuration(0),
|
||||
_pitchUpdate(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++) {
|
||||
_toyBallInHand[i] = false;
|
||||
|
@ -61,6 +63,10 @@ Hand::Hand(Avatar* owningAvatar) :
|
|||
_whichBallColor[i] = 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() {
|
||||
|
@ -119,7 +125,10 @@ void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, f
|
|||
_ballParticleEditHandles[handID] = caughtParticle;
|
||||
caughtParticle = NULL;
|
||||
// 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];
|
||||
_ballParticleEditHandles[handID] = NULL;
|
||||
|
||||
// Play a throw sound
|
||||
app->getAudio()->startDrumSound(1.0, 3000, 0.5, 0.02);
|
||||
// move the throw injector to inject from the position of the ball
|
||||
_throwInjector.setPosition(ballPosition);
|
||||
|
||||
// inject the throw sound and play it locally
|
||||
_throwInjector.injectViaThread(app->getAudio());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <SharedUtil.h>
|
||||
|
||||
#include <AvatarData.h>
|
||||
#include <AudioInjector.h>
|
||||
#include <HandData.h>
|
||||
#include <ParticleEditHandle.h>
|
||||
|
||||
|
@ -110,7 +111,9 @@ private:
|
|||
|
||||
glm::vec3 _grabDelta;
|
||||
glm::vec3 _grabDeltaVelocity;
|
||||
|
||||
|
||||
AudioInjector _throwInjector;
|
||||
AudioInjector _catchInjector;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -62,6 +62,8 @@ public:
|
|||
|
||||
bool isStarved() const { return _isStarved; }
|
||||
void setIsStarved(bool isStarved) { _isStarved = isStarved; }
|
||||
|
||||
bool hasStarted() const { return _hasStarted; }
|
||||
protected:
|
||||
// disallow copying of AudioRingBuffer objects
|
||||
AudioRingBuffer(const AudioRingBuffer&);
|
||||
|
|
Loading…
Reference in a new issue