1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM 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 BLADERUNNER_AUDIO_PLAYER_H 24 #define BLADERUNNER_AUDIO_PLAYER_H 25 26 #include "common/array.h" 27 #include "common/mutex.h" 28 #include "common/str.h" 29 30 #include "audio/audiostream.h" 31 #include "audio/mixer.h" 32 33 namespace BladeRunner { 34 35 class BladeRunnerEngine; 36 class AudioCache; 37 class AudStream; 38 39 enum AudioPlayerFlags { 40 kAudioPlayerLoop = 1, 41 kAudioPlayerOverrideVolume = 2 42 }; 43 44 class AudioPlayer { 45 #if BLADERUNNER_ORIGINAL_BUGS 46 static const int kTracks = 6; 47 #else 48 // increase tracks, reduce probability of tracks being skipped 49 static const int kTracks = 12; 50 #endif // BLADERUNNER_ORIGINAL_BUGS 51 // Use SFX sound type if none is specified 52 static const Audio::Mixer::SoundType kAudioPlayerSoundType = Audio::Mixer::kSFXSoundType; 53 54 struct Track { 55 bool isActive; 56 int channel; 57 int priority; 58 int volume; 59 int pan; 60 AudStream *stream; 61 }; 62 63 BladeRunnerEngine *_vm; 64 65 Common::Mutex _mutex; 66 Track _tracks[kTracks]; 67 int _sfxVolume; 68 69 public: 70 AudioPlayer(BladeRunnerEngine *vm); 71 ~AudioPlayer(); 72 73 int playAud(const Common::String &name, int volume, int panStart, int panEnd, int priority, byte flags = 0, Audio::Mixer::SoundType type = kAudioPlayerSoundType); 74 bool isActive(int track) const; 75 uint32 getLength(int track) const; 76 void stop(int track, bool immediately); 77 void stopAll(); 78 void adjustVolume(int track, int volume, uint32 delaySeconds, bool overrideVolume); 79 void adjustPan(int track, int pan, uint32 delaySeconds); 80 81 // void setVolume(int volume); 82 int getVolume() const; 83 void playSample(); 84 85 private: 86 void remove(int channel); 87 static void mixerChannelEnded(int channel, void *data); 88 }; 89 90 } // End of namespace BladeRunner 91 92 #endif 93