Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flute #285

Open
Seetaram8 opened this issue Oct 31, 2024 · 2 comments
Open

Flute #285

Seetaram8 opened this issue Oct 31, 2024 · 2 comments

Comments

@Seetaram8
Copy link

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"

@Seetaram8
Copy link
Author

Good

1 similar comment
@Seetaram8
Copy link
Author

Good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant