ScummVM API documentation
emisound.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 GRIM_MSS_H
23
#define GRIM_MSS_H
24
25
#include "audio/mixer.h"
26
27
#include "common/str.h"
28
#include "common/stack.h"
29
#include "common/mutex.h"
30
#include "common/hashmap.h"
31
32
#include "math/vector3d.h"
33
34
namespace
Grim
{
35
36
class
SoundTrack;
37
class
SaveGame;
38
39
struct
MusicEntry
{
40
int
_x;
41
int
_y;
42
int
_sync;
43
int
_trim;
44
int
_id;
45
Common::String
_type;
46
Common::String
_name;
47
Common::String
_filename;
48
};
49
50
// Currently this class only implements the exact functions called in iMuse
51
// from Actor, to allow for splitting that into EMI-sound and iMuse without
52
// changing iMuse.
53
class
EMISound
{
54
public
:
55
EMISound
(
int
fps);
56
~
EMISound
();
57
bool
startVoice(
const
Common::String
&soundName,
int
volume = static_cast<int>(
Audio::Mixer::kMaxChannelVolume
),
int
pan = 64);
58
bool
startSfx(
const
Common::String
&soundName,
int
volume = static_cast<int>(
Audio::Mixer::kMaxChannelVolume
),
int
pan = 64);
59
bool
startSfxFrom(
const
Common::String
&soundName,
const
Math::Vector3d &pos,
int
volume = static_cast<int>(
Audio::Mixer::kMaxChannelVolume
));
60
bool
getSoundStatus(
const
Common::String
&soundName);
61
void
stopSound(
const
Common::String
&soundName);
62
int32 getPosIn16msTicks(
const
Common::String
&soundName);
63
64
void
setVolume(
const
Common::String
&soundName,
int
volume);
65
void
setPan(
const
Common::String
&soundName,
int
pan);
/* pan: 0 .. 127 */
66
67
bool
loadSfx(
const
Common::String
&soundName,
int
&
id
);
68
void
playLoadedSound(
int
id
,
bool
looping);
69
void
playLoadedSoundFrom(
int
id
,
const
Math::Vector3d &pos,
bool
looping);
70
void
setLoadedSoundLooping(
int
id
,
bool
looping);
71
void
stopLoadedSound(
int
id
);
72
void
freeLoadedSound(
int
id
);
73
void
setLoadedSoundVolume(
int
id
,
int
volume);
74
void
setLoadedSoundPan(
int
id
,
int
pan);
75
void
setLoadedSoundPosition(
int
id
,
const
Math::Vector3d &pos);
76
bool
getLoadedSoundStatus(
int
id
);
77
int
getLoadedSoundVolume(
int
id
);
78
79
void
setMusicState(
int
stateId);
80
void
selectMusicSet(
int
setId);
81
82
bool
stateHasLooped(
int
stateId);
83
bool
stateHasEnded(
int
stateId);
84
85
void
restoreState(
SaveGame
*savedState);
86
void
saveState(
SaveGame
*savedState);
87
88
void
pushStateToStack();
89
void
popStateFromStack();
90
void
flushStack();
91
void
pause(
bool
paused);
92
void
flushTracks();
93
94
uint32 getMsPos(
int
stateId);
95
96
void
updateSoundPositions();
97
98
private
:
99
struct
StackEntry {
100
int
_state;
101
SoundTrack
*_track;
102
};
103
104
typedef
Common::List<SoundTrack *>
TrackList
;
105
TrackList _playingTracks;
106
SoundTrack
*_musicTrack;
107
MusicEntry
*_musicTable;
108
Common::String
_musicPrefix;
109
Common::Stack<StackEntry>
_stateStack;
110
// A mutex to avoid concurrent modification of the sound channels by the engine thread
111
// and the timer callback, which may run in a different thread.
112
Common::Mutex
_mutex;
113
114
typedef
Common::HashMap<int, SoundTrack *>
TrackMap
;
115
TrackMap _preloadedTrackMap;
116
117
int
_curMusicState;
118
int
_numMusicStates;
119
int
_callbackFps;
120
int
_curTrackId;
121
122
static
void
timerHandler(
void
*refConf);
123
void
removeItem(
SoundTrack
*item);
124
TrackList::iterator
getPlayingTrackByName(
const
Common::String
&name);
125
void
freeChannel(int32 channel);
126
void
initMusicTable();
127
128
void
callback();
129
void
updateTrack(
SoundTrack
*track);
130
void
freePlayingSounds();
131
void
freeLoadedSounds();
132
SoundTrack
*initTrack(
const
Common::String
&soundName,
Audio::Mixer::SoundType
soundType,
const
Audio::Timestamp
*start =
nullptr
)
const
;
133
SoundTrack
*restartTrack(
SoundTrack
*track);
134
bool
startSound(
const
Common::String
&soundName,
Audio::Mixer::SoundType
soundType,
int
volume,
int
pan);
135
bool
startSoundFrom(
const
Common::String
&soundName,
Audio::Mixer::SoundType
soundType,
const
Math::Vector3d &pos,
int
volume);
136
void
saveTrack(
SoundTrack
*track,
SaveGame
*savedState);
137
SoundTrack
*restoreTrack(
SaveGame
*savedState);
138
MusicEntry
*initMusicTableDemo(
const
Common::String
&filename);
139
void
initMusicTableRetail(
MusicEntry
*table,
const
Common::String
filename);
140
};
141
142
extern
EMISound
*g_emiSound;
143
144
}
145
146
#endif
Grim::EMISound
Definition:
emisound.h:53
Common::String
Definition:
str.h:59
Common::List< SoundTrack * >
Audio::Timestamp
Definition:
timestamp.h:83
Grim::SaveGame
Definition:
savegame.h:33
Grim::MusicEntry
Definition:
emisound.h:39
Grim
Definition:
actor.h:33
Audio::Mixer::SoundType
SoundType
Definition:
mixer.h:62
Common::HashMap< int, SoundTrack * >
Common::Mutex
Definition:
mutex.h:67
Audio::Mixer::kMaxChannelVolume
Definition:
mixer.h:71
Common::ListInternal::Iterator
Definition:
list_intern.h:51
Common::Stack< StackEntry >
Grim::SoundTrack
Definition:
track.h:46
engines
grim
emi
sound
emisound.h
Generated on Sat Aug 31 2024 09:10:37 for ScummVM API documentation by
1.8.13