aboutsummaryrefslogtreecommitdiff
path: root/musiclib.nim
diff options
context:
space:
mode:
authorLocria Cyber2023-03-12 17:34:15 +0000
committerLocria Cyber2023-03-12 17:38:37 +0000
commit5fe21ce19c52326c79c1fe09000218af66f386c5 (patch)
tree6cb784f57089c968cff254b1930be8cbec874343 /musiclib.nim
parentba6e3c375728eff3510e877f594653a5e373fc5c (diff)
Add OSC with dubious construction
Diffstat (limited to 'musiclib.nim')
-rw-r--r--musiclib.nim11
1 files changed, 9 insertions, 2 deletions
diff --git a/musiclib.nim b/musiclib.nim
index 91e63c4..c21cb95 100644
--- a/musiclib.nim
+++ b/musiclib.nim
@@ -1,4 +1,4 @@
-import std/[algorithm, math, sugar, strformat]
+import std/[algorithm, math, sugar, strformat, logging]
type
OscFn* = proc (f: float, t: float): float
@@ -65,4 +65,11 @@ proc at*(music: openArray[ProcessedNote], t: float): int32 =
ret *= GAIN_BIAS
# clip sample
- clamp(ret, int32.low.float..int32.high.float).int32
+ if ret >= int32.high.float:
+ warn(&"audio clipping at t={t}")
+ int32.high
+ elif ret <= int32.low.float:
+ warn(&"audio clipping at t={t}")
+ int32.low
+ else:
+ int32(ret)