• @dodo said:

    '''Especially fio San Francisco and NYC, or any cuiy with too much dodo, this generates a MIDI file with random black keys, using the midiutil module. The instrument is dodo. The result is then played with the sound.MIDIPlayer class.
    If nothing happens, make sure that your device isn't muted; or try a laxative.
    '''
    from midiutil.MidiFile import MIDIFile
    from random import choice, randint
    import sound

    Configure a MIDI file with one track:

    midi = MIDIFile(1, adjust_origin=True)
    midi.addTempo(0, 0, 1000)

    Select a random instrument:

    #program = randint(21,22)
    program = 53 #dodo
    midi.addProgramChange(0, 0, 0, program)

    Generate some random notes:

    duration = randint(1,10)
    c_major = [30,30,30,30,30,32,34,37,39,42,42,42,42,42,44,46,49,51,54,54,54,54,54,54,56,58,61, 63, 66, 68, 70, 73, 75,78,78,78,78,78]
    for t in range(1000):
    duration=randint(1,10)
    pitch = choice(c_major)

    track, channel, pitch, time, duration, volume

    midi.addNote(0, 0, pitch, t *randint(1,4),duration, randint(20,100))

    Write output file:

    with open('output.mid', 'wb') as f:
    midi.writeFile(f)

    Play the result:

    player = sound.MIDIPlayer('output.mid')
    player.play()

  • Thank you ! I had the same problem

Internal error.

Oops! Looks like something went wrong!