Amiga: filter emulation
This commit is contained in:
parent
b514ee30da
commit
154ef3f9a3
6 changed files with 61 additions and 8 deletions
|
|
@ -63,10 +63,20 @@ const char** DivPlatformAmiga::getRegisterSheet() {
|
|||
return regCheatSheetAmiga;
|
||||
}
|
||||
|
||||
const char* DivPlatformAmiga::getEffectName(unsigned char effect) {
|
||||
switch (effect) {
|
||||
case 0x10:
|
||||
return "10xx: Toggle filter (0 disables; 1 enables)";
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void DivPlatformAmiga::acquire(short* bufL, short* bufR, size_t start, size_t len) {
|
||||
static int outL, outR;
|
||||
for (size_t h=start; h<start+len; h++) {
|
||||
bufL[h]=0;
|
||||
bufR[h]=0;
|
||||
outL=0;
|
||||
outR=0;
|
||||
for (int i=0; i<4; i++) {
|
||||
if (chan[i].sample>=0 && chan[i].sample<parent->song.sampleLen) {
|
||||
chan[i].audSub-=AMIGA_DIVIDER;
|
||||
|
|
@ -102,14 +112,20 @@ void DivPlatformAmiga::acquire(short* bufL, short* bufR, size_t start, size_t le
|
|||
}
|
||||
if (!isMuted[i]) {
|
||||
if (i==0 || i==3) {
|
||||
bufL[h]+=((chan[i].audDat*chan[i].outVol)*sep1)>>7;
|
||||
bufR[h]+=((chan[i].audDat*chan[i].outVol)*sep2)>>7;
|
||||
outL+=((chan[i].audDat*chan[i].outVol)*sep1)>>7;
|
||||
outR+=((chan[i].audDat*chan[i].outVol)*sep2)>>7;
|
||||
} else {
|
||||
bufL[h]+=((chan[i].audDat*chan[i].outVol)*sep2)>>7;
|
||||
bufR[h]+=((chan[i].audDat*chan[i].outVol)*sep1)>>7;
|
||||
outL+=((chan[i].audDat*chan[i].outVol)*sep2)>>7;
|
||||
outR+=((chan[i].audDat*chan[i].outVol)*sep1)>>7;
|
||||
}
|
||||
}
|
||||
}
|
||||
filter[0][0]+=(filtConst*(outL-filter[0][0]))>>12;
|
||||
filter[0][1]+=(filtConst*(filter[0][0]-filter[0][1]))>>12;
|
||||
filter[1][0]+=(filtConst*(outR-filter[1][0]))>>12;
|
||||
filter[1][1]+=(filtConst*(filter[1][0]-filter[1][1]))>>12;
|
||||
bufL[h]=filter[0][1];
|
||||
bufR[h]=filter[1][1];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -299,6 +315,10 @@ int DivPlatformAmiga::dispatch(DivCommand c) {
|
|||
chan[c.chan].audPos=c.value;
|
||||
chan[c.chan].setPos=true;
|
||||
break;
|
||||
case DIV_CMD_AMIGA_FILTER:
|
||||
filterOn=c.value;
|
||||
filtConst=filterOn?filtConstOn:filtConstOff;
|
||||
break;
|
||||
case DIV_CMD_GET_VOLMAX:
|
||||
return 64;
|
||||
break;
|
||||
|
|
@ -332,7 +352,11 @@ void* DivPlatformAmiga::getChanState(int ch) {
|
|||
void DivPlatformAmiga::reset() {
|
||||
for (int i=0; i<4; i++) {
|
||||
chan[i]=DivPlatformAmiga::Channel();
|
||||
filter[0][i]=0;
|
||||
filter[1][i]=0;
|
||||
}
|
||||
filterOn=false;
|
||||
filtConst=filterOn?filtConstOn:filtConstOff;
|
||||
}
|
||||
|
||||
bool DivPlatformAmiga::isStereo() {
|
||||
|
|
@ -372,6 +396,13 @@ void DivPlatformAmiga::setFlags(unsigned int flags) {
|
|||
sep2=127-((flags>>8)&127);
|
||||
amigaModel=flags&2;
|
||||
bypassLimits=flags&4;
|
||||
if (amigaModel) {
|
||||
filtConstOff=4000;
|
||||
filtConstOn=sin(M_PI*8000.0/(double)rate)*4096.0;
|
||||
} else {
|
||||
filtConstOff=sin(M_PI*16000.0/(double)rate)*4096.0;
|
||||
filtConstOn=sin(M_PI*5500.0/(double)rate)*4096.0;
|
||||
}
|
||||
}
|
||||
|
||||
int DivPlatformAmiga::init(DivEngine* p, int channels, int sugRate, unsigned int flags) {
|
||||
|
|
|
|||
|
|
@ -68,6 +68,11 @@ class DivPlatformAmiga: public DivDispatch {
|
|||
bool isMuted[4];
|
||||
bool bypassLimits;
|
||||
bool amigaModel;
|
||||
bool filterOn;
|
||||
|
||||
int filter[2][4];
|
||||
int filtConst;
|
||||
int filtConstOff, filtConstOn;
|
||||
|
||||
int sep1, sep2;
|
||||
|
||||
|
|
@ -88,6 +93,7 @@ class DivPlatformAmiga: public DivDispatch {
|
|||
void notifyWaveChange(int wave);
|
||||
void notifyInsDeletion(void* ins);
|
||||
const char** getRegisterSheet();
|
||||
const char* getEffectName(unsigned char effect);
|
||||
int init(DivEngine* parent, int channels, int sugRate, unsigned int flags);
|
||||
void quit();
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue