blob: 15feef5eef843b370d61c41fb78f1a1fc5784be0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
# Utilities for working with notes and scales
# A minor scale goes up two fifths and down four from the root
minor ← ∧12|7×2-↕7
# Transpose frequency 𝕩 up 𝕨 semitones.
Trans ⇐ (2 ⋆ ÷⟜12)⊸×
# Frequency from note in roughly scientific pitch notation
# e.g. C#, A4, Gb2, F##
Oct ← ⊑'4'-˜('0'⊸≤∧≤⟜'9')⊸/∾"3"˙ # Default to 3 to hit middle C
Note ⇐ (minor⊑˜'a'(⊢-≤◶'A'‿⊣)⊑) (+´⟜(-˝"#b"=⌜⊢) Trans 440×2⋆Oct∘⊢) 1⊸↓
# Nearest note from frequency
names ← ('A'⊸+ ∾⟜(/⟜"#")¨ ⊒) /12⊸«⊸-minor
FromFreq ⇐ 12 ((names⊑˜|) ∾ '4'+⌊∘÷˜) 0.5 ⌊∘+ Trans⟜440⁼
|