// // AudioReflector.h // interface // // Created by Brad Hefta-Gaub on 4/2/2014 // Copyright (c) 2014 High Fidelity, Inc. All rights reserved. // #ifndef __interface__AudioReflector__ #define __interface__AudioReflector__ #include #include #include "Audio.h" #include "avatar/MyAvatar.h" class AudioReflector : public QObject { Q_OBJECT public: AudioReflector(QObject* parent = NULL); void setVoxels(VoxelTree* voxels) { _voxels = voxels; } void setMyAvatar(MyAvatar* myAvatar) { _myAvatar = myAvatar; } void setAudio(Audio* audio) { _audio = audio; } void render(); int getReflections() const { return _reflections; } float getAverageDelayMsecs() const { return _averageDelay; } float getAverageAttenuation() const { return _averageAttenuation; } float getMaxDelayMsecs() const { return _maxDelay; } float getMaxAttenuation() const { return _maxAttenuation; } float getMinDelayMsecs() const { return _minDelay; } float getMinAttenuation() const { return _minAttenuation; } float getDelayFromDistance(float distance); public slots: void processSpatialAudio(unsigned int sampleTime, const QByteArray& samples, const QAudioFormat& format); signals: private: VoxelTree* _voxels; // used to access voxel scene MyAvatar* _myAvatar; // access to listener Audio* _audio; // access to audio API void drawRays(); void drawVector(const glm::vec3& start, const glm::vec3& end, const glm::vec3& color); void echoReflections(const glm::vec3& origin, const QVector& reflections, const QByteArray& samples, unsigned int sampleTime, int sampleRate); QVector calculateReflections(const glm::vec3& origin, const glm::vec3& originalDirection, int maxBounces); void drawReflections(const glm::vec3& origin, const glm::vec3& originalColor, const QVector& reflections); void calculateAllReflections(); void reset(); int _reflections; int _delayCount; float _totalDelay; float _averageDelay; float _maxDelay; float _minDelay; int _attenuationCount; float _totalAttenuation; float _averageAttenuation; float _maxAttenuation; float _minAttenuation; glm::vec3 _origin; QVector _frontRightUpReflections; QVector _frontLeftUpReflections; QVector _backRightUpReflections; QVector _backLeftUpReflections; QVector _frontRightDownReflections; QVector _frontLeftDownReflections; QVector _backRightDownReflections; QVector _backLeftDownReflections; QVector _frontReflections; QVector _backReflections; QVector _leftReflections; QVector _rightReflections; QVector _upReflections; QVector _downReflections; QMutex _mutex; }; #endif /* defined(__interface__AudioReflector__) */