1 /* ResidualVM - A 3D game interpreter 2 * 3 * ResidualVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef GRIM_SOUNDTRACK_H 24 #define GRIM_SOUNDTRACK_H 25 26 #include "audio/mixer.h" 27 #include "audio/timestamp.h" 28 #include "math/vector3d.h" 29 30 namespace Common { 31 class String; 32 } 33 34 namespace Audio { 35 class AudioStream; 36 class SoundHandle; 37 } 38 39 namespace Grim { 40 41 class SaveGame; 42 43 /** 44 * @class Super-class for the different codecs used in EMI 45 */ 46 class SoundTrack { 47 public: 48 enum FadeMode { 49 FadeNone, 50 FadeIn, 51 FadeOut 52 }; 53 protected: 54 Common::String _soundName; 55 Audio::AudioStream *_stream; 56 Audio::SoundHandle *_handle; 57 Audio::Mixer::SoundType _soundType; 58 DisposeAfterUse::Flag _disposeAfterPlaying; 59 bool _paused; 60 bool _positioned; 61 Math::Vector3d _pos; 62 FadeMode _fadeMode; 63 float _fade; 64 float _attenuation; 65 int _balance; 66 int _volume; 67 int _sync; 68 public: 69 SoundTrack(); 70 virtual ~SoundTrack(); 71 virtual bool openSound(const Common::String &filename, const Common::String &voiceName, const Audio::Timestamp *start = nullptr) = 0; 72 virtual bool isPlaying() = 0; 73 virtual bool play(); 74 virtual void pause(); 75 virtual void stop(); 76 fadeIn()77 void fadeIn() { _fadeMode = FadeIn; } fadeOut()78 void fadeOut() { _fadeMode = FadeOut; } setFadeMode(FadeMode fadeMode)79 void setFadeMode(FadeMode fadeMode) { _fadeMode = fadeMode; } 80 void setFade(float fade); getFade()81 float getFade() const { return _fade; } getFadeMode()82 FadeMode getFadeMode() const { return _fadeMode; } 83 void setBalance(int balance); 84 void setVolume(int volume); 85 void setPosition(bool positioned, const Math::Vector3d &pos = Math::Vector3d()); 86 void updatePosition(); setSync(int sync)87 void setSync(int sync) { _sync = sync; } 88 int getEffectiveVolume(); getVolume()89 int getVolume() const { return _volume; } getBalance()90 int getBalance() const { return _balance; } getSync()91 int getSync() const { return _sync; } 92 virtual Audio::Timestamp getPos() = 0; 93 Common::String getSoundName(); 94 void setSoundName(const Common::String &name); hasLooped()95 virtual bool hasLooped() { return false; } setLooping(bool looping)96 virtual void setLooping(bool looping) { } isLooping()97 virtual bool isLooping() const { return false; } isPaused()98 bool isPaused() const { return _paused; } isPositioned()99 bool isPositioned() const { return _positioned; } getWorldPos()100 Math::Vector3d getWorldPos() const { return _pos; } getSoundType()101 Audio::Mixer::SoundType getSoundType() const { return _soundType; } 102 }; 103 104 } 105 106 #endif 107