22 #ifndef AUDIO_MODS_PAULA_H 23 #define AUDIO_MODS_PAULA_H 25 #include "audio/audiostream.h" 26 #include "common/frac.h" 27 #include "common/mutex.h" 38 static const int NUM_VOICES = 4;
40 static const int PANNING_LEFT = 63;
42 static const int PANNING_RIGHT = 191;
44 kPalSystemClock = 7093790,
45 kNtscSystemClock = 7159090,
46 kPalCiaClock = kPalSystemClock / 10,
47 kNtscCiaClock = kNtscSystemClock / 10,
48 kPalPaulaClock = kPalSystemClock / 2,
49 kNtscPaulaClock = kNtscSystemClock / 2
58 kFilterModeDefault = kFilterModeNone
60 kFilterModeDefault = kFilterModeA1200
69 explicit Offset(
int off = 0) : int_off(off), rem_off(0) {}
77 float rc[NUM_VOICES][5];
80 Paula(
bool stereo =
false,
int rate = 44100, uint interruptFreq = 0,
81 FilterMode filterMode = kFilterModeDefault,
int periodScaleDivisor = 1);
84 bool playing()
const {
return _playing; }
85 void setTimerBaseValue( uint32 ticksPerSecond ) { _timerBase = ticksPerSecond; }
86 uint32 getTimerBaseValue() {
return _timerBase; }
87 void setSingleInterrupt(uint sampleDelay) { assert(sampleDelay < _intFreq); _curInt = sampleDelay; }
88 void setSingleInterruptUnscaled(uint timerDelay) {
89 setSingleInterrupt((uint)(((
double)timerDelay *
getRate()) / _timerBase));
91 void setInterruptFreq(uint sampleDelay) { _intFreq = sampleDelay; _curInt = 0; }
92 void setInterruptFreqUnscaled(uint timerDelay) {
93 setInterruptFreq((uint)(((
double)timerDelay *
getRate()) / _timerBase));
95 void clearVoice(byte voice);
96 void clearVoices() {
for (
int i = 0; i < NUM_VOICES; ++i) clearVoice(i); }
97 void startPlay() { filterResetState(); _playing =
true; }
98 void stopPlay() { _playing =
false; }
99 void pausePlay(
bool pause) { _playing = !pause; }
102 int readBuffer(int16 *buffer,
const int numSamples);
110 const int8 *dataRepeat;
124 virtual void interrupt() = 0;
126 virtual void interruptChannel(byte channel) { }
138 void setChannelPanning(byte channel, byte panning) {
139 assert(channel < NUM_VOICES);
140 _voice[channel].panning = panning;
143 void disableChannel(byte channel) {
144 assert(channel < NUM_VOICES);
145 _voice[channel].data = 0;
148 void enableChannel(byte channel) {
149 assert(channel < NUM_VOICES);
151 ch.data = ch.dataRepeat;
152 ch.length = ch.lengthRepeat;
158 void setChannelInterrupt(byte channel,
bool enable) {
159 assert(channel < NUM_VOICES);
160 _voice[channel].interrupt = enable;
163 void setChannelPeriod(byte channel, int16 period) {
164 assert(channel < NUM_VOICES);
165 _voice[channel].period = period;
168 void setChannelVolume(byte channel, byte volume) {
169 assert(channel < NUM_VOICES);
170 _voice[channel].volume = volume;
173 void setChannelSampleStart(byte channel,
const int8 *data) {
174 assert(channel < NUM_VOICES);
175 _voice[channel].dataRepeat = data;
178 void setChannelSampleLen(byte channel, uint32 length) {
179 assert(channel < NUM_VOICES);
180 assert(length < 32768/2);
181 _voice[channel].lengthRepeat = 2 * length;
184 void setChannelData(uint8 channel,
const int8 *data,
const int8 *dataRepeat, uint32 length, uint32 lengthRepeat, int32 offset = 0) {
185 assert(channel < NUM_VOICES);
189 ch.dataRepeat = data;
190 ch.lengthRepeat = length;
191 enableChannel(channel);
192 ch.offset =
Offset(offset);
194 ch.dataRepeat = dataRepeat;
195 ch.lengthRepeat = lengthRepeat;
198 void setChannelOffset(byte channel,
Offset offset) {
199 assert(channel < NUM_VOICES);
200 _voice[channel].offset = offset;
203 Offset getChannelOffset(byte channel) {
204 assert(channel < NUM_VOICES);
205 return _voice[channel].offset;
208 int getChannelDmaCount(byte channel) {
209 assert(channel < NUM_VOICES);
210 return _voice[channel].dmaCount;
213 void setChannelDmaCount(byte channel,
int dmaVal = 0) {
214 assert(channel < NUM_VOICES);
215 _voice[channel].dmaCount = dmaVal;
218 void setAudioFilter(
bool enable) {
219 _filterState.ledFilter = enable;
227 const double _periodScale;
235 template<
bool stereo>
236 int readBufferIntern(int16 *buffer,
const int numSamples);
238 void filterResetState();
239 float filterCalculateA0(
int rate,
int cutoff);
int readBuffer(int16 *buffer, const int numSamples)
Definition: audiostream.h:50
int getRate() const
Definition: paula.h:105
bool isStereo() const
Definition: paula.h:103
bool endOfData() const
Definition: paula.h:104
int32 frac_t
Definition: frac.h:52