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 
32 namespace Common {
33 class MacResManager;
34 }
35 
36 namespace StarTrek {
37 
38 class StarTrekEngine;
39 
40 
41 // Max # of VOC files that can play at once
42 const int MAX_SFX_PLAYING = 4;
43 
44 const int NUM_MIDI_SLOTS = 8;
45 
47  int slot;
48  int track;
49  MidiParser *midiParser;
50 };
51 
52 
53 class Sound {
54 public:
55  Sound(StarTrekEngine *vm);
56  ~Sound();
57 
58  void clearAllMidiSlots();
62  void playMidiTrack(int track);
63  void playMidiTrackInSlot(int slot, int track);
64  bool isMidiPlaying();
65  void loadMusicFile(const Common::String &baseSoundName);
66  void playMidiMusicTracks(int startTrack, int loopTrack);
67  void playVoc(const Common::String &baseSoundName);
68  void playSpeech(const Common::String &basename);
69  void stopAllVocSounds();
70  void stopPlayingSpeech();
71  void playSoundEffectIndex(int index);
72  void setMusicEnabled(bool enable);
73  void setSfxEnabled(bool enable);
74  void toggleMusic();
75  void toggleSfx();
76  void checkLoopMusic();
77 
78 private:
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 
99 public:
100  Common::String _loopingAudioName;
101  Common::String _loadedMidiFilename;
102  int _loopingMidiTrack;
103 
104 private:
105  // Driver callback
106  static void midiDriverCallback(void *data);
107 };
108 
109 } // End of namespace StarTrek
110 
111 #endif
Definition: str.h:59
Definition: list.h:44
Definition: mididrv.h:299
Definition: mixer.h:49
Definition: sound.h:46
Definition: algorithm.h:29
Definition: action.h:27
Definition: startrek.h:239
Definition: sound.h:53
Definition: midiparser.h:289