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_MUSIC_H 24 #define BLADERUNNER_MUSIC_H 25 26 #include "common/mutex.h" 27 #include "common/str.h" 28 29 namespace BladeRunner { 30 31 class AudStream; 32 class BladeRunnerEngine; 33 class SaveFileReadStream; 34 class SaveFileWriteStream; 35 36 class Music { 37 struct Track { 38 Common::String name; 39 int volume; // A value between 0 and 100 - It is the set volume for the track regardless of fadeIn and fadeOut transitions 40 int pan; // A value between -100 (left) and 100 (right) (0 is center) - It is the set pan/balance for the track regardless of any ongoing adjustments 41 int32 timeFadeInSeconds; // how long will it take for the track to reach target volume (in seconds) 42 int32 timePlaySeconds; // how long the track will play before starting fading out (in seconds) - uses timeFadeOutSeconds for fadeout 43 // -1: Special value for playing the whole track 44 int loop; // values from enum MusicTrackLoop (see game_constants.h) 45 int32 timeFadeOutSeconds; // how long the fade out will be for the track at its end (in seconds) 46 }; 47 48 BladeRunnerEngine *_vm; 49 50 Common::Mutex _mutex; 51 int _musicVolume; 52 int _channel; 53 bool _isNextPresent; 54 bool _isPlaying; 55 bool _isPaused; 56 Track _current; 57 Track _next; 58 byte *_data; 59 AudStream *_stream; 60 61 public: 62 Music(BladeRunnerEngine *vm); 63 ~Music(); 64 65 bool play(const Common::String &trackName, int volume, int pan, int32 timeFadeInSeconds, int32 timePlaySeconds, int loop, int32 timeFadeOutSeconds); 66 void stop(uint32 delaySeconds); 67 void adjust(int volume, int pan, uint32 delaySeconds); 68 bool isPlaying(); 69 70 void setVolume(int volume); 71 int getVolume(); 72 void playSample(); 73 74 void save(SaveFileWriteStream &f); 75 void load(SaveFileReadStream &f); 76 77 #if !BLADERUNNER_ORIGINAL_BUGS 78 // moved to public access 79 void fadeOut(); 80 void next(); 81 #endif // !BLADERUNNER_ORIGINAL_BUGS 82 83 84 private: 85 void reset(); 86 void adjustVolume(int volume, uint32 delaySeconds); 87 void adjustPan(int pan, uint32 delaySeconds); 88 89 void ended(); 90 #if BLADERUNNER_ORIGINAL_BUGS 91 void fadeOut(); 92 void next(); 93 static void timerCallbackFadeOut(void *refCon); 94 static void timerCallbackNext(void *refCon); 95 #endif // BLADERUNNER_ORIGINAL_BUGS 96 97 static void mixerChannelEnded(int channel, void *data); 98 99 byte *getData(const Common::String &name); 100 }; 101 102 } // End of namespace BladeRunner 103 104 #endif 105