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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef GOB_SOUND_SOUNDBLASTER_H
24 #define GOB_SOUND_SOUNDBLASTER_H
25 
26 #include "common/mutex.h"
27 
28 #include "gob/sound/soundmixer.h"
29 
30 namespace Audio {
31 class Mixer;
32 }
33 
34 namespace Gob {
35 
36 class SoundDesc;
37 
38 class SoundBlaster : public SoundMixer {
39 public:
40 	SoundBlaster(Audio::Mixer &mixer);
41 	~SoundBlaster() override;
42 
43 	void playSample(SoundDesc &sndDesc, int16 repCount,
44 			int16 frequency, int16 fadeLength = 0);
45 	void stopSound(int16 fadeLength, SoundDesc *sndDesc = 0);
46 
47 	void playComposition(const int16 *composition, int16 freqVal,
48 			SoundDesc *sndDescs = 0, int8 sndCount = 60);
49 	void stopComposition();
50 	void endComposition();
51 
52 	void repeatComposition(int32 repCount);
53 
54 protected:
55 	Common::Mutex _mutex;
56 
57 	SoundDesc *_compositionSamples;
58 	int8 _compositionSampleCount;
59 	int16 _composition[50];
60 	int8 _compositionPos;
61 
62 	int32 _compositionRepCount;
63 
64 	SoundDesc *_curSoundDesc;
65 
66 	void setSample(SoundDesc &sndDesc, int16 repCount,
67 			int16 frequency, int16 fadeLength) override;
68 	void checkEndSample() override;
69 	void endFade() override;
70 
71 	void nextCompositionPos();
72 };
73 
74 } // End of namespace Gob
75 
76 #endif // GOB_SOUND_SOUNDBLASTER_H
77