Exemplo n.º 1
0
Arquivo: music.py Projeto: sabo/steven
def composificate(tracks1, tracks2):
    """Extends tracks1 (presumed to be some sort of percussion) to the length of
    track2. Returns a Composition."""
    compo = Composition()
    #Extend each track1 to the length of the corresponding track2
    ntracks = []
    if len(tracks1) < len(tracks2):
        for track in tracks1:
            idx = tracks1.index(track)
            track = extend_track(track, len(tracks2[idx]))
            ntracks.append(track)
    else:
        ntracks = tracks1
    percus = sum_tracks(ntracks)
    melody = sum_tracks(tracks2)

    piano = MidiInstrument()
    piano.name = 'Acoustic Grand Piano'
    percussion = MidiInstrument()
    percussion.name = 'Woodblock'
    
    percus.instrument = percussion
    melody.instrument = piano
    compo.add_track(percus)
    compo.add_track(melody)
    return compo
Exemplo n.º 2
0
def composificate(tracks1, tracks2):
    """Extends tracks1 (presumed to be some sort of percussion) to the length of
    track2. Returns a Composition."""
    compo = Composition()
    #Extend each track1 to the length of the corresponding track2
    ntracks = []
    if len(tracks1) < len(tracks2):
        for track in tracks1:
            idx = tracks1.index(track)
            track = extend_track(track, len(tracks2[idx]))
            ntracks.append(track)
    else:
        ntracks = tracks1
    percus = sum_tracks(ntracks)
    melody = sum_tracks(tracks2)

    piano = MidiInstrument()
    piano.name = 'Acoustic Grand Piano'
    percussion = MidiInstrument()
    percussion.name = 'Woodblock'

    percus.instrument = percussion
    melody.instrument = piano
    compo.add_track(percus)
    compo.add_track(melody)
    return compo
Exemplo n.º 3
0
def track_creator(instrument_name, channel):
    instrument = MidiInstrument()
    track = Track(instrument, channel=channel)
    instrument.name = instrument_name
    track.instrument.instrument_nr = MidiInstrument.names.index(
        instrument_name)
    return track
Exemplo n.º 4
0
def create_instrument(low, high):
    xylo = MidiInstrument()
    '''
    9 = 'Glockenspiel',
    11 = 'Vibraphone',
    12 = 'Marimba',
    13 = 'Xylophone'
    '''
    xylo.instrument_nr = 11
    xylo.set_range((low, high))
    xylo.name = 'ballophone'
    return xylo
Exemplo n.º 5
0
def find_instrument(instrument, instrument_group):
    if instrument:
        try:
            instrument_nr = MidiInstrument.names.index(instrument)
        except ValueError:
            instrument_nr = int(instrument)
    elif instrument_group:
        # Choose a random from the instrument_group
        instrument = Waitstaff.choose_from_group(instrument_group)
        instrument_nr = MidiInstrument.names.index(instrument)
    else:
        instrument_nr = random.randint(0, len(MidiInstrument.names))

    midi_instrument = MidiInstrument()
    midi_instrument.name = MidiInstrument.names[instrument_nr]
    midi_instrument.instrument_nr = instrument_nr

    return midi_instrument