Ejemplo n.º 1
0
def mash(song1, song2):
	audio1 = Audio(song1)
	audio2 = Audio(song2)


	beats1 = audio1.timings['beats']
	beats2 = audio2.timings['beats']



	mashup =[]
	i = 1
	for beat1, beat2 in zip(beats1, beats2):
		#if (i % 4 == 3 or i % 4 == 1):
		#if (i % 4 == 2 or i % 4 == 1):
		if(i%8 == 7):
		#if (i % 4 == 3):
			mashup.append(beat1)
		else:
			mashup.append(beat2)
		i+=1

	#beats.reverse()
	out = synthesize(mashup)
	out.output('one_more_knob.wav')
Ejemplo n.º 2
0
def mash_except(song1, song2, modValues):
    """Slices two songs and creates third based upon beats chosen"""
    audio1 = Audio(song1)
    audio2 = Audio(song2)

    #breaks the song apart based on beats, returns a list of audio segments
    beats1 = audio1.timings['beats']
    beats2 = audio2.timings['beats']

    mashup = []
    i = 1
	#appends beats from each song to a list, dependent on the beats selected by the user in the GUI'''

    print(modValues)
    for beat2, beat1 in zip(beats2, beats1):
        if(i%8 not in modValues):
            mashup.append(beat1)
        else:
            mashup.append(beat2)
        i += 1

    #converts song from a list of audio to one seamless piece of audio'''
    out = synthesize(mashup)
    output = 'Mashup.wav'
    #saves the newly created song as an uncompressed .wav file'''
    out.output(output)
    return output
def run(file, output):
    from amen.audio import Audio
    # from amen.utils import example_audio_file
    from amen.synthesize import synthesize
    audio_file = file  # INPUT FILE HERE
    audio = Audio(audio_file)

    beats = audio.timings['beats']
    beats.reverse()

    # output
    out = synthesize(beats)
    out.output(output)
def run(file, output):
    from amen.audio import Audio
    # from amen.utils import example_audio_file
    from amen.synthesize import synthesize
    audio_file = file  # INPUT FILE HERE
    audio = Audio(audio_file)

    beats = audio.timings['beats']
    new_beats = []
    for i, beat in enumerate(beats):
        if i % 3 == 0:
            new_beats.append(beat)

    out = synthesize(new_beats)
    out.output(output)
Ejemplo n.º 5
0
def mash(song1, song2):
    audio1 = Audio(song1)
    audio2 = Audio(song2)

    beats1 = audio1.timings['beats']
    beats2 = audio2.timings['beats']

    mashup =[]
    i = 1
    for beat1, beat2 in zip(beats1, beats2):
	    if(i%8 == 7):
		    mashup.append(beat1)
	    else:
		    mashup.append(beat2)
	    i+=1

    out = synthesize(mashup)
    output = 'one_knob.wav'
    out.output(output)
    return output
Ejemplo n.º 6
0
#!/usr/bin/env python
# encoding: utf=8
"""
reverse.py : Reverse the beats of a song.
"""

from amen.audio import Audio
from amen.utils import example_audio_file
from amen.synthesize import synthesize

audio_file = example_audio_file()
audio = Audio(audio_file)

beats = audio.timings['beats']
beats.reverse()

out = synthesize(beats)
out.output('reversed.wav')
Ejemplo n.º 7
0
#!/usr/bin/env python
# encoding: utf=8
"""
iterate.py : Iterate through the beats of a song, and keep some, but not others
"""

from amen.audio import Audio
from amen.utils import example_audio_file
from amen.synthesize import synthesize

audio_file = example_audio_file()
audio = Audio(audio_file)

beats = audio.timings['beats']
new_beats = []
for i, beat in enumerate(beats):
    if i % 4 == 0:
        new_beats.append(beat)

out = synthesize(new_beats)
out.output('iterate.wav')
import os, sys
import random
from amen.utils import example_audio_file
from amen.audio import Audio
from amen.synthesize import synthesize

d = "\\stuff\\music"
print("test")
aud = []
print(os.curdir)
os.chdir(os.curdir + d)
print(os.curdir)
ff = os.listdir(os.curdir)
for f in ff:
    print(f)
    aud.append(Audio(f))
beats = aud[0].timings['beats']
beats.extend(aud[1].timings['beats'])
beats.extend(aud[2].timings['beats'])
print(beats)
random.shuffle(beats)
print(beats)
out1 = synthesize(beats[:((len(beats) // 2) - 1)])
out2 = synthesize(beats[((len(beats) // 2)):])
out1.output('1.wav')
out1.output('2.wav')
Ejemplo n.º 9
0
#!/usr/bin/env python
# encoding: utf=8

"""
iterate.py : Iterate through the beats of a song, and keep some, but not others
"""

import sys
from amen.audio import Audio
from amen.utils import example_audio_file
from amen.synthesize import synthesize

audio_file = example_audio_file()
audio = Audio(audio_file)

beats = audio.timings['beats']
new_beats = []
for i, beat in enumerate(beats):
    if i % 4 == 0:
        new_beats.append(beat)

out = synthesize(new_beats)
out.output('iterate.wav')
Ejemplo n.º 10
0
 def __test():
     synthesized_audio = synthesize(audio.timings['beats'])
     assert (np.isclose(audio.raw_samples[0][100],
                        synthesized_audio.raw_samples[0][100]))
Ejemplo n.º 11
0
 def __test():
     synthesized_audio = synthesize(audio.timings['beats'])
     assert isinstance(synthesized_audio, Audio)
Ejemplo n.º 12
0
def test_synthesize_sample_output_stereo():
    synthesized_audio = synthesize(stereo_audio.timings['beats'])
    assert np.isclose(stereo_audio.raw_samples[0][100],
                      synthesized_audio.raw_samples[0][100])
Ejemplo n.º 13
0
def test_synthesize_returns_stereo():
    synthesized_audio = synthesize(stereo_audio.timings['beats'])
    assert isinstance(synthesized_audio, Audio)
Ejemplo n.º 14
0
def test_synthesize_fails_if_too_long():
    time = pd.to_timedelta(21 * 60, unit='s')
    with pytest.raises(SynthesizeError):
        res = synthesize(([audio.timings['beats'][5]], [time]))