changeset 752:bcd246da025d

add: check if track is playing
author Sam <sam@basx.dev>
date Mon, 19 Jun 2023 01:14:58 +0700
parents 42e692716e38
children eb5ae1f1bc87
files src/semicongine/audio.nim
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/semicongine/audio.nim	Wed Jun 14 23:31:59 2023 +0700
+++ b/src/semicongine/audio.nim	Mon Jun 19 01:14:58 2023 +0700
@@ -146,6 +146,10 @@
         return true
   return false
 
+proc isPlaying*(mixer: var Mixer, track: string): bool =
+  mixer.lock.withLock():
+    return mixer.tracks.contains(track) and mixer.tracks[track].playing.len > 0
+
 func applyLevel(sample: Sample, levelLeft, levelRight: Level): Sample =
   [int16(float(sample[0]) * levelLeft), int16(float(sample[1]) * levelRight)]