ScummVM API documentation
wave_file.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 TITANIC_WAVE_FILE_H
23#define TITANIC_WAVE_FILE_H
24
25#include "audio/audiostream.h"
26#include "audio/mixer.h"
27#include "titanic/sound/audio_buffer.h"
28#include "titanic/support/string.h"
29#include "titanic/true_talk/dialogue_file.h"
30
31namespace Titanic {
32
33enum LoadMode { LOADMODE_AUDIO_BUFFER = 1, LOADMODE_SCUMMVM = 2 };
34
35class CWaveFile {
36private:
37 Audio::Mixer *_mixer;
38 byte *_waveData;
39 int _waveSize;
40 int _dataSize;
41 int _headerSize;
42 int _rate;
43 byte _flags;
44 uint16 _wavType;
45 Audio::SeekableAudioStream *_pendingAudioStream;
46private:
50 void setup();
51
55 void load(byte *data, uint dataSize);
56
60 Audio::SeekableAudioStream *createAudioStream();
61public:
62 Audio::Mixer::SoundType _soundType;
63
64 LoadMode _loadMode;
65 CAudioBuffer *_audioBuffer;
66 DisposeAfterUse::Flag _disposeAudioBuffer;
67 int _channel;
68public:
69 CWaveFile(Audio::Mixer *mixer);
70 ~CWaveFile();
71
77 uint getDurationTicks() const;
78
82 uint size() const { return _dataSize; }
83
87 bool loadSound(const CString &name);
88
92 bool loadSpeech(CDialogueFile *dialogueFile, int speechIndex);
93
97 bool loadMusic(const CString &name);
98
102 bool loadMusic(CAudioBuffer *buffer, DisposeAfterUse::Flag disposeAfterUse);
103
107 bool isLoaded() const {
108 return _waveData != nullptr || _pendingAudioStream != nullptr;
109 }
110
114 uint getFrequency() const { return _rate; }
115
119 const int16 *lock();
120
124 void unlock(const int16 *ptr);
125
133 Audio::SoundHandle play(int numLoops, byte volume);
134};
135
136} // End of namespace Titanic
137
138#endif /* TITANIC_WAVE_FILE_H */
Definition: mixer.h:70
SoundType
Definition: mixer.h:73
Definition: audiostream.h:212
Definition: mixer.h:49
Definition: audio_buffer.h:32
Definition: dialogue_file.h:51
Definition: string.h:40
Definition: wave_file.h:35
bool loadSpeech(CDialogueFile *dialogueFile, int speechIndex)
bool loadMusic(CAudioBuffer *buffer, DisposeAfterUse::Flag disposeAfterUse)
uint size() const
Definition: wave_file.h:82
const int16 * lock()
bool isLoaded() const
Definition: wave_file.h:107
uint getDurationTicks() const
Audio::SoundHandle play(int numLoops, byte volume)
uint getFrequency() const
Definition: wave_file.h:114
bool loadMusic(const CString &name)
void unlock(const int16 *ptr)
bool loadSound(const CString &name)