Allow to modify the samplerate

master
Frank Bösing 8 years ago
parent 4496925ab3
commit a710912443
  1. 18
      reSID.cpp
  2. 3
      reSID.h
  3. 2
      reSID/wave.h

@ -27,17 +27,23 @@
#include "reSID.h"
#include <AudioStream.h>
#define SAMPLERATE 44118
#define CLOCKFREQ (22.5 * SAMPLERATE) //nearest int to 985248
#define SAMPLERATE AUDIO_SAMPLE_RATE_EXACT
#define CLOCKFREQ 985248
void AudioPlaySID::begin(void)
{
sidptr = &sid;
this->reset();
sid.set_sampling_parameters(CLOCKFREQ, SAMPLE_FAST, SAMPLERATE);
setSampleParameters(CLOCKFREQ, SAMPLERATE);
playing = true;
}
void AudioPlaySID::setSampleParameters(unsigned clockfreq, unsigned samplerate) {
sid.set_sampling_parameters(clockfreq, SAMPLE_FAST, samplerate);
csdelta = round((float)clockfreq / ((float)samplerate / AUDIO_BLOCK_SAMPLES));
}
void AudioPlaySID::reset(void)
{
sid.reset();
@ -59,9 +65,9 @@ void AudioPlaySID::update(void) {
// allocate the audio blocks to transmit
block = allocate();
if (block == NULL) return;
//I'm not 100% if this is correct:
cycle_count delta_t = CLOCKFREQ / (SAMPLERATE / AUDIO_BLOCK_SAMPLES);
//cycle_count delta_t = CLOCKFREQ / (SAMPLERATE / AUDIO_BLOCK_SAMPLES);
cycle_count delta_t = csdelta;
sidptr->clock(delta_t, (short int*)block->data, AUDIO_BLOCK_SAMPLES);

@ -36,11 +36,14 @@ class AudioPlaySID : public AudioStream
public:
AudioPlaySID(void) : AudioStream(0, NULL) { begin(); }
void begin(void);
void setSampleParameters(unsigned clockfreq, unsigned samplerate);
inline void setreg(int ofs, int val) { sid.write(ofs, val); }
inline uint8_t getreg(int ofs) { return sid.read(ofs); }
void reset(void);
void stop(void);
inline bool isPlaying(void) { return playing; }
private:
cycle_count csdelta;
volatile bool playing;
virtual void update(void);
SID sid;

@ -267,7 +267,7 @@ reg12 WaveformGenerator::output___T()
{
reg24 msb = (ring_mod ? accumulator ^ sync_source->accumulator : accumulator)
& 0x800000;
return ((msb ? ~accumulator : accumulator) >> 11) & 0xfff;
return ((msb ? ~accumulator : accumulator) >> 11) & 0xffe;
}
// Sawtooth:

Loading…
Cancel
Save