MIDI file scale generator

I’m a bit old-fashioned. I wrote a “scale” generator way back when so I could play a MIDI file of a Major/minor scale sequence.

These days I use “MIDIplayer X” to play my scales. The classic ‘t2mf’ is used to create the MIDI file from a shell script…

 
#!/bin/bash
# SCALE="C" SCALEM="a" N1=60

let N1=N1+0
let N2=N1+2
let N3=N1+4
let N4=N1+5
let N5=N1+7
let N6=N1+9
let N7=N1+11
let N8=N1+12

let NM1=N1-3
let NM2=N1-1

cat >$SCALE-$SCALEM.txt <<EOF
MFile 0 1 24
MTrk
0 Meta Text "$SCALE major scale"
0 On ch=1 n=$N1 v=64
12 On ch=1 n=$N1 v=0
24 On ch=1 n=$N2 v=64
36 On ch=1 n=$N2 v=0
48 On ch=1 n=$N3 v=64
60 On ch=1 n=$N3 v=0
72 On ch=1 n=$N4 v=64
84 On ch=1 n=$N4 v=0
96 On ch=1 n=$N5 v=64
108 On ch=1 n=$N5 v=0
120 On ch=1 n=$N6 v=64
132 On ch=1 n=$N6 v=0
144 On ch=1 n=$N7 v=64
156 On ch=1 n=$N7 v=0
168 On ch=1 n=$N8 v=64
180 On ch=1 n=$N8 v=0
190 Meta Text "$SCALEM minor scale"
200 On ch=1 n=$NM1 v=64
212 On ch=1 n=$NM1 v=0
224 On ch=1 n=$NM2 v=64
236 On ch=1 n=$NM2 v=0
248 On ch=1 n=$N1 v=64
260 On ch=1 n=$N1 v=0
272 On ch=1 n=$N2 v=64
284 On ch=1 n=$N2 v=0
296 On ch=1 n=$N3 v=64
308 On ch=1 n=$N3 v=0
320 On ch=1 n=$N4 v=64
332 On ch=1 n=$N4 v=0
344 On ch=1 n=$N5 v=64
356 On ch=1 n=$N5 v=0
368 On ch=1 n=$N6 v=64
380 On ch=1 n=$N6 v=0
392 Meta TrkEnd
TrkEnd
EOF

t2mf $SCALE-$SCALEM.txt >$SCALE-$SCALEM.mid

I assure you that weird characters in file names can be odd.