diff options
| -rw-r--r-- | filter.bqn | 16 | ||||
| -rw-r--r-- | mix.bqn | 6 | ||||
| -rw-r--r-- | panap.bqn | 4 | ||||
| -rw-r--r-- | wav.bqn | 8 |
4 files changed, 17 insertions, 17 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 @@ -8,7 +8,7 @@ I ⇐ <⟜0 ⌽∘⊢⍟⊣ ↕⊸÷∘| # Add two signals 𝕨 and 𝕩 or a list of signals 𝕩, # extending to the length of the longest signal. -Add ⇐ +´ ·(⌈´(¯1⊑≢)¨)⊸(↑⎉1¨) ⊢⊘(≍○<) +Add ⇐ +´ ·(⌈´(¯1⊑≢)¨)⊸(↑⎉1¨) ⊢⊘⋈ # Like add, but concatenate instead (no extension). Concat ⇐ (∾ (0⥊˜·⌈´=¨)⊸(<∘⊣↓¨↓)) ⊘ (∾⎉1) # Like ⌽⎉1, but the end of the signal does not wrap around. @@ -38,7 +38,7 @@ Fadefront‿Fadeback ⇐ {𝕊f: {𝕨⊸×⌾((F≠𝕨)↑⊢)𝕩}⎉1 }¨ # 𝕗 is the overlap amount. Fade 𝕨 into 𝕩, linearly. _crossfade ⇐ { - G←↑≍○<↓ + G←↑⋈↓ (-𝕗)⊸G⊸(∾ 1⌽∾˜○(1⊸↓) ∾⟜< (¬⊸≍I𝕗)+˝∘×≍○⊑)⟜(𝕗⊸G)⎉1 } @@ -57,6 +57,6 @@ Reverb ⇐ { k0← ⌈⌾(÷⟜l) k # Rounded up 𝕨 { CW ← ⊏ · (FFT n↑𝕨)⊸M⌾FFT n⊸↑ - {t←0 ⋄ k↑⥊ {r‿s←(-o)(t⊸+⌾(o⊸↑)∘↓≍○<↑)CW𝕩⋄t↩s⋄r}˘ ∘‿l⥊k0↑𝕩}⎉1 𝕩 + {t←0 ⋄ k↑⥊ {r‿s←(-o)(t⊸+⌾(o⊸↑)∘↓⋈↑)CW𝕩⋄t↩s⋄r}˘ ∘‿l⥊k0↑𝕩}⎉1 𝕩 }⎉(1≍1+0⌈-˜○=) 𝕩 } @@ -116,8 +116,8 @@ Get_panap_coeff ← { 𝕊 n‿rr‿f: sv ← (ט ÷ (4×q) + ×⟜((3-r)+2×re)) 1+r-2×re - GetZ ← ⊢ ≍ √∘-⟜(ט) # 𝕩 is real part and 𝕨 is square magnitude - (GetZ○⊑ ≍○< GetZ○(⊑+sv×+´))´ ⟨r‿¯1,re‿1⟩ + GetZ ← ⊢ ⋈ √∘-⟜(ט) # 𝕩 is real part and 𝕨 is square magnitude + (GetZ○⊑ ⋈ GetZ○(⊑+sv×+´))´ ⟨r‿¯1,re‿1⟩ } # --------------------------------------------------------- @@ -83,7 +83,7 @@ _audioConvert ← { maxval←(1-2⋆-m+1)×2⋆(2⋆e)-b+1 { 𝕩 ×↩ 2⋆-m - p‿s ← (2⋆e) (| ≍○< ⌊∘÷˜) ⌊𝕩 + p‿s ← (2⋆e) (| ⋈ ⌊∘÷˜) ⌊𝕩 p +↩ ¬n←0<p (¯1⋆s)×(2⋆p-b) × n+1|𝕩 }_withInv_{ @@ -126,7 +126,7 @@ Decode ← { # Integer from little-endian unsigned bytes ToInt ← 256⊸×⊸+˜´ -⟜@ - hdr‿dat ← wh.len +´⊸(↑ ≍○< ↓) 𝕩 + hdr‿dat ← wh.len +´⊸(↑⋈↓) 𝕩 # Assign field values to field names. hdr ↩ ('i'=wh.typ) ToInt∘⊢⍟⊣¨ wh.len /⊸⊔ hdr @@ -135,7 +135,7 @@ Decode ← { "subchunk1Size is invalid" ! ⊑ 0‿2‿24 ∊˜ se←subchunk1Size-16 If (se>0)‿{𝕤 ! se = 2 + ToInt 2↑subchunk2ID - ext←@ ⋄ ext‿dat ↩ se (↑ ≍○< ↓) dat + ext←@ ⋄ ext‿dat ↩ se (↑⋈↓) dat If (se>2)‿{𝕤 If (audioFormat = 65534)‿{𝕤⋄ audioFormat ↩ ToInt 4↑ext } } @@ -143,7 +143,7 @@ Decode ← { # Ignore remaining subchunks s ← subchunk2Size While {𝕤⋄"data"≢subchunk2ID}‿{𝕤 - subchunk2ID‿s‿dat ↩ (4⊸↑ ≍○< ToInt∘((4+↕4)⊸⊏) ≍○< 8⊸↓) s ↓ dat + subchunk2ID‿s‿dat ↩ (4⊸↑ ⋈ ToInt∘((4+↕4)⊸⊏) ⋈ 8⊸↓) s ↓ dat subchunk2Size +↩ s+8 } # Check that fields match their definitions |
