Ejemplo n.º 1
0
def main(args):
    s = usersong.UserSong(args.song)
    s.analyze()
    if args.output_path is None:
        print(s.get_analysis())
    else:
        with open(args.output_path, "wb") as out_file:
            out_file.write(dill.dumps(s.get_analysis()))
            out_file.close()
from composer import composer
from analyzer import usersong, analysis
from composer.audio_effect_types import Transition_Types
"""
Songs are in decreasing order of bpm
"""
songs_path = os.path.join(os.path.abspath(".."), "testmp3s")
filepaths = [
    os.path.join(songs_path, '140bpm_8bars.mp3'),
    os.path.join(songs_path, '130bpm_8bars.mp3'),
    os.path.join(songs_path, '125bpm_8bars.mp3'),
    os.path.join(songs_path, '120bpm_8bars.mp3'),
    os.path.join(songs_path, '110bpm_8bars.mp3')
]

song_a = usersong.UserSong(filepaths[0])
song_b = usersong.UserSong(filepaths[1])
song_c = usersong.UserSong(filepaths[2])
song_d = usersong.UserSong(filepaths[3])
song_e = usersong.UserSong(filepaths[4])

usersong.batch_analyze_user_songs([song_a, song_b, song_c, song_d, song_e])

# get beat 16 beats from the end of Song a for transition 2
beat_a_0 = len(song_a.get_analysis_feature(analysis.Feature.BEATS)) - 13
beat_b_1 = len(song_b.get_analysis_feature(analysis.Feature.BEATS)) - 13
beat_c_1 = len(song_c.get_analysis_feature(analysis.Feature.BEATS)) - 13
beat_d_1 = len(song_d.get_analysis_feature(analysis.Feature.BEATS)) - 13
beat_e_1 = len(song_e.get_analysis_feature(analysis.Feature.BEATS)) - 13

# length in beats
Ejemplo n.º 3
0
sys.path.append("..")
from analyzer import usersong, analysis
from composer import composer
from composer.audio_effect_types import Transition_Types
"""
110 bpm -> 140 bpm -> 120 bpm
"""
songs_path = os.path.join(os.path.abspath(".."), "testmp3s")
filepaths = [
    os.path.join(songs_path, '110bpm_8bars.mp3'),
    os.path.join(songs_path, '140bpm_8bars.mp3'),
    os.path.join(songs_path, '120bpm_8bars.mp3')
]

song_a = usersong.UserSong(filepaths[0])
song_b = usersong.UserSong(filepaths[1])
song_c = usersong.UserSong(filepaths[2])

usersong.batch_analyze_user_songs([song_a, song_b, song_c])

# get beat 16 beats from the end of Song a for transition 2
beat_a_0 = len(song_a.get_analysis_feature(analysis.Feature.BEATS)) - 9
# start beat 0 for Song b on transition 0
beat_b_0 = 0
# start beat 16 beats from end of Song b for transition 1
beat_b_1 = len(song_b.get_analysis_feature(analysis.Feature.BEATS)) - 9
# start beat 0 for Song c on transition 1
beat_c_1 = 0
# length in beats
length = 8
Ejemplo n.º 4
0
import librosa

from analyzer import usersong
from analyzer import analysis

TEST_SONG = usersong.UserSong(librosa.util.example_audio_file(), False)
TEST_SONG.load()
TEST_SONG.analyze()

BEATS = TEST_SONG.get_analysis_feature(analysis.Feature.BEATS)


def test_errors():
    try:
        TEST_SONG.get_amplitude_at_beat(BEATS[0], 500)
        assert False
    except ValueError:
        assert True
    try:
        TEST_SONG.get_amplitude_at_beat(BEATS[0], -1)
        assert False
    except ValueError:
        assert True
    try:
        TEST_SONG.get_amplitude_at_beat(BEATS[0], 0)
        assert False
    except ValueError:
        assert True
    try:
        TEST_SONG.get_amplitude_at_beat(BEATS[0], 8192)
        assert False