diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-12-11 22:16:31 -0500 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-12-11 22:16:31 -0500 |
| commit | fd6632e287f82dba7bac7b590647800e29666a58 (patch) | |
| tree | de86cafbe6bc4f12cb2026fccab9b583711f36e8 | |
| parent | 5221259f777ff1abd83d0f0e806bc289ae860977 (diff) | |
Add Karplus-Stong oscillator
| -rw-r--r-- | oscillator.bqn | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/oscillator.bqn b/oscillator.bqn index 8df742d..3531a76 100644 --- a/oscillator.bqn +++ b/oscillator.bqn @@ -30,3 +30,9 @@ Brown ⇐ +` White # Brown noise # Pink noise #Pink ⇐ ÷⟜(⌈´|) (2⊸/⊸+˜´∘⌽ · Rand¨ 2⋆↕)⊸÷∘(1+·⌈2⋆⁼⊢)⊸(↑˜)∘≠ Pink ⇐ ÷⟜(⌈´|) (+` ·⥊∘⍉∘≍´ ·-⟜«∘Rand¨ 2⋆1⌈⌽∘↕)∘(1+·⌈2⋆⁼⊢)⊸(↑˜)∘≠ + +# Karplus-Stong algorithm for a plucked string +Pluck ⇐ { 𝕊 f‿len‿att: # Frequency, length, attenuation + p ← ⌊o.freq÷f + ∾ ((÷2×16⋆att÷p)×1⊸⌽⊸+)⍟(↕⌈len÷p) Pink p⥊0 +} |
