ScummVM API documentation
dimuse_internalmixer.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#if !defined(SCUMM_IMUSE_DIGI_MIXER_H) && defined(ENABLE_SCUMM_7_8)
23#define SCUMM_IMUSE_DIGI_MIXER_H
24
25#include "common/scummsys.h"
26#include "common/mutex.h"
27#include "common/serializer.h"
28#include "common/textconsole.h"
29#include "common/util.h"
30
31#include "scumm/imuse_digi/dimuse_engine.h"
32#include "scumm/music.h"
33#include "scumm/sound.h"
34#include "audio/mixer.h"
35#include "audio/audiostream.h"
36
37namespace Audio {
38class AudioStream;
39class Mixer;
40class QueuingAudioStream;
41}
42
43namespace Scumm {
44
45class IMuseDigiInternalMixer {
46
47private:
48 int32 *_amp8Table = nullptr;
49 int32 *_amp12Table = nullptr;
50 int32 *_softLMID = nullptr;
51 int32 *_softLTable = nullptr;
52
53 uint8 *_mixBuf = nullptr;
54
55 Audio::Mixer *_mixer;
56 Audio::SoundHandle _channelHandle;
57 int _mixBufSize = 0;
58 int _radioChatter = 0;
59 int _outWordSize = 0;
60 int _outChannelCount = 0;
61 int _sampleRate = 0;
62 int _stereoReverseFlag = 0;
63 bool _isEarlyDiMUSE = false;
64 bool _lowLatencyMode = false;
65
66 void mixBits8Mono(uint8 *srcBuf, int32 inFrameCount, int feedSize, int32 mixBufStartIndex, int32 *ampTable, bool ftIs11025Hz);
67 void mixBits12Mono(uint8 *srcBuf, int32 inFrameCount, int feedSize, int32 mixBufStartIndex, int32 *ampTable);
68 void mixBits16Mono(uint8 *srcBuf, int32 inFrameCount, int feedSize, int32 mixBufStartIndex, int32 *ampTable);
69
70 void mixBits8ConvertToMono(uint8 *srcBuf, int32 inFrameCount, int feedSize, int32 mixBufStartIndex, int32 *ampTable);
71 void mixBits12ConvertToMono(uint8 *srcBuf, int32 inFrameCount, int feedSize, int32 mixBufStartIndex, int32 *ampTable);
72 void mixBits16ConvertToMono(uint8 *srcBuf, int32 inFrameCount, int feedSize, int32 mixBufStartIndex, int32 *ampTable);
73
74 void mixBits8ConvertToStereo(uint8 *srcBuf, int32 inFrameCount, int feedSize, int32 mixBufStartIndex, int32 *leftAmpTable, int32 *rightAmpTable, bool ftIs11025Hz);
75 void mixBits12ConvertToStereo(uint8 *srcBuf, int32 inFrameCount, int feedSize, int32 mixBufStartIndex, int32 *leftAmpTable, int32 *rightAmpTable);
76 void mixBits16ConvertToStereo(uint8 *srcBuf, int32 inFrameCount, int feedSize, int32 mixBufStartIndex, int32 *leftAmpTable, int32 *rightAmpTable);
77
78 void mixBits8Stereo(uint8 *srcBuf, int32 inFrameCount, int feedSize, int32 mixBufStartIndex, int32 *ampTable);
79 void mixBits12Stereo(uint8 *srcBuf, int32 inFrameCount, int feedSize, int32 mixBufStartIndex, int32 *ampTable);
80 void mixBits16Stereo(uint8 *srcBuf, int32 inFrameCount, int feedSize, int32 mixBufStartIndex, int32 *ampTable);
81
82public:
83 IMuseDigiInternalMixer(Audio::Mixer *mixer, int sampleRate, bool isEarlyDiMUSE, bool lowLatencyMode = false);
84 ~IMuseDigiInternalMixer();
85 int init(int bytesPerSample, int numChannels, uint8 *mixBuf, int mixBufSize, int sizeSampleKB, int mixChannelsNum);
86 void setRadioChatter();
87 void clearRadioChatter();
88 int clearMixerBuffer();
89
90 void mix(uint8 *srcBuf, int32 inFrameCount, int wordSize, int channelCount, int feedSize, int32 mixBufStartIndex, int volume, int pan, bool ftIs11025Hz);
91 int loop(uint8 **destBuffer, int len);
93
94 // For low latency audio
95 void setCurrentMixerBuffer(uint8 *newBuf);
96 void endStream(int idx);
97 Audio::QueuingAudioStream *getStream(int idx);
98
99 Audio::QueuingAudioStream *_separateStreams[DIMUSE_MAX_TRACKS];
100 Audio::SoundHandle _separateChannelHandles[DIMUSE_MAX_TRACKS];
101};
102
103} // End of namespace Scumm
104
105#endif
Definition: mixer.h:70
Definition: audiostream.h:370
Definition: mixer.h:49
Definition: system.h:39
Definition: actor.h:30