from midiutil import MIDIFile
# Crear un archivo MIDI con un solo track
midi = MIDIFile(1)
track = 0
time = 0 # Inicio en el tiempo 0
channel = 0
volume = 100
tempo = 80 # BPM
midi.addTempo(track, time, tempo)
# Notas y tiempos para la melodía
melody = [
(64, 0), (67, 0.5), (69, 1), (72, 1.5), # Am7
(62, 2), (71, 2.5), (67, 3), (69, 3.5), # Gadd9
(69, 4), (65, 4.5), (64, 5), (72, 5.5), # Fmaj7
(67, 6), (64, 6.5), (72, 7), (71, 7.5) # Cmaj7/E
]
# Añadir las notas al MIDI
duration = 0.5 # Duración de cada nota en beats
for note, start_time in melody:
midi.addNote(track, channel, note, start_time, duration, volume)
# Guardar el archivo MIDI
output_path = "/mnt/data/Melody_Rusowsky_Style.mid"
with open(output_path, "wb") as output_file:
midi.writeFile(output_file)
output_path
To embed this project on your website, copy the following code and paste it into your website's HTML: