I am currently doing a PYTHON program and I want to transform midi to wav without a library NOR a program or website. I found multiple posts telling me to download a library BUT I am coding in Pythonista (python IDE for iPhones and iPads) so since I am on mobile I can’t download those libs…
So if it’s possible could someone tell me how?
My code:
# modes: 1 = short classical songs, 2 = soundtrack games boss battle, 3 = sad music
mode = 2
from midiutil.MidiFile import MIDIFile
from random import randint as random
import sound
from time import sleep as wait
midi = MIDIFile(1, adjust_origin=True)
duration = 0
if mode == 1:
duration = random(30, 200)
midi.addTempo(0, 0, random(60, 360))
elif mode == 2:
duration = random(660, 960)
midi.addTempo(0, 0, random(360, 660))
elif mode == 3:
duration = random(10,80)
midi.addTempo(0, 0, random(30, 60))
for t in range(duration):
pitch = random(60,80)
midi.addNote(0, 0, pitch, t * 1 + random(0, 2), 1, 100)
with open('machine made song.txt', 'wb') as f:
midi.writeFile(f)
player = sound.MIDIPlayer('machine made song.txt')
player.play()