SoundUnit: add 1-bit PDM rev emulation
This commit is contained in:
parent
fcb8fba77b
commit
976e193309
4 changed files with 53 additions and 8 deletions
|
|
@ -300,12 +300,46 @@ void SoundUnit::NextSample(short* l, short* r) {
|
|||
}
|
||||
}
|
||||
|
||||
*l=minval(32767,maxval(-32767,tnsL));
|
||||
*r=minval(32767,maxval(-32767,tnsR));
|
||||
if (dsOut) {
|
||||
tnsL=minval(32767,maxval(-32767,tnsL<<1));
|
||||
tnsR=minval(32767,maxval(-32767,tnsR<<1));
|
||||
|
||||
short accumL=0;
|
||||
short accumR=0;
|
||||
|
||||
for (int i=0; i<4; i++) {
|
||||
if ((tnsL>>8)==0 && dsCounterL>0) dsCounterL=0;
|
||||
dsCounterL+=tnsL>>8;
|
||||
if (dsCounterL>=0) {
|
||||
accumL+=4095;
|
||||
dsCounterL-=127;
|
||||
} else {
|
||||
accumL+=-4095;
|
||||
dsCounterL+=127;
|
||||
}
|
||||
|
||||
if ((tnsR>>8)==0 && dsCounterR>0) dsCounterR=0;
|
||||
dsCounterR+=tnsR>>8;
|
||||
if (dsCounterR>=0) {
|
||||
accumR+=4095;
|
||||
dsCounterR-=127;
|
||||
} else {
|
||||
accumR+=-4095;
|
||||
dsCounterR+=127;
|
||||
}
|
||||
}
|
||||
|
||||
*l=accumL;
|
||||
*r=accumR;
|
||||
} else {
|
||||
*l=minval(32767,maxval(-32767,tnsL));
|
||||
*r=minval(32767,maxval(-32767,tnsR));
|
||||
}
|
||||
}
|
||||
|
||||
void SoundUnit::Init(int sampleMemSize) {
|
||||
void SoundUnit::Init(int sampleMemSize, bool dsOutMode) {
|
||||
pcmSize=sampleMemSize;
|
||||
dsOut=dsOutMode;
|
||||
Reset();
|
||||
memset(pcm,0,pcmSize);
|
||||
for (int i=0; i<256; i++) {
|
||||
|
|
@ -346,6 +380,8 @@ void SoundUnit::Reset() {
|
|||
oldflags[i]=0;
|
||||
pcmdec[i]=0;
|
||||
}
|
||||
dsCounterL=0;
|
||||
dsCounterR=0;
|
||||
tnsL=0;
|
||||
tnsR=0;
|
||||
ilBufPos=0;
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ class SoundUnit {
|
|||
unsigned short oldfreq[8];
|
||||
unsigned short oldflags[8];
|
||||
unsigned int pcmSize;
|
||||
bool dsOut;
|
||||
short dsCounterL, dsCounterR;
|
||||
public:
|
||||
unsigned short resetfreq[8];
|
||||
unsigned short voldcycles[8];
|
||||
|
|
@ -99,7 +101,7 @@ class SoundUnit {
|
|||
if (ret>32767) ret=32767;
|
||||
return ret;
|
||||
}
|
||||
void Init(int sampleMemSize=8192);
|
||||
void Init(int sampleMemSize=8192, bool dsOutMode=false);
|
||||
void Reset();
|
||||
SoundUnit();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -596,7 +596,7 @@ void DivPlatformSoundUnit::setFlags(unsigned int flags) {
|
|||
|
||||
sampleMemSize=flags&16;
|
||||
|
||||
su->Init(sampleMemSize?65536:8192);
|
||||
su->Init(sampleMemSize?65536:8192,flags&32);
|
||||
renderSamples();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue