aboutsummaryrefslogtreecommitdiff
path: root/engines/illusions/sound.h
blob: d2d91ac3c812845c1cbc990d9ab6f0a5e2b474c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */

#ifndef ILLUSIONS_SOUND_H
#define ILLUSIONS_SOUND_H

#include "illusions/graphics.h"
#include "audio/audiostream.h"
#include "audio/mixer.h"
#include "audio/decoders/wave.h"
#include "common/list.h"

namespace Illusions {

class IllusionsEngine;

class MusicPlayer {
public:
	MusicPlayer();
	~MusicPlayer();
	void play(uint32 musicId, bool looping, int16 volume, int16 pan);
	void stop();
	bool isPlaying();
protected:
	Audio::SoundHandle _soundHandle;
	uint32 _musicId;
	uint _flags;
};

class VoicePlayer {
public:
	VoicePlayer();
	~VoicePlayer();
	bool cue(const char *voiceName);
	void stopCueing();
	void start(int16 volume, int16 pan);
	void stop();
	bool isPlaying();
	bool isEnabled();
	bool isCued();
protected:
	Audio::SoundHandle _soundHandle;
	Common::String _voiceName;
	uint _voiceStatus;
};

class Sound {
public:
	Sound(uint32 soundEffectId, uint32 soundGroupId, bool looping);
	~Sound();
	void load();
	void unload();
	void play(int16 volume, int16 pan);
	void stop();
	bool isPlaying();
public:
	uint32 _soundEffectId;
	uint32 _soundGroupId;
protected:
	Audio::RewindableAudioStream *_stream;
	Audio::SoundHandle _soundHandle;
	bool _looping;
};

class SoundMan {
public:
	SoundMan(IllusionsEngine *vm);
	~SoundMan();
	void update();

	void playMusic(uint32 musicId, int16 type, int16 volume, int16 pan, uint32 notifyThreadId);
	void stopMusic();

	bool cueVoice(const char *voiceName);
	void stopCueingVoice();
	void startVoice(int16 volume, int16 pan);
	void stopVoice();
	bool isVoicePlaying();
	bool isVoiceEnabled();
	bool isVoiceCued();

	void loadSound(uint32 soundEffectId, uint32 soundGroupId, bool looping);
	void playSound(uint32 soundEffectId, int16 volume, int16 pan);
	void stopSound(uint32 soundEffectId);
	void unloadSounds(uint32 soundGroupId);

protected:
	typedef Common::List<Sound*> SoundList;
	typedef SoundList::iterator SoundListIterator;
	IllusionsEngine *_vm;
	uint32 _musicNotifyThreadId;
	MusicPlayer *_musicPlayer;
	VoicePlayer *_voicePlayer;
	SoundList _sounds;
	Sound *getSound(uint32 soundEffectId);
};

} // End of namespace Illusions

#endif // ILLUSIONS_SOUND_H