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 TWINE_SOUND_H
23 #define TWINE_SOUND_H
24 
25 #include "audio/audiostream.h"
26 #include "audio/mixer.h"
27 #include "common/scummsys.h"
28 #include "common/types.h"
29 #include "twine/shared.h"
30 
31 namespace TwinE {
32 
33 class TextEntry;
34 
35 #define NUM_CHANNELS 32
36 
37 namespace Samples {
38 enum _Samples {
39  TwinsenHit = 0,
40  SoldierHit = 4,
41  ItemPopup = 11,
42  Explode = 37,
43  BigItemFound = 41,
44  TaskCompleted = 41,
45  Hit = 86,
46  ItemFound = 97,
47  WalkFloorBegin = 126,
48  WalkFloorRightBegin = 141
49 };
50 }
51 
52 class TwinEEngine;
53 class Sound {
54 private:
55  TwinEEngine *_engine;
56 
58  int32 getSampleChannel(int32 index);
59 
61  Audio::SoundHandle samplesPlaying[NUM_CHANNELS];
62 
64  int32 samplesPlayingActors[NUM_CHANNELS]{0};
65 
66  bool playSample(int channelIdx, int index, Audio::SeekableAudioStream *audioStream, int32 loop, const char *name, Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType);
67 
68  bool isChannelPlaying(int32 channel);
69 
71  int32 getFreeSampleChannelIndex();
72 
74  void removeSampleChannel(int32 index);
75 
76 public:
77  Sound(TwinEEngine *engine);
78  ~Sound();
79 
85  void playFlaSample(int32 index, int32 repeat, uint8 balance, int32 volumeLeft, int32 volumeRight);
86 
88  void setSamplePosition(int32 channelIdx, int32 x, int32 y, int32 z);
89 
90  inline void setSamplePosition(int32 channelIdx, const IVec3 &pos) {
91  setSamplePosition(channelIdx, pos.x, pos.y, pos.z);
92  }
93 
103  // HQ_MixSample
104  void playSample(int32 index, int32 repeat = 1, int32 x = 128, int32 y = 128, int32 z = 128, int32 actorIdx = -1);
105  void playSample(int32 index, int32 repeat, const IVec3 &pos, int32 actorIdx = -1) {
106  playSample(index, repeat, pos.x, pos.y, pos.z, actorIdx);
107  }
108 
110  void pauseSamples();
111 
113  void resumeSamples();
114 
115  void startRainSample();
116 
118  void stopSamples();
119 
121  int32 getActorChannel(int32 index);
122 
124  void stopSample(int32 index);
125 
127  int32 isSamplePlaying(int32 index);
128 
130  bool playVoxSample(const TextEntry *text);
131 };
132 
133 } // namespace TwinE
134 
135 #endif
Definition: text.h:33
Definition: sound.h:53
Definition: shared.h:113
Definition: audiostream.h:212
Definition: mixer.h:49
SoundType
Definition: mixer.h:62
Definition: twine.h:200
Definition: achievements_tables.h:27
Definition: mixer.h:63