§ I.5 · The CLI Workshop · No. XI
Microtonality
Scaler.
After Blackwood 1985 · Xenakis 1971
Reads MIDI numbers from stdin, retunes them to a specified tuning system — edo, just intonation, cents, meantone — and writes the resulting frequencies in Hz to stdout, four decimals. Rationals are stored exactly via a small BigInt helper, converted to float only at the boundary. A pocket retuning lab for the corpus.
¶ Why a command line
Composers and ethnomusicologists working with non-12-TET systems need to translate melodies between tuning spaces — "what are these MIDI pitches in 31-EDO?", or "scale this melody to 5-limit just intonation?" The command answers both in a single line: node 02-scaler.js --tuning=edo:31 < melody.txt. Output is plain Hz, suitable for a synthesiser, a CSV, or a frequency-domain analysis script.
¶ Invocation
$ node 02-scaler.js --tuning=edo:31 < midi-pitches.txt $ echo "60 62 64 65 67" | node 02-scaler.js --tuning=ji:1/1,9/8,5/4,4/3,3/2 $ node 02-scaler.js --tuning=meantone:1/4 --ref=440 < chorale.txt $ echo "60 64 67" | node 02-scaler.js --tuning=cents:0,386.31,701.96
¶ Sample output
261.6256 293.6648 329.6276 349.2282 391.9954
¶ Scope
input whitespace-delimited MIDI integers (0..127) on stdin / file
tuning --tuning=edo:N N equal divisions of the octave
--tuning=ji:p1/q1,p2/q2 sparse just intonation, anchored to
the nearest 12-edo semitone within
the octave; uncovered degrees fall
back to 12-edo
--tuning=cents:c1,c2,… same anchoring, in cents from 1/1
--tuning=meantone:p/q twelve fifths tempered by p/q of the
syntonic comma 81/80; wolf falls
between G# and Eb
flags --ref=Hz A4 anchor frequency (default 440)
output Hz, four decimals, one per line. C (MIDI 60) is the 1/1 anchor
for ji / cents / meantone modes.
¶ References
- Blackwood, Easley. The Structure of Recognizable Diatonic Tunings. Princeton: Princeton University Press, 1986. — the taxonomy of interval ratios that grounds the tuning mini-language.
- Xenakis, Iannis. Formalized Music: Thought and Mathematics in Composition. Bloomington: Indiana University Press, 1971; rev. ed. 1992.
¶ Source
loading source…