You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def add_section_to_midi(notes, durations):
global time
for note, duration in zip(notes, durations):
midi_file.addNote(track, channel, note, time, duration, volume)
time += duration
from midiutil import MIDIFile
Define the MIDI parameters
tempo = 60 # BPM
track = 0
channel = 0
volume = 100
time = 0 # Start at the beginning
midi_file = MIDIFile(1) # One track
midi_file.addTempo(track, time, tempo)
Define the notes and durations for each section of the poem interpretation
Notes are represented in MIDI numbers (60 = Middle C)
Section 1: "अक्ष अक्षि पर ठहरे"
section1_notes = [60, 55, 58] # C, G, A (calm start)
section1_durations = [2, 2, 2] # Durations in beats
Section 2: "तिमिर अहम ढेरे"
section2_notes = [55, 57, 59, 58] # G, A, B, A (deeper, mysterious feel)
section2_durations = [1, 1, 1, 2]
Section 3: "स्वप्न टूट गए"
section3_notes = [60, 62, 64, 62] # C, D, E, D (sad and uncertain)
section3_durations = [1, 1, 2, 2]
Section 4: "अश्व अभिलाषा और प्रेम पतवार"
section4_notes = [67, 65, 64, 62, 60] # G, F, E, D, C (lively, moving forward)
section4_durations = [1, 1, 1, 1, 2]
Function to add notes to the MIDI track
def add_section_to_midi(notes, durations):
global time
for note, duration in zip(notes, durations):
midi_file.addNote(track, channel, note, time, duration, volume)
time += duration
Adding each section to the MIDI file
add_section_to_midi(section1_notes, section1_durations)
add_section_to_midi(section2_notes, section2_durations)
add_section_to_midi(section3_notes, section3_durations)
add_section_to_midi(section4_notes, section4_durations)
Save the MIDI file
with open("/mnt/data/poem_flute_interpretation.mid", "wb") as output_file:
midi_file.writeFile(output_file)
"/mnt/data/poem_flute_interpretation.mid"
The text was updated successfully, but these errors were encountered: