diff options
Diffstat (limited to 'filter.bqn')
| -rw-r--r-- | filter.bqn | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -59,14 +59,14 @@ Filter ← { _f ← { !∘0⊘(𝔽⊸Filter) } # Compute the frequency response from coefficients -#Response ← ≍○<⟜(1∾-)○⌽´ ⊸ ((|·÷´{+⟜(𝕩⊸×)´𝕨}¨)⎉∞‿0) ⟜ (⋆0i1×Om) +#Response ← ⋈⟜(1∾-)○⌽´ ⊸ ((|·÷´{+⟜(𝕩⊸×)´𝕨}¨)⎉∞‿0) ⟜ (⋆0i1×Om) Om ← (2×π)×{𝕩÷o.freq} Tom ← Tan Om÷2˙ # 1-pole low-pass and high-pass filters -Lp1 ← (⥊¨ ·≍⟜¬ 1+⌾÷Om) _f -Hp1 ← ((-⊸≍ ≍○< ⥊) 1÷∘+Om) _f +Lp1 ← (⋈¨ ·⋈⟜¬ 1+⌾÷Om) _f +Hp1 ← ((-⊸⋈ ⋈ ⋈) 1÷∘+Om) _f # 2-pole *-pass f2types ← "bw"‿"cd"‿"bessel" @@ -78,7 +78,7 @@ Filter2 ← { type‿nPasses‿isHighpass: Clp2 ← { e ← ¯1 ⊑ a ← 𝕨 × ≍⟜(ט) Tom 𝕩 b ← (1‿2‿1 ∾˜ 2×1-˜÷e) × e ÷ 1++´a - ¯3 (↑ ≍○< ↓) (1-+´)⊸∾ b + ¯3 (↑⋈↓) (1-+´)⊸∾ b } (isHighpass ⊑ ⟨ x Clp2 ÷⟜c @@ -91,7 +91,7 @@ Filter2 ← { type‿nPasses‿isHighpass: # Once more, with resonance # Lp2q and Hp2q are identical to Lp2 and Hp2 when Q=÷√2 Resfilt ← { - Om⊸(Sin⊸÷⟜(2⊸×) (+⟜1 ÷˜ 𝕏 ≍○< -⟜1≍2⊸×) Cos∘⊣)´ _f + Om⊸(Sin⊸÷⟜(2⊸×) (+⟜1 ÷˜ 𝕏 ⋈ -⟜1≍2⊸×) Cos∘⊣)´ _f } Lp2q‿Hp2q‿Bp2q ← Resfilt¨ ⟨ 1⊸-÷2‿1‿2˙ , 1⊸+÷2‿¯1‿2˙ , ×⟜1‿0‿¯1 ⟩ @@ -99,7 +99,7 @@ Lp2q‿Hp2q‿Bp2q ← Resfilt¨ ⟨ 1⊸-÷2‿1‿2˙ , 1⊸+÷2‿¯1‿2˙ , Peak ← { g‿f‿q: k ← Tom f ab ← 1‿4‿0‿2‿3‿0 ⊏ +⟜(k⊸×)´¨ ¯2‿0‿2 <⊸∾ {1‿𝕩‿1}¨ ⥊≍⟜- q ÷˜ 10⋆0⌈-⊸≍g÷20 - 3 (↑ ≍○< -∘↓) (1⊸↓ ÷ ⊑) ab + 3 (↑ ⋈ -∘↓) (1⊸↓ ÷ ⊑) ab } _f # Q to bandwidth and vice-versa for peaking filters NtoQ ← {𝕊𝕩: (√÷-⟜1)𝕩 ; 𝕊⁼𝕩: -⟜1⌾(ט)⊸+ 1+÷2×ט𝕩} 2⊸⋆ @@ -111,7 +111,7 @@ Shelf ← { k ← Tom f v1 ← 10 ⋆ t × 0⌈-⊸≍g÷40 ab ← ⥊ 1‿0‿2⊸⊏˘ (ט1⌊v1) ÷˜ (k×v1) {+⟜(𝕨⊸×)´𝕩}⌜ ¯2‿0‿2 <⊸∾ {1‿𝕩‿1}¨ ≍⟜- q - 2 (↓ ≍○<○⌽ -∘↑) (1⊸↓ ÷ ⊑) ab + 2 (↓ ⋈○⌽ -∘↑) (1⊸↓ ÷ ⊑) ab } _f # Shortcuts for low- and high-shelf LShelf ← 1⊸∾⊸Shelf @@ -124,4 +124,4 @@ Notch ← { ⟨1,-c,1⟩‿⟨t-1,c⟩ ÷ 1+t } _f -AllPass ← (≍○<⟜(-∘⌽1⊸↓) ⟨1,¯2×⊑,+´×˜⟩{𝕎𝕩}¨<) _f +AllPass ← (⋈⟜(-∘⌽1⊸↓) ⟨1,¯2×⊑,+´×˜⟩{𝕎𝕩}¨<) _f |
