1#! /usr/bin/env python3
2
3# Taken from:
4# https://github.com/MarkCWirt/MIDIUtil/blob/1.2.1/examples/c-major-scale.py
5
6from midiutil import MIDIFile
7
8degrees = [60, 62, 64, 65, 67, 69, 71, 72]  # MIDI note number
9track = 0
10channel = 0
11time = 0        # In beats
12duration = 1    # In beats
13tempo = 60      # In BPM
14volume = 100    # 0-127, as per the MIDI standard
15
16MyMIDI = MIDIFile(1)  # One track
17MyMIDI.addTempo(track, time, tempo)
18
19for i, pitch in enumerate(degrees):
20    MyMIDI.addNote(track, channel, pitch, time + i, duration, volume)
21
22with open("major-scale.mid", "wb") as output_file:
23    MyMIDI.writeFile(output_file)
24