ScummVM API documentation
music_effect.h
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 modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (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, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef ZVISION_MUSIC_NODE_H
23#define ZVISION_MUSIC_NODE_H
24
25#include "audio/mixer.h"
26#include "math/angle.h"
27#include "zvision/scripting/scripting_effect.h"
28#include "zvision/sound/volume_manager.h"
29#include "zvision/text/subtitle_manager.h"
30
31namespace Common {
32class String;
33}
34
35namespace ZVision {
36
38public:
39 MusicNodeBASE(ZVision *engine, uint32 key, ScriptingEffectType type) : ScriptingEffect(engine, key, type) {}
40 ~MusicNodeBASE() override {}
41
49 bool process(uint32 deltaTimeInMillis) override = 0;
50
51 virtual void setVolume(uint8 volume) = 0;
52 uint8 getVolume() {
53 return _volume;
54 }
55 virtual void setFade(int32 time, uint8 target) = 0;
56 virtual void setBalance(int8 balance); // NB Overrides effects of setDirection()
57 void setDirection(Math::Angle azimuth, uint8 magnitude = 255); // NB Overrides effects of setBalance()
58protected:
59 void updateMixer();
60 virtual void outputMixer() = 0;
61
62 uint8 _volume = 0;
63 int8 _balance = 0;
64 Math::Angle _azimuth;
65 uint8 _directionality; // 0 = fully ambient, 255 = fully directional
66 uint8 _volumeOut = 0;
67};
68
69class MusicNode : public MusicNodeBASE {
70public:
71 MusicNode(ZVision *engine, uint32 key, Common::Path &file, bool loop, uint8 volume);
72 ~MusicNode() override;
73
81 bool process(uint32 deltaTimeInMillis) override;
82
83 void setVolume(uint8 volume) override;
84
85 void setFade(int32 time, uint8 target) override;
86
87private:
88 void outputMixer() override;
89 bool _loop;
90 bool _fade;
91 uint8 _fadeStartVol;
92 uint8 _fadeEndVol;
93 uint32 _fadeTime;
94 uint32 _fadeElapsed; // Cumulative time since fade start
95 bool _stereo;
96 Audio::SoundHandle _handle;
97 uint16 _sub;
98 bool _loaded;
99};
100
101// Only used by Zork: Nemesis, for the flute and piano puzzles (tj4e and ve6f, as well as vr)
103public:
104 MusicMidiNode(ZVision *engine, uint32 key, uint8 program, uint8 note, uint8 volume);
105 ~MusicMidiNode() override;
106
114 bool process(uint32 deltaTimeInMillis) override;
115
116 void setVolume(uint8 volume) override;
117
118 void setFade(int32 time, uint8 target) override;
119
120private:
121 void outputMixer() override;
122 int8 _chan;
123 uint8 _noteNumber;
124 int8 _pan;
125 uint8 _prog;
126};
127
129public:
130 PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos, uint8 mag = 255, bool resetMixerOnDelete = false, bool staticScreen = false);
131 ~PanTrackNode() override;
132
133 bool process(uint32 deltaTimeInMillis) override;
134
135private:
136 uint32 _slot;
137 int16 _width, _pos;
138 Math::Angle _sourcePos, _viewPos;
139 uint8 _mag;
140 bool _resetMixerOnDelete;
141 bool _staticScreen;
142};
143
144} // End of namespace ZVision
145
146#endif
Definition: mixer.h:49
Definition: path.h:52
Definition: music_effect.h:102
bool process(uint32 deltaTimeInMillis) override
Definition: music_effect.h:37
bool process(uint32 deltaTimeInMillis) override=0
Definition: music_effect.h:69
bool process(uint32 deltaTimeInMillis) override
Definition: music_effect.h:128
Definition: scripting_effect.h:45
Definition: algorithm.h:29
Definition: focus_list.h:27