sys.path.append('../note_seq') # needed unless installing forked lib from github from note_seq import midi_io from music_utils.tokenizer import TokenizerMonophonic from loaders.dataloader_midi import load_midi_to_seq #PARAMS midi_dir = '/Users/nikolasborrel/github/dlmusic_data/midi_data_out/tests/' midi_dir_out = '/Users/nikolasborrel/github/dlmusic_data/midi_data_out/splitted/' instruments = [0] lead_instrument = ('melody', instruments[0]) name_instrument_map = { lead_instrument[0] : lead_instrument[1] } print("Create...") sequences = load_midi_to_seq(midi_dir, name_instrument_map, recursive=False) if len(sequences) == 0: raise Exception(f'No midi files loaded') print("Tokenize...") t = TokenizerMonophonic(max_bars_chunk=8, min_note=60, max_note=72) t.add_songs(sequences, instruments) print("write to disk...") for i, mel in enumerate(t.song_parts_lead): inputs_one_hot, label_not_used = t.encoder_decoder.encode(mel) # MELODY print(f'#encodings melody: {len(inputs_one_hot)}')
# Encoding-Tokenizing parameters instruments = [0, 1] lead_instrument = ('melody', instruments[0]) accomp_instrument = ('bass', instruments[1]) extract_names = (lead_instrument[0], accomp_instrument[0]) extract_instruments = [lead_instrument[1], accomp_instrument[1]] name_instrument_map = { extract_names[0]: extract_instruments[0], extract_names[1]: extract_instruments[1] } sequences = load_midi_to_seq(dataset_path, name_instrument_map, recursive=False) #%% max_chunks_lists = [4, 5, 6] steps = [1, 2, 4] D = AutoVivification() for i, spq in enumerate(steps): tokenizer_kwargs = { 'split_in_bar_chunks': 16, 'steps_per_quarter': spq, 'min_note': 60, 'max_note': 72 } length_per_seq = tokenizer_kwargs[
from loaders.dataloader_midi import load_midi_to_seq import note_seq root_dir = '/home/sarantos/Documents/Music_AI/maestro-v2.0.0-midi' sequences = load_midi_to_seq(root_dir, recursive=True) print(sequences.size) seq1 = sequences[0] seq2 = sequences[1] seq1_extracted = note_seq.extract_subsequence(seq1, 0.0, 0.5) seq2_extracted = note_seq.extract_subsequence(seq2, 0.0, 0.5) print('------SEQ 1--------') print(seq1_extracted) print('------SEQ 2--------') print(seq2_extracted)