clamp wave data

issue #267
This commit is contained in:
tildearrow 2022-03-11 16:58:43 -05:00
parent 5fadcf4891
commit ab3884e5aa
4 changed files with 20 additions and 6 deletions

View file

@ -119,8 +119,12 @@ void DivPlatformSwan::updateWave(int ch) {
}
} else {
for (int i=0; i<16; i++) {
unsigned char nibble1=(wt->data[(i*2)*wt->len/32]*15)/wt->max;
unsigned char nibble2=(wt->data[(1+i*2)*wt->len/32]*15)/wt->max;
int nibble1=(wt->data[(i*2)*wt->len/32]*15)/wt->max;
int nibble2=(wt->data[(1+i*2)*wt->len/32]*15)/wt->max;
if (nibble1<0) nibble1=0;
if (nibble1>15) nibble1=15;
if (nibble2<0) nibble2=0;
if (nibble2>15) nibble2=15;
rWrite(addr+i,nibble1|(nibble2<<4));
}
}