saturn-examples/midi/interpreter.py
Zack Buhman 778138971f midi: play c major scale
TIMA occurs at half the speed predicted in the SCSP manual in
mednafen, but at the correct speed in Kronos. I don't know which is
correct.
2023-06-27 10:15:14 +00:00

18 lines
333 B
Python

from dataclasses import dataclass
def note_freq(n):
return 440 * 2 ** ((n-69)/12)
@dataclass
class State:
tempo: int = 500000 # µS/qn
division: int = 96 # ticks/qn
state = State()
def delay(dt # microseconds
) -> int: # in microseconds
return int((dt * state.tempo) / state.division)
print(delay(96))