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 ZVISION_MUSIC_NODE_H 24 #define ZVISION_MUSIC_NODE_H 25 26 #include "audio/mixer.h" 27 #include "zvision/scripting/scripting_effect.h" 28 #include "zvision/text/subtitles.h" 29 30 namespace Common { 31 class String; 32 } 33 34 namespace ZVision { 35 36 class MusicNodeBASE : public ScriptingEffect { 37 public: MusicNodeBASE(ZVision * engine,uint32 key,ScriptingEffectType type)38 MusicNodeBASE(ZVision *engine, uint32 key, ScriptingEffectType type) : ScriptingEffect(engine, key, type) {} ~MusicNodeBASE()39 ~MusicNodeBASE() override {} 40 41 /** 42 * Decrement the timer by the delta time. If the timer is finished, set the status 43 * in _globalState and let this node be deleted 44 * 45 * @param deltaTimeInMillis The number of milliseconds that have passed since last frame 46 * @return If true, the node can be deleted after process() finishes 47 */ 48 bool process(uint32 deltaTimeInMillis) override = 0; 49 50 virtual void setVolume(uint8 volume) = 0; 51 virtual uint8 getVolume() = 0; 52 virtual void setDeltaVolume(uint8 volume) = 0; 53 virtual void setBalance(int8 balance) = 0; 54 55 virtual void setFade(int32 time, uint8 target) = 0; 56 }; 57 58 class MusicNode : public MusicNodeBASE { 59 public: 60 MusicNode(ZVision *engine, uint32 key, Common::String &file, bool loop, uint8 volume); 61 ~MusicNode() override; 62 63 /** 64 * Decrement the timer by the delta time. If the timer is finished, set the status 65 * in _globalState and let this node be deleted 66 * 67 * @param deltaTimeInMillis The number of milliseconds that have passed since last frame 68 * @return If true, the node can be deleted after process() finishes 69 */ 70 bool process(uint32 deltaTimeInMillis) override; 71 72 void setVolume(uint8 volume) override; 73 uint8 getVolume() override; 74 void setDeltaVolume(uint8 volume) override; 75 void setBalance(int8 balance) override; 76 77 void setFade(int32 time, uint8 target) override; 78 79 private: 80 uint8 _volume; 81 uint8 _deltaVolume; 82 int8 _balance; 83 bool _loop; 84 bool _crossfade; 85 uint8 _crossfadeTarget; 86 int32 _crossfadeTime; 87 bool _stereo; 88 Audio::SoundHandle _handle; 89 Subtitle *_sub; 90 bool _loaded; 91 }; 92 93 // Only used by Zork: Nemesis, for the flute and piano puzzles (tj4e and ve6f, as well as vr) 94 class MusicMidiNode : public MusicNodeBASE { 95 public: 96 MusicMidiNode(ZVision *engine, uint32 key, int8 program, int8 note, int8 volume); 97 ~MusicMidiNode() override; 98 99 /** 100 * Decrement the timer by the delta time. If the timer is finished, set the status 101 * in _globalState and let this node be deleted 102 * 103 * @param deltaTimeInMillis The number of milliseconds that have passed since last frame 104 * @return If true, the node can be deleted after process() finishes 105 */ 106 bool process(uint32 deltaTimeInMillis) override; 107 108 void setVolume(uint8 volume) override; 109 uint8 getVolume() override; 110 void setDeltaVolume(uint8 volume) override; 111 void setBalance(int8 balance) override; 112 113 void setFade(int32 time, uint8 target) override; 114 115 private: 116 int8 _chan; 117 int8 _noteNumber; 118 int8 _pan; 119 int8 _volume; 120 int8 _prog; 121 }; 122 123 class PanTrackNode : public ScriptingEffect { 124 public: 125 PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos); 126 ~PanTrackNode() override; 127 128 bool process(uint32 deltaTimeInMillis) override; 129 130 private: 131 uint32 _slot; 132 int16 _position; 133 }; 134 135 } // End of namespace ZVision 136 137 #endif 138