SoundUnit: actually finish it
This commit is contained in:
parent
e0c5029769
commit
6934a499c1
4 changed files with 90 additions and 16 deletions
|
|
@ -238,44 +238,65 @@ void SoundUnit::NextSample(short* l, short* r) {
|
|||
tnsL=(nsL[0]+nsL[1]+nsL[2]+nsL[3]+nsL[4]+nsL[5]+nsL[6]+nsL[7])>>2;
|
||||
tnsR=(nsR[0]+nsR[1]+nsR[2]+nsR[3]+nsR[4]+nsR[5]+nsR[6]+nsR[7])>>2;
|
||||
|
||||
IL1=minval(32767,maxval(-32767,tnsL))>>8;
|
||||
IL2=minval(32767,maxval(-32767,tnsR))>>8;
|
||||
|
||||
// write input lines to sample memory
|
||||
if (ILSIZE&64) {
|
||||
if (++ilBufPeriod>=((1+(FIL1>>4))<<2)) {
|
||||
ilBufPeriod=0;
|
||||
unsigned short ilLowerBound=pcmSize-((1+(ILSIZE&63))<<7);
|
||||
short next;
|
||||
if (ilBufPos<ilLowerBound) ilBufPos=ilLowerBound;
|
||||
switch (ILCTRL&3) {
|
||||
case 0:
|
||||
ilFeedback0=ilFeedback1=pcm[ilBufPos];
|
||||
pcm[ilBufPos]=IL0+((pcm[ilBufPos]*(FIL1&15))>>4);
|
||||
next=((signed char)IL0)+((pcm[ilBufPos]*(FIL1&15))>>4);
|
||||
if (next<-128) next=-128;
|
||||
if (next>127) next=127;
|
||||
pcm[ilBufPos]=next;
|
||||
if (++ilBufPos>=pcmSize) ilBufPos=ilLowerBound;
|
||||
break;
|
||||
case 1:
|
||||
ilFeedback0=ilFeedback1=pcm[ilBufPos];
|
||||
pcm[ilBufPos]=IL1+((pcm[ilBufPos]*(FIL1&15))>>4);
|
||||
next=((signed char)IL1)+((pcm[ilBufPos]*(FIL1&15))>>4);
|
||||
if (next<-128) next=-128;
|
||||
if (next>127) next=127;
|
||||
pcm[ilBufPos]=next;
|
||||
if (++ilBufPos>=pcmSize) ilBufPos=ilLowerBound;
|
||||
break;
|
||||
case 2:
|
||||
ilFeedback0=ilFeedback1=pcm[ilBufPos];
|
||||
pcm[ilBufPos]=IL2+((pcm[ilBufPos]*(FIL1&15))>>4);
|
||||
next=((signed char)IL2)+((pcm[ilBufPos]*(FIL1&15))>>4);
|
||||
if (next<-128) next=-128;
|
||||
if (next>127) next=127;
|
||||
pcm[ilBufPos]=next;
|
||||
if (++ilBufPos>=pcmSize) ilBufPos=ilLowerBound;
|
||||
break;
|
||||
case 3:
|
||||
ilFeedback0=pcm[ilBufPos];
|
||||
pcm[ilBufPos]=IL1+((pcm[ilBufPos]*(FIL1&15))>>4);
|
||||
next=((signed char)IL1)+((pcm[ilBufPos]*(FIL1&15))>>4);
|
||||
if (next<-128) next=-128;
|
||||
if (next>127) next=127;
|
||||
pcm[ilBufPos]=next;
|
||||
if (++ilBufPos>=pcmSize) ilBufPos=ilLowerBound;
|
||||
ilFeedback1=pcm[ilBufPos];
|
||||
pcm[ilBufPos]=IL2+((pcm[ilBufPos]*(FIL1&15))>>4);
|
||||
next=((signed char)IL2)+((pcm[ilBufPos]*(FIL1&15))>>4);
|
||||
if (next<-128) next=-128;
|
||||
if (next>127) next=127;
|
||||
pcm[ilBufPos]=next;
|
||||
if (++ilBufPos>=pcmSize) ilBufPos=ilLowerBound;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ILSIZE&128) {
|
||||
tnsL+=ilFeedback1*(signed char)FILVOL;
|
||||
tnsR+=ilFeedback0*(signed char)FILVOL;
|
||||
} else {
|
||||
tnsL+=ilFeedback0*(signed char)FILVOL;
|
||||
tnsR+=ilFeedback1*(signed char)FILVOL;
|
||||
if (ILCTRL&4) {
|
||||
if (ILSIZE&128) {
|
||||
tnsL+=ilFeedback1*(signed char)FILVOL;
|
||||
tnsR+=ilFeedback0*(signed char)FILVOL;
|
||||
} else {
|
||||
tnsL+=ilFeedback0*(signed char)FILVOL;
|
||||
tnsR+=ilFeedback1*(signed char)FILVOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue