From fd6632e287f82dba7bac7b590647800e29666a58 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Fri, 11 Dec 2020 22:16:31 -0500 Subject: Add Karplus-Stong oscillator --- oscillator.bqn | 6 ++++++ 1 file changed, 6 insertions(+) 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 +} -- cgit v1.2.3