Esempio n. 1
0
 def mix(self):
     if len(self.loaded_songs) == 0:
         self.message.set("No loaded songs...")
         return
     first_goal = MixGoal(0.0, 0.0, 0.0, 0.0, 1)
     goals = [first_goal]
     self.analyze_songs()
     print("Chosen Style: {}".format(self.style))
     print("Maximum Length: {}".format(self.max_length))
     print("First Song: {}".format(self.first_song))
     dj = Optimizer(self.loaded_songs, goals, Style_Lib[self.style].value, 
                    self.max_length, self.first_song)
     mix = dj.generate_mixtape()
     self.log_message(mix)
     comp = composer.composer_parser(mix)
     comp.compose()
    "start_a": beat_b_1,
    "start_b": 0,
    "sections": [{
        "offset": 0,
        "length": length,
        "type": [t_1, t_2]
    }]
}, {
    "song_a": song_c,
    "song_b": song_d,
    "start_a": beat_c_1,
    "start_b": 0,
    "sections": [{
        "offset": 0,
        "length": length,
        "type": [t_1, t_2]
    }]
}, {
    "song_a": song_d,
    "song_b": song_e,
    "start_a": beat_d_1,
    "start_b": 0,
    "sections": [{
        "offset": 0,
        "length": length,
        "type": [t_1, t_2]
    }]
}]

c = composer.composer_parser(mix)
c.compose()
            for ext in usersong.UserSong.EXTENSIONS:
                if fnmatch.fnmatch(file_path, "*%s" % ext):
                    file_paths.append(file_path)
                    break
    return file_paths

song_folder_path = os.path.normpath(os.path.join(project_path, "djskinnyg_songs"))
song_paths = get_file_paths(song_folder_path)
cache_path = os.path.normpath(os.path.join(song_folder_path, "cache"))
song_objects = usersong.batch_create_user_songs(song_paths)
usersong.batch_analyze_user_songs(song_objects, cache_path)

for song in song_objects:
    song.write_analysis_to_folder(cache_path)
    print("{} : {} : {} : {} : {} : {}".format(song.get_analysis_feature(analysis.Feature.NAME), song.get_analysis_feature(analysis.Feature.TEMPO), song.get_analysis_feature(analysis.Feature.KEY), song.get_analysis_feature(analysis.Feature.DANCEABILITY), song.get_analysis_feature(analysis.Feature.ENERGY), song.get_analysis_feature(analysis.Feature.VALENCE)))

# create a list with one goal (start)
first_goal = mix_goal.MixGoal(0.0, 0.0, 0.0, 0.0, 1)
goals = list([first_goal])
# initialize optimizer
dj = optimizer.Optimizer(song_objects, goals, style.Style_Lib.tempo_based.value)
mix_script = dj.generate_mixtape()
print("***MIX SCRIPT RESULT***")

for mix in mix_script:
    print(mix)

c = composer.composer_parser(mix_script)

c.compose()