// // Sound.h // libraries/audio/src // // Created by Stephen Birarda on 1/2/2014. // Copyright 2014 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #ifndef hifi_Sound_h #define hifi_Sound_h #include #include #include #include class Sound : public Resource { Q_OBJECT Q_PROPERTY(bool downloaded READ isReady) public: Sound(const QUrl& url, bool isStereo = false); bool isStereo() const { return _isStereo; } bool isReady() const { return _isReady; } const QByteArray& getByteArray() { return _byteArray; } signals: void ready(); private: QByteArray _byteArray; bool _isStereo; bool _isReady; void downSample(const QByteArray& rawAudioByteArray); void interpretAsWav(const QByteArray& inputAudioByteArray, QByteArray& outputAudioByteArray); virtual void downloadFinished(const QByteArray& data) override; }; typedef QSharedPointer SharedSoundPointer; Q_DECLARE_METATYPE(SharedSoundPointer) QScriptValue soundSharedPointerToScriptValue(QScriptEngine* engine, SharedSoundPointer const& in); void soundSharedPointerFromScriptValue(const QScriptValue& object, SharedSoundPointer &out); Q_DECLARE_METATYPE(Sound*) QScriptValue soundPointerToScriptValue(QScriptEngine* engine, Sound* const& in); void soundPointerFromScriptValue(const QScriptValue& object, Sound* &out); #endif // hifi_Sound_h