print("Chord notes must be between C2 and B2. Melody notes must be between C3 and B4.") print("Keep the chord and CORRESPONDING melody files in the SAME ORDER within their respective folders.") print() print() print("LSTM RNN Trainer:") print() chord_train_files = glob.glob("%s*.mid" %(chord_train_dir)) mel_train_files = glob.glob("%s*.mid" %(mel_train_dir)) print("Choose a resolution factor. (e.g. Resolution_Factor=24: 1/8 Resolution, 12: 1/16 Resolution, 6: 1/32 Resolution, etc...)") resolution_factor = int(input('Resolution Factor (recommended=12):')) #24: 1/8 Resolution, 12: 1/16 Resolution, 6: 1/32 Resolution #Preprocessing: Get highest and lowest notes + maximum midi_ticks overall midi files chord_lowest_note, chord_highest_note, chord_ticks = data_utils_train.getNoteRangeAndTicks(chord_train_files, res_factor=resolution_factor) mel_lowest_note, mel_highest_note, mel_ticks = data_utils_train.getNoteRangeAndTicks(mel_train_files, res_factor=resolution_factor) #Create Piano Roll Representation of the MIDI files. Return: 3-dimensional array or shape (num_midi_files, maximum num of ticks, note range) chord_roll = data_utils_train.fromMidiCreatePianoRoll(chord_train_files, chord_ticks, chord_lowest_note, chord_highest_note, res_factor=resolution_factor) mel_roll = data_utils_train.fromMidiCreatePianoRoll(mel_train_files, mel_ticks, mel_lowest_note, mel_highest_note, res_factor=resolution_factor) #Double each chord_roll and mel_roll. Preprocessing to create Input and Target Vector for Network double_chord_roll = data_utils_train.doubleRoll(chord_roll) double_mel_roll = data_utils_train.doubleRoll(mel_roll) #Create Network Inputs:
np.set_printoptions(threshold=np.nan) #Comment that line out, to print reduced matrices #chord_train_dir = './trainData1/chords/' mel_train_dir = 'C:/Users/Apoorva.Radhakrishna/Documents/Rocmatt/EC2BACKUP/EC2/melody/' #chord_train_files = glob.glob("%s*.mid" %(chord_train_dir)) mel_train_files = glob.glob("%s*.mid" %(mel_train_dir)) resolution_factor = 12 #Preprocessing: Get highest and lowest notes + maximum midi_ticks overall midi files #chord_lowest_note, chord_highest_note, chord_ticks = data_utils_train.getNoteRangeAndTicks(chord_train_files, res_factor=resolution_factor) mel_lowest_note, mel_highest_note, mel_ticks = data_utils_train.getNoteRangeAndTicks(mel_train_files, res_factor=resolution_factor) #Create Piano Roll Representation of the MIDI files. Return: 3-dimensional array or shape (num_midi_files, maximum num of ticks, note range) #chord_roll = data_utils_train.fromMidiCreatePianoRoll(chord_train_files, chord_ticks, chord_lowest_note, chord_highest_note, mel_roll = data_utils_train.fromMidiCreatePianoRoll_ARIMA(mel_train_files, mel_ticks, mel_lowest_note, mel_highest_note, res_factor=resolution_factor) Pianoroll=sparse.csr_matrix(mel_roll) scipy.sparse.save_npz("C:/Users/Apoorva.Radhakrishna/Documents/Rocmatt/EC2BACKUP/EC2/melody/ShortPianoroll.npz", Pianoroll, compressed=True) #Double each chord_roll and mel_roll. Preprocessing to create Input and Target Vector for Network #double_chord_roll = data_utils_train.doubleRoll(chord_roll) #double_mel_roll = data_utils_train.doubleRoll(mel_roll) #
import data_utils_train import numpy as np import time import csv import glob np.set_printoptions( threshold=np.nan) #Comment that line out, to print reduced matrices chord_train_dir = './data1/' chord_train_files = glob.glob("%s*.mid" % (chord_train_dir)) resolution_factor = 12 time = float(0) prev = float(0) #Preprocessing: Get highest and lowest notes + maximum midi_ticks overall midi files chord_lowest_note, chord_highest_note = data_utils_train.getNoteRangeAndTicks( chord_train_files, res_factor=resolution_factor) #Create Piano Roll Representation of the MIDI files. Return: 3-dimensional array or shape (num_midi_files, maximum num of ticks, note range) chord_roll = data_utils_train.fromMidiCreatePianoRoll( chord_train_files, chord_ticks, chord_lowest_note, chord_highest_note, res_factor=resolution_factor) #Double each chord_roll and mel_roll. Preprocessing to create Input and Target Vector for Network double_chord_roll = data_utils_train.doubleRoll(chord_roll) double_mel_roll = data_utils_train.doubleRoll(mel_roll)