ScummVM API documentation
sound.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 STARTREK_SOUND_H
23#define STARTREK_SOUND_H
24
25#include "startrek/soundeffects.h"
26#include "startrek/startrek.h"
27
28#include "audio/midiparser.h"
29#include "audio/mididrv.h"
30#include "audio/mixer.h"
31
32namespace Common {
33class MacResManager;
34}
35
36namespace StarTrek {
37
38class StarTrekEngine;
39
40
41// Max # of VOC files that can play at once
42const int MAX_SFX_PLAYING = 4;
43
44const int NUM_MIDI_SLOTS = 8;
45
47 int slot;
48 int track;
49 MidiParser *midiParser;
50};
51
52
53class Sound {
54public:
56 ~Sound();
57
58 void clearAllMidiSlots();
62 void playMidiTrack(MidiTracks track);
63 void playMidiTrackInSlot(int slot, MidiTracks track);
64 bool isMidiPlaying();
65 void loadMusicFile(const Common::String &baseSoundName);
66 void playMidiMusicTracks(MidiTracks startTrack, MidiLoopType loopType = kLoopTypeNone);
67 void playVoc(const Common::String &baseSoundName);
68 void playSpeech(const Common::String &basename);
69 void stopAllVocSounds();
70 void stopPlayingSpeech();
71 void playSoundEffectIndex(SoundEffects index);
72 void setMusicEnabled(bool enable);
73 void setSfxEnabled(bool enable);
74 void toggleMusic();
75 void toggleSfx();
76 void checkLoopMusic();
77
78private:
79 StarTrekEngine *_vm;
80 Audio::SoundHandle *_soundHandle;
81
82 void loadPCMusicFile(const Common::String &baseSoundName);
83 void clearMidiSlot(int slot);
84
85 // MIDI-Related Variables
86 MidiDriver *_midiDriver;
87 MidiPlaybackSlot _midiSlots[NUM_MIDI_SLOTS]; // 0 is for music; 1-7 are for sfx
88 Common::List<MidiPlaybackSlot *> _midiSlotList; // Sorts midi slots by most recently used
89
90 byte *_loadedSoundData;
91 int _loadedSoundDataSize;
92 uint32 _midiDevice;
93
94 // VOC-related variables
95 Audio::SoundHandle _sfxHandles[MAX_SFX_PLAYING];
96 Audio::SoundHandle _speechHandle;
97 bool _playingSpeech;
98
99public:
100 Common::String _loopingAudioName;
101 Common::String _loadedMidiFilename;
102 MidiTracks _loopingMidiTrack;
103
104private:
105 // Driver callback
106 static void midiDriverCallback(void *data);
107};
108
109} // End of namespace StarTrek
110
111#endif
Definition: mixer.h:49
Definition: list.h:44
Definition: str.h:59
Definition: mididrv.h:313
Definition: midiparser.h:354
Definition: sound.h:53
void playMidiTrack(MidiTracks track)
Definition: startrek.h:237
Definition: algorithm.h:29
Definition: action.h:27
Definition: sound.h:46