aboutsummaryrefslogtreecommitdiff
path: root/musiclib.nim
diff options
context:
space:
mode:
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)