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// Music class
23
24#ifndef SAGA_MUSIC_H
25#define SAGA_MUSIC_H
26
27#include "audio/audiostream.h"
28#include "audio/mididrv.h"
29#include "audio/mididrv_ms.h"
30#include "audio/mt32gm.h"
31#include "audio/midiparser.h"
32#include "audio/mixer.h"
33#include "audio/softsynth/fmtowns_pc98/towns_pc98_driver.h"
34
36
37namespace Saga {
38
39enum MusicFlags {
40 MUSIC_NORMAL = 0,
41 MUSIC_LOOP = 0x0001
42};
43
44class Music {
45private:
46 static const uint8 MUSIC_SUNSPOT = 26;
47 static const uint8 MT32_GOODBYE_MSG[MidiDriver_MT32GM::MT32_DISPLAY_NUM_CHARS];
48
49public:
50 Music(SagaEngine *vm, Audio::Mixer *mixer);
51 ~Music();
52 void close();
53 bool isPlaying();
54 bool hasDigitalMusic() { return _digitalMusic; }
55
56 void play(uint32 resourceId, MusicFlags flags = MUSIC_NORMAL);
57 void pause();
58 void resume();
59 void stop();
60
61 void setVolume(int volume, int time = 1);
62 int getVolume() { return _currentVolume; }
63 void resetVolume();
64 bool isFading();
65
66 bool isAdlib() const { return _driverType == MT_ADLIB; }
67
68 void syncSoundSettings();
69
70 Common::Array<int32> _songTable;
71
72private:
73 SagaEngine *_vm;
74 Audio::Mixer *_mixer;
75
76 MidiParser *_parser;
78 TownsPC98_AudioDriver *_driverPC98;
79 Audio::SoundHandle _musicHandle;
80 uint32 _trackNumber;
81
82 int _userVolume;
83 bool _userMute;
84 int _targetVolume;
85 int _currentVolume;
86 int _currentVolumePercent;
87 bool _digitalMusic;
88 MusicType _musicType;
89 MusicType _driverType;
90
91 ResourceContext *_musicContext;
92 ResourceContext *_digitalMusicContext;
93
94
95 static void musicVolumeGaugeCallback(void *refCon);
96 static void timerCallback(void *refCon);
97 void onTimer();
98 bool playDigital(uint32 resourceId, MusicFlags flags);
99 void playProtracker(uint32 resourceId, MusicFlags flags);
100 void playQuickTime(uint32 resourceId, MusicFlags flags);
101 void playMidi(uint32 resourceId, MusicFlags flags);
102 void musicVolumeGauge();
103 ByteArray *_currentMusicBuffer;
104 ByteArray _musicBuffer[2];
105};
106
107} // End of namespace Saga
108
109#endif
Definition: mixer.h:70
Definition: mixer.h:49
Definition: mididrv_ms.h:86
Definition: midiparser.h:354
Definition: saga.h:464
Definition: music.h:44
Definition: resource.h:105
Definition: saga.h:497
Definition: towns_pc98_driver.h:34
MusicType
Definition: mididrv.h:44
Definition: actor.h:34