Пример #1
0
def pq(inpath, type):
    '''
        prints out the quanta of the given type
    '''
    remixer = pyremix.Remix(trace=True)
    track = remixer.analyze_track(inpath)
    for q in track['analysis'][type]:
        remixer.print_quanta(q)
Пример #2
0
def extract_loudest(inpath, outpath):
    ''' extracts the loudest section
    '''
    remixer = pyremix.Remix(trace=True)
    track = remixer.analyze_track(inpath)

    loudest = None
    for section in track['analysis']['sections']:
        if loudest == None or section['loudness'] > loudest['loudness']:
            loudest = section
    remixer.render([loudest]).export(outpath)
Пример #3
0
def reverse(inpath, outpath):
    '''
        render a new version of the input song that consists
        of the beats in reverse order
    '''
    remixer = pyremix.Remix(trace=True)
    track = remixer.analyze_track(inpath)
    beats = track['analysis']['beats']
    beats.reverse()
    audio = remixer.render(beats)
    audio.export(outpath, format="mp3")
Пример #4
0
def breverse(inpath, outpath):
    '''
        reverse each beat of audio
    '''
    remixer = pyremix.Remix(trace=True)
    track = remixer.analyze_track(inpath)
    beats = track['analysis']['tatums']
    out = []
    for b in beats:
        out.append(remixer.q_reverse(b))
    audio = remixer.render(out)
    audio.export(outpath, format="mp3")
Пример #5
0
def echo(inpath, outpath):
    '''
        echos each beat with a quieter version of the beat
    '''
    remixer = pyremix.Remix(trace=True)

    track = remixer.analyze_track(inpath)
    out = []
    for i, beat in enumerate(track['analysis']['beats']):
        out.append(beat)
        out.append(remixer.q_gain(beat, -5))
    audio = remixer.render(out)
    audio.export(outpath, format="mp3")
Пример #6
0
def one(inpath, outpath):
    '''
        render a new version of the input song that consists
        of just the first beat of every bar
    '''
    remixer = pyremix.Remix(trace=True)

    track = remixer.analyze_track(inpath)
    beats = []
    for i, beat in enumerate(track['analysis']['beats']):
        if beat['index_in_parent'] == 0:
            beats.append(beat)
    audio = remixer.render(beats)
    audio.export(outpath, format="mp3")
Пример #7
0
def separated_segments(inpath, outpath):
    '''
        separate ever segment by short stretch of silence
    '''
    remixer = pyremix.Remix(trace=True)

    track = remixer.analyze_track(inpath)
    silence = remixer.q_silence(.33)
    out = []
    for i, q in enumerate(track['analysis']['segments']):
        out.append(q)
        out.append(silence)

    audio = remixer.render(out)
    audio.export(outpath, format="mp3")
Пример #8
0
def adjust_speed(inpath, factor, outpath):
    '''
        adjusts the speed of the given song, beat by beat
    '''

    remixer = pyremix.Remix(trace=True)

    track = remixer.analyze_track(inpath)

    song = []

    for q in track['analysis']['beats']:
        song.append(remixer.q_resize(q, factor))

    audio = remixer.render(song)
    audio.export(outpath, format="mp3")
Пример #9
0
def rebar(inpath, outpath):
    '''
        reorder the beats in each bar so that they are in
        descending loudness order
    '''
    remixer = pyremix.Remix(trace=True)
    track = remixer.analyze_track(inpath)

    song = []
    for bar in track['analysis']['bars']:
        beats = bar['children']
        beats.sort(key=lambda beat: beat['loudness_max'], reverse=True)
        song.extend(beats)

    audio = remixer.render(song)
    audio.export(outpath, format="mp3")
Пример #10
0
def shuffle_bars(inpath, outpath):
    '''
        reorder the beats in each bar so that they are in
        descending loudness order
    '''
    remixer = pyremix.Remix(trace=True)
    track = remixer.analyze_track(inpath)

    song = []
    for bar in track['analysis']['bars']:
        beats = bar['children']
        random.shuffle(beats)
        song.extend(beats)

    audio = remixer.render(song)
    audio.export(outpath, format="mp3")
Пример #11
0
def add_a_beat(inpath, outpath):
    '''
        render a new version of the input song that consists
        of the beats in reverse order
    '''
    remixer = pyremix.Remix(trace=True)
    track = remixer.analyze_track(inpath)
    beats = track['analysis']['beats']

    out = []
    for b in beats:
        if b['index_in_parent'] == 3:
            out.append(b)
        out.append(b)
    audio = remixer.render(out)
    audio.export(outpath, format="mp3")
Пример #12
0
def overlay(inpath, outpath):
    '''
        overlays each beat with the next beat
    '''
    remixer = pyremix.Remix(trace=True)

    track = remixer.analyze_track(inpath)
    out = []
    for i, beat in enumerate(track['analysis']['beats']):
        print i, 'of', len(track['analysis']['beats'])
        if beat['next']:
            out.append(
                remixer.q_combine(remixer.q_gain(beat, -7),
                                  remixer.q_gain(beat['next'], -5)))
        else:
            out.append(beat)

    audio = remixer.render(out)
    audio.export(outpath, format="mp3")
Пример #13
0
def alt_beats(inpath1, inpath2, outpath):
    '''
        render a new version of the input song that consists
        of the beats in reverse order
    '''
    remixer = pyremix.Remix(trace=True)

    track1 = remixer.analyze_track(inpath1)
    track2 = remixer.analyze_track(inpath2)
    beats1 = track1['analysis']['beats']
    beats2 = track2['analysis']['beats']

    out = []
    for b1, b2 in zip(beats1, beats2):
        if b1:
            out.append(b1)
        if b2:
            out.append(b2)

    audio = remixer.render(out)
    audio.export(outpath, format="mp3")
Пример #14
0
def blip(inpath, type, outpath):
    '''
        a simple version of more cowbell. Merely
        adds a cowbell to the most confident beats
    '''
    confidence_threshold = .0

    remixer = pyremix.Remix(trace=True)

    track = remixer.analyze_track(inpath)
    bell = remixer.q_from_file("examples/sounds/blip_high.wav", "wav")

    song = []

    for q in track['analysis'][type]:
        if q['confidence'] >= confidence_threshold:
            song.append(remixer.q_combine(q, bell))
        else:
            song.append(q)

    audio = remixer.render(song)
    audio.export(outpath, format="mp3")