예제 #1
0
def remixing():
    in_transcript = reader.load_transcript(file1)
    in_transcript2 = reader.load_transcript(file2)
    ngram = MultiInstrumentNGram(nsize)
    ngram.build_from_transcript(in_transcript)
    ngram.build_from_transcript(in_transcript2)
    scheduled_tracks = Generator.generate_multi_instrument_tracks(ngram, ticks)
    return PatternSchedule(scheduled_tracks=scheduled_tracks, meta=in_transcript.get_transcript_meta())
예제 #2
0
def run_from_eminem_music():
    files = listdir("music/Eminem")
    ignored = ["music/Eminem/business.mid", "music/Eminem/forgotaboutdre.mid", "music/Eminem/purple pills.mid"]
               # "music/Eminem/Under_The_Influence.mid"]
    ngram = MultiInstrumentNGram(nsize)
    last_transcript = None
    for file in files:
        path = "music/Eminem/" + file
        if path not in ignored:
            print path
            transcript = reader.load_transcript(path)
            ngram.build_from_transcript(transcript)
            last_transcript = transcript
    scheduled_tracks = Generator.generate_multi_instrument_tracks(ngram, ticks)
    return PatternSchedule(scheduled_tracks=scheduled_tracks, meta=last_transcript.get_transcript_meta())
예제 #3
0
nsize = 10
ticks = 10000
Policies.frame_selection_policy = Policies.FrameSelectionPolicy.RANDOM
input_midi_file_name = "music/bach.mid"
output_midi_file_name = "music/bach-out.mid"

# Create a transcript, this encapsulates the midi data into instrument tracks, where each track contains Note objects
transcript = reader.load_transcript(input_midi_file_name)

# Build the ngram from the track
ngram = MultiInstrumentNGram(nsize)
ngram.build_from_transcript(transcript)

# Generate tracks
scheduled_tracks = Generator.generate_multi_instrument_tracks(ngram, ticks)

# Create a Pattern Schedule
pattern_schedule = PatternSchedule(scheduled_tracks=scheduled_tracks, meta=transcript.get_transcript_meta())

# Convert the Pattern Schedule to an actual Midi Pattern and write it to file
MidiFileWriter(pattern_schedule).save_to_file(output_midi_file_name)

# Play the generated music
reader.play_music(output_midi_file_name)

Policies.FrameSelectionPolicy.PERFECT = "perfect"


class SingleInstrumentPerfectGenerator(SingleInstrumentGenerator):
    def __init__(self, ngram, duration, meta_track):
예제 #4
0
def reproduce():
    transcript = reader.load_transcript("music/Eminem/forgotaboutdre.mid")
    ngram = MultiInstrumentNGram(nsize)
    ngram.build_from_transcript(transcript)
    scheduled_tracks = Generator.generate_multi_instrument_tracks(ngram, ticks)
    return PatternSchedule(scheduled_tracks=scheduled_tracks, meta=transcript.get_transcript_meta())