aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2021-02-18 21:39:57 -0500
committerMarshall Lochbaum <mwlochbaum@gmail.com>2021-02-18 21:50:25 -0500
commit5643af00cc8922d94b91b53b37ba4a42eaa0d07c (patch)
tree06a110ddf8e5ad915d9f2aee33f3a929e847f0c0
parentfc71ae905f997d5650ece1be804f8f3ba13f718b (diff)
Clipping functionality
-rw-r--r--mix.bqn8
1 files changed, 8 insertions, 0 deletions
diff --git a/mix.bqn b/mix.bqn
index 1ad248f..21172c0 100644
--- a/mix.bqn
+++ b/mix.bqn
@@ -24,6 +24,14 @@ Stereo ⇐ β‰ΛœβŸ(2>=)
# Pan signal 𝕩 to position 𝕨, where 0 is hard left and 1 is hard right
Pan ⇐ (25βŒŠβˆ˜Γ—β‰βŸœΒ¬βˆ˜βŠ£) β₯ŠβŸœ0⊸»˘ ((=βŒœΛœβ†•2)-Β·(Γ—Γ—βŒœ0⊸⌈)Β·β‰βŸœ-1-˜2Γ—βŠ£)⊸(+Λβˆ˜Γ—βŽ‰Β―1β€Ώβˆž)⟜Stereo
+# Clipping functions clip to [Β―1,1] by default
+# _norm changes this to match the format if it's an integer format
+_norm ⇐ { (π•¨π”½βŠ’)⌾(÷⟜(2⋆1-˜¯1βŠ‘o.fmt)) 𝕩 }
+# Clip signal 𝕩 to the maximum possible range.
+Clip ⇐ 1⌊¯1⌈⊒
+# 𝕨 is an integer giving "sharpness". Perform a soft clip.
+Softclip ⇐ { ÷⟜(1⊸+⌾(β‹†βŸœ(2β‹†π•¨βŠ£3))) 𝕩 }
+
# Multiply leading or trailing samples of 𝕩 by 𝕨.
Fadefrontβ€ΏFadeback ⇐ {π•Šf: {π•¨βŠΈΓ—βŒΎ((F≠𝕨)β†‘βŠ’)𝕩}βŽ‰1 }Β¨ βŠ’β€Ώ-