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