Skip to content

Commit 2ab7a72

Browse files
committed
Quick fix for noise channel divide-by-zero
1 parent a35caac commit 2ab7a72

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

audio.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,12 @@ void update_noise(void){
252252
struct chan* c = chans + 3;
253253
if(!c->powered) return;
254254

255-
float freq = 4194304.0f / (float)((int[]){ 8, 16, 32, 48, 64, 80, 96, 112 }[c->lfsr_div] << c->freq);
256-
set_note_freq(c, c->freq < 14 ? freq : 0.0f);
255+
float freq = 4194304.0f / (float)((size_t[]){ 8, 16, 32, 48, 64, 80, 96, 112 }[c->lfsr_div] << (size_t)c->freq);
256+
set_note_freq(c, freq);
257+
258+
if(c->freq >= 14){
259+
c->enabled = false;
260+
}
257261

258262
for(int i = 0; i < nsamples; i+=2){
259263
update_len(c);

0 commit comments

Comments
 (0)