David Radcliffe
dradcliffe@gmail.com
import pandas as pd
from mingus.containers import Note, NoteContainer, Bar, Track
from mingus.midi import midi_file_out
data = pd.read_csv('temp-anomaly-annual.csv')
track = Track()
# The track begins with 11 bars of rests, in 4/4 time.
for _ in range(11):
bar = Bar()
bar.place_rest(1) # Whole rest
track.add_bar(bar)
for value in data.Anomaly:
note = Note()
pitch = int(36*value + 48)
note.from_int(pitch)
note.velocity = 127
bar = Bar('C', (1, 4))
bar.place_notes(note, 4)
track.add_bar(bar)
midi_filename = "temp-anomaly.mid"
bpm = 600 # 10 beats per second. Each beat represents 1 year.
midi_file_out.write_Track(midi_filename, track, bpm)