Musicology·A Field Guide

§ I.5 · The CLI Workshop · No. X

Interval-Class
Histogram.

After Forte 1973 · cf. Lewin 1959

Reads a pitch-class inventory — one pitch per token, in MIDI numbers (0–127) or note-names (C4, D♯5, B♭3) — and computes the complete interval-class distribution. Outputs the six-place Forte vector [ic1 ic2 ic3 ic4 ic5 ic6], pitch-class cardinality, and an optional ASCII histogram. The set theorist's first move, automated for the corpus.

Why a command line

Researchers profiling pitch-class content across digital corpora — a Webern opus, a twelve-tone row library, an atonal archive — need to compute interval vectors at scale. The tool reads stdin and writes structured fields, so the typical workflow is a one-liner: cat pitches.txt | node 01-interval-histogram.js. Pipe the output through grep cardinality, sort, or your favourite analysis script.

Invocation

$ node 01-interval-histogram.js < pitches.txt
$ echo "C4 E4 G4 B4" | node 01-interval-histogram.js --histogram
$ cat row-database.txt | node 01-interval-histogram.js | tee analysis.txt

Sample output

cardinality: 7
interval-vector: [2 5 4 3 6 1]

ic1: ##
ic2: #####
ic3: ####
ic4: ###
ic5: ######
ic6: #

Scope

input        whitespace-delimited tokens on stdin or in a file path argument
             — note names      C4, D#5, Bb3, F##4 (sharp = #, flat = b)
             — MIDI integers   0..127

flags        --histogram       append an ASCII bar chart for ic1..ic6
             --no-vector       suppress the [..] line
             --strict          error on duplicate pitch classes

output       a cardinality line, a six-place interval-class vector, and
             an optional histogram. plain text, suitable for piping.

References

Source

cli/01-interval-histogram.js ↗ raw
loading source…
← Back to the CLI workshop