Browse code

(audio.c) Default duration is sample length

neauoire authored on 20/10/2023 15:51:17
Showing 1 changed files
... ...
@@ -108,7 +108,7 @@ env_off(Envelope *env) {
108 108
 void
109 109
 note_on(AudioChannel *channel, Uint16 duration, Uint8 *data, Uint16 len, Uint8 vol,
110 110
         Uint8 attack, Uint8 decay, Uint8 sustain, Uint8 release, Uint8 pitch, bool loop) {
111
-    channel->duration = duration;
111
+    channel->duration = duration > 0 ? duration : len / 44.1f;
112 112
     channel->vol_l = (vol >> 4) / 15.0f;
113 113
     channel->vol_r = (vol & 0xf) / 15.0f;
114 114