ich arbeite aktuell an einem Skript, welches zufällige didi.tracks erstellt.
Der aktuellste Code würde denke ich den Rahmen sprengen.
Deshalb habe ich ersteinmal den Code gepostet mit dem die ersten kleinen Tracks entstanden sind bzw. Notenansammlungen ^^
Musik kann man das ganze noch nicht nennen
![Mr. Green :mrgreen:](./images/smilies/icon_mrgreen.gif)
Das aktuelle skript welches für das Forum zu groß wäre spuckt u.A. folgenden Track aus:
https://www.youtube.com/watch?v=V0tqtYkB--s
Code: Alles auswählen
import random
from midiutil import MIDIFile
import subprocess
track = 0
channel = 0
time = 0
duration = 1
tempo = 280 # in BPM
volume = 100
mf = MIDIFile(1)
mf.addTempo(track, time, tempo)
mf.addProgramChange(track, channel, time, 19)
notes = { "llf":10 ,"llllf":120, 'b': 125, 'c': 115, 'bb': 125, 'cc': 115, 'oi':200, 'e': 105, 'f': 110 }
#very high piano 105,110
#clingding >110
#10 deep sound
# generate random piano track
for i in range(16000):
#if(random.randint(0,99) > 50):
# tempo+=20
# mf.addTempo(track, time, tempo )
#elif (tempo > 20) : tempo -=20
# if(random.randint(0,10) > 1):
extramp = random.randint(0,10)
if(extramp == 3):
pitch = random.choice(list(notes.values()))
mf.addNote(track, channel, pitch, time, duration, volume)
time+=0.25
mf.addNote(track, channel, pitch, time, duration, volume)
time += 0.25
if(random.randint(0,1) == 1):
pitch = random.choice(list(notes.values()))
mf.addNote(track, channel, pitch, time, duration, volume)
time += 0.25
mf.addNote(track, channel, pitch, time, duration, volume)
time+=0.25
continue
elif(extramp == 2):
pitch = random.choice(list(notes.values()))
mf.addNote(track, channel, pitch, time, duration, volume)
time+=0.5
mf.addNote(track, channel, pitch, time, duration, volume)
time += 0.5
continue
pitch = random.choice(list(notes.values()))
mf.addNote(track, channel, pitch, time, duration, volume)
time += 1
#else:
# pitch = random.choice(list(notes.values()))
# mf.addNote(track, channel, pitch, time, duration/3, volume)
# time += 0.3
# pitch = random.choice(list(notes.values()))
# mf.addNote(track, channel, pitch, time, duration / 3, volume)
# time += 0.3
# pitch = random.choice(list(notes.values()))
# mf.addNote(track, channel, pitch, time, duration / 3, volume)
# time += 0.3
num = int((open("num.txt", "r").readlines())[0])
open("num.txt", "w").writelines(str(num + 1))
with open("random_piano_track" + "_" + str(num) +".mid", "wb") as output_file:
mf.writeFile(output_file)
![Smile :)](./images/smilies/icon_smile.gif)