diff --git a/reSID.cpp b/reSID.cpp index b532289..5d8f468 100644 --- a/reSID.cpp +++ b/reSID.cpp @@ -27,16 +27,14 @@ #include "reSID.h" #include -#define OVERSAMPLE 23 - -static SID sid; +#define SAMPLERATE 44118 +#define CLOCKFREQ (22.5 * SAMPLERATE) //nearest int to 985248 void AudioPlaySID::begin(void) { + sidptr = &sid; this->reset(); - sid.set_sampling_parameters(OVERSAMPLE * AUDIO_SAMPLE_RATE_EXACT, SAMPLE_FAST, AUDIO_SAMPLE_RATE_EXACT); - //sid.set_chip_model(MOS6581); - //sid.set_chip_model(MOS8580); + sid.set_sampling_parameters(CLOCKFREQ, SAMPLE_FAST, SAMPLERATE); playing = true; } @@ -52,13 +50,7 @@ void AudioPlaySID::stop(void) __enable_irq(); } -//inline -void AudioPlaySID::setreg(int ofs, int val) { - sid.write(ofs, val); -} - void AudioPlaySID::update(void) { -unsigned int i; audio_block_t *block; // only update if we're playing @@ -67,11 +59,11 @@ unsigned int i; // allocate the audio blocks to transmit block = allocate(); if (block == NULL) return; - - for (i=0; i< AUDIO_BLOCK_SAMPLES; i++) { - sid.clock(OVERSAMPLE); - block->data[i] = sid.output(); - } + + //I'm not 100% if this is correct: + cycle_count delta_t = CLOCKFREQ / (SAMPLERATE / AUDIO_BLOCK_SAMPLES); + + sidptr->clock(delta_t, (short int*)block->data, AUDIO_BLOCK_SAMPLES); transmit(block); release(block); diff --git a/reSID.h b/reSID.h index 784b4bf..b9c0e05 100644 --- a/reSID.h +++ b/reSID.h @@ -36,14 +36,15 @@ class AudioPlaySID : public AudioStream public: AudioPlaySID(void) : AudioStream(0, NULL) { begin(); } void begin(void); - //inline - void setreg(int ofs, int val);// { sid.write(ofs, val);} + inline void setreg(int ofs, int val) { sid.write(ofs, val); } void reset(void); void stop(void); - bool isPlaying(void) { return playing; } + inline bool isPlaying(void) { return playing; } private: volatile bool playing; virtual void update(void); + SID sid; + SID* sidptr; }; diff --git a/sid.h b/sid.h index 9d017c2..f2bc354 100644 --- a/sid.h +++ b/sid.h @@ -11,7 +11,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this library. If not, see . - The helix decoder itself as a different license, look at the subdirectories for more info. + Diese Bibliothek ist freie Software: Sie können es unter den Bedingungen der GNU General Public License, wie von der Free Software Foundation, Version 3 der Lizenz oder (nach Ihrer Wahl) jeder neueren @@ -22,8 +22,7 @@ Siehe die GNU General Public License für weitere Details. Sie sollten eine Kopie der GNU General Public License zusammen mit diesem Programm erhalten haben. Wenn nicht, siehe . - Der Helixdecoder selbst hat eine eigene Lizenz, bitte für mehr Informationen - in den Unterverzeichnissen nachsehen. + */ #include "reSID/sid.h"