changes to sample rate storage

as of now we store and use the actual sample rate as opposed to an index
fo a fixed rate table.

this allows for more flexibility in a future file format...
This commit is contained in:
tildearrow 2021-12-23 18:04:44 -05:00
parent 830e880a57
commit 7ba8607270
9 changed files with 66 additions and 49 deletions

View file

@ -9,9 +9,6 @@ static unsigned short chanOffs[8]={
static unsigned short opOffs[4]={
0x00, 0x08, 0x10, 0x18
};
static int pcmRates[6]={
65,65,90,131,180,255
};
static bool isOutput[8][4]={
// 1 3 2 4
{false,false,false,true},
@ -217,7 +214,7 @@ int DivPlatformArcade::dispatch(DivCommand c) {
break;
}
chan[c.chan].pcm.pos=0;
chan[c.chan].pcm.freq=pcmRates[parent->song.sample[chan[c.chan].pcm.sample]->rate];
chan[c.chan].pcm.freq=MIN(255,(parent->song.sample[chan[c.chan].pcm.sample]->rate*255)/31250);
break;
}
DivInstrument* ins=parent->getIns(chan[c.chan].ins);

View file

@ -5,9 +5,6 @@
#include "genesisshared.h"
static int dacRates[6]={
160,160,116,80,58,40
};
static unsigned char konOffs[6]={
0, 1, 2, 4, 5, 6
};
@ -179,7 +176,7 @@ int DivPlatformGenesis::dispatch(DivCommand c) {
}
dacPos=0;
dacPeriod=0;
dacRate=dacRates[parent->song.sample[dacSample]->rate];
dacRate=1280000/parent->song.sample[dacSample]->rate;
break;
}
DivInstrument* ins=parent->getIns(chan[c.chan].ins);

View file

@ -37,10 +37,6 @@ void DivPlatformNES::acquire(short* bufL, short* bufR, size_t start, size_t len)
}
}
static int dacRates[6]={
4000, 8000, 11025, 16000, 22050, 32000
};
static unsigned char noiseTable[256]={
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 4,
15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4,
@ -170,7 +166,7 @@ int DivPlatformNES::dispatch(DivCommand c) {
}
dacPos=0;
dacPeriod=0;
dacRate=dacRates[parent->song.sample[dacSample]->rate];
dacRate=parent->song.sample[dacSample]->rate;
break;
} else if (c.chan==3) { // noise
chan[c.chan].baseFreq=c.value;

View file

@ -76,10 +76,6 @@ static unsigned char noiseFreq[12]={
4,13,15,18,21,23,25,27,29,31,0,2
};
static int dacRates[6]={
224,224,162,112,81,56
};
void DivPlatformPCE::tick() {
for (int i=0; i<6; i++) {
chan[i].std.next();
@ -149,7 +145,7 @@ int DivPlatformPCE::dispatch(DivCommand c) {
}
chan[c.chan].dacPos=0;
chan[c.chan].dacPeriod=0;
chan[c.chan].dacRate=dacRates[parent->song.sample[chan[c.chan].dacSample]->rate];
chan[c.chan].dacRate=1789773/parent->song.sample[chan[c.chan].dacSample]->rate;
break;
}
chan[c.chan].baseFreq=round(FREQ_BASE/pow(2.0f,((float)c.value/12.0f)));