add a volume setter to the AudioInjector

This commit is contained in:
Stephen Birarda 2013-12-19 15:28:10 -08:00
parent 3f4b4178ff
commit 534010347b
2 changed files with 5 additions and 1 deletions

View file

@ -107,7 +107,7 @@ void AudioInjector::injectAudio(AbstractAudioInterface* localAudioInterface) {
currentPacketPosition += sizeof(radius);
// pack 255 for attenuation byte
uchar volume = 255;
uchar volume = MAX_INJECTOR_VOLUME * _volume;
memcpy(currentPacketPosition, &volume, sizeof(volume));
currentPacketPosition += sizeof(volume);

View file

@ -19,6 +19,8 @@
class AbstractAudioInterface;
class QNetworkReply;
const uchar MAX_INJECTOR_VOLUME = 0xFF;
class AudioInjector : public QObject {
Q_OBJECT
public:
@ -28,6 +30,7 @@ public:
void setPosition(const glm::vec3& position) { _position = position; }
void setOrientation(const glm::quat& orientation) { _orientation = orientation; }
void setVolume(float volume) { _volume = std::max(fabsf(volume), 1.0f); }
public slots:
void injectViaThread(AbstractAudioInterface* localAudioInterface = NULL);
@ -38,6 +41,7 @@ private:
QUrl _sourceURL;
glm::vec3 _position;
glm::quat _orientation;
float _volume;
private slots:
void startDownload();