From d3ad5fc663cbbfa4c01fbfbf5cfe6f7df82e7d10 Mon Sep 17 00:00:00 2001 From: Norbert Lange Date: Mon, 8 Jun 2009 18:33:20 +0000 Subject: Initital commit modifying buildsystem and adding a TFMX Module-Player Changes in Paula.cpp/Paula.h + soundfx.cpp: Added (easy) queueing of samples by implementing methods that act similar like writes to the Amiga-Chipset would. Added counting of DMA-Interrupts, that is how often a sample finished playing. Added a base for the interrupt-interval, in most cases this will be the Cia-clockrate. Derived classes can then set the interval without scaling to the samplerate Changes in common/scummsys.h: Only disable warnings with pragmas for MS Compilers that cant do so otherwise. Newer MSVC Versions can and should disable warnings in the Project-Settings. Files in tfmx: Some files for debugging. Wont ever be commited back into trunk so those will contain some messy and hackish code Added: tfmx.h/tfmx.cpp Player for TFMX-Modules. Rest: main.cpp etc. Modified buildsystem to include new directory, modified main.cpp so it calls tfmxmain (tfmxplayer.cpp) instead of starting the GUI. svn-id: r41382 --- sound/mods/paula.h | 74 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 66 insertions(+), 8 deletions(-) (limited to 'sound/mods/paula.h') diff --git a/sound/mods/paula.h b/sound/mods/paula.h index e3c6002451..5e32dc8580 100644 --- a/sound/mods/paula.h +++ b/sound/mods/paula.h @@ -40,12 +40,27 @@ namespace Audio { class Paula : public AudioStream { public: static const int NUM_VOICES = 4; + enum { + kPalSystemClock = 7093790, + kNtscSystemClock = 7159090, + kPalCiaClock = kPalSystemClock / 10, + kNtscCiaClock = kNtscSystemClock / 10 + }; - Paula(bool stereo = false, int rate = 44100, int interruptFreq = 0); + Paula(bool stereo = false, int rate = 44100, uint interruptFreq = 0); ~Paula(); bool playing() const { return _playing; } - void setInterruptFreq(int freq) { _curInt = _intFreq = freq; } + void setTimerBaseValue( uint32 ticksPerSecond ) { _timerBase = ticksPerSecond; } + uint32 getTimerBaseValue() { return _timerBase; } + void setSingleInterrupt(uint sampleDelay) { assert(sampleDelay < _intFreq); _curInt = sampleDelay; } + void setSingleInterruptUnscaled(uint timerDelay) { + setSingleInterrupt((uint)(((double)timerDelay * getRate()) / _timerBase)); + } + void setInterruptFreq(uint sampleDelay) { _intFreq = sampleDelay; _curInt = 0; } + void setInterruptFreqUnscaled(uint timerDelay) { + setInterruptFreq((uint)(((double)timerDelay * getRate()) / _timerBase)); + } void clearVoice(byte voice); void clearVoices() { for (int i = 0; i < NUM_VOICES; ++i) clearVoice(i); } void startPlay(void) { _playing = true; } @@ -65,9 +80,11 @@ protected: uint32 length; uint32 lengthRepeat; int16 period; + int16 periodRepeat; byte volume; frac_t offset; byte panning; // For stereo mixing: 0 = far left, 255 = far right + int dmaCount; }; bool _end; @@ -90,9 +107,24 @@ protected: _voice[channel].panning = panning; } + void disableChannel(byte channel) { + assert(channel < NUM_VOICES); + _voice[channel].data = 0; + } + + void enableChannel(byte channel) { + assert(channel < NUM_VOICES); + Channel &ch = _voice[channel]; + ch.data = ch.dataRepeat; + ch.length = ch.lengthRepeat; + // actually first 2 bytes are dropped? + ch.offset = intToFrac(0); + ch.period = ch.periodRepeat; + } + void setChannelPeriod(byte channel, int16 period) { assert(channel < NUM_VOICES); - _voice[channel].period = period; + _voice[channel].periodRepeat = period; } void setChannelVolume(byte channel, byte volume) { @@ -100,6 +132,17 @@ protected: _voice[channel].volume = volume; } + void setChannelSampleStart(byte channel, const int8 *data) { + assert(channel < NUM_VOICES); + _voice[channel].dataRepeat = data; + } + + void setChannelSampleLen(byte channel, uint32 length) { + assert(channel < NUM_VOICES); + assert(length < 32768/2); + _voice[channel].lengthRepeat = 2 * length; + } + void setChannelData(uint8 channel, const int8 *data, const int8 *dataRepeat, uint32 length, uint32 lengthRepeat, int32 offset = 0) { assert(channel < NUM_VOICES); @@ -110,11 +153,14 @@ protected: assert(lengthRepeat < 32768); Channel &ch = _voice[channel]; - ch.data = data; + + ch.dataRepeat = data; + ch.lengthRepeat = length; + enableChannel(channel); + ch.offset = intToFrac(offset); + ch.dataRepeat = dataRepeat; - ch.length = length; ch.lengthRepeat = lengthRepeat; - ch.offset = intToFrac(offset); } void setChannelOffset(byte channel, frac_t offset) { @@ -128,13 +174,25 @@ protected: return _voice[channel].offset; } + int getChannelDmaCount(byte channel) { + assert(channel < NUM_VOICES); + return _voice[channel].dmaCount; + } + + void setChannelDmaCount(byte channel, int dmaVal = 0) { + assert(channel < NUM_VOICES); + _voice[channel].dmaCount = dmaVal; + } + private: Channel _voice[NUM_VOICES]; const bool _stereo; const int _rate; - int _intFreq; - int _curInt; + const double _periodScale; + uint _intFreq; + uint _curInt; + uint32 _timerBase; bool _playing; template -- cgit v1.2.3