• dodo

    @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()

    posted in Pythonista read more
  • dodo

    '''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()
    

    posted in Pythonista read more
  • dodo

    Fixed! If the switch to kill the ringer is on you get no sound from Pythonista. Such a small bug. I’d rather hear Pythonista than the phone ringing.

    posted in General Discussion read more
  • dodo

    Anyone else notice?

    posted in General Discussion read more
  • dodo

    For your amusement, there is this article published which contains a url with Python music, only playable for we Pythonistas.

    https://www.thespoof.com/spoof-news/us/144172/song-celebrates-streets-of-san-francisco

    The appropriate music for it..

    posted in Pythonista read more
Internal error.

Oops! Looks like something went wrong!