Skip to content

Instantly share code, notes, and snippets.

@githubuser1983
githubuser1983 / shortest_paths_music
Created December 25, 2022 07:20
Two pitches a,b are connected in a graph if |a-b| = 3 or |a-b| = 4. This is an attempt to produce some music using shortest paths in this graph
import numpy as np
def writePitches(fn,inds,tempo=82,instrument=[0,0],add21=True,start_at= [0,0],durationsInQuarterNotes=False):
from MidiFile import MIDIFile
track = 0
channel = 0
time = 0 # In beats
duration = 1 # In beats # In BPM
volume = 116 # 0-127, as per the MIDI standard
import turtle as t
import math
WIDTH, HEIGHT = 800, 800
OFFSET = -WIDTH // 2, -HEIGHT // 2
import numpy as np