changeset 295:93cedb9635c1

fix: one-fix for broken mono-sounds $(
author Sam <sam@basx.dev>
date Sat, 24 Jun 2023 23:42:26 +0700
parents f25e9e19b5fa
children b0810305e5d2
files src/semicongine/resources/audio.nim
diffstat 1 files changed, 1 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/semicongine/resources/audio.nim	Sat Jun 24 21:04:13 2023 +0700
+++ b/src/semicongine/resources/audio.nim	Sat Jun 24 23:42:26 2023 +0700
@@ -34,8 +34,6 @@
   else:
     result[1] = result[0]
 
-
-
 # https://en.wikipedia.org/wiki/Au_file_format
 proc readAU*(stream: Stream): Sound =
   var header: AuHeader
@@ -81,8 +79,8 @@
     raise newException(Exception, &"Only support sample rate of {AUDIO_SAMPLE_RATE} Hz but got {sampleRate} Hz, please resample (e.g. ffmpeg -i <infile> -acodec libvorbis -ar {AUDIO_SAMPLE_RATE} <outfile>)")
 
   result = new Sound
-  result[].setLen(int(nSamples))
   if channels == 2:
+    result[].setLen(int(nSamples))
     copyMem(addr result[][0], output, nSamples * sizeof(Sample))
     free(output)
   elif channels == 1: