def Snare(): noteThreshold = 0.5 unitSize = 0.5 # Step, Peaks, 4 by 4, unit 0.5 x_all, y_energy, z_freq = [],[],[] freqBands = [120,300] barBlock = 4 for i in range(maxBars//barBlock): barNum = i*barBlock x,y,z = ez.GetNotesPeaks3D_Step(freqBands, song, bpm, barNum, barNum+barBlock, measure, unitSize, noteThreshold) offset = i*barBlock*measure*(1/unitSize) for j in range(len(y)): x_all.append(x[j] + offset) y_energy.append(y[j]) z_freq.append(z[j]) peaks = [] for i in x_all: peaks.append(i * (60/bpm)*unitSize * song.sampfreq) onset.SavePeaks(peaks, song.sampfreq, 1, song.peakAlphaIndex, directory + "peaksSnare.csv") pc_e,pc_f = parsons.GetPCode(x_all, y_energy),parsons.GetPCode(x_all, z_freq) x = [i*unitSize for i in x_all] ez.PlotComplete(x, pc_e, pc_f, bpm, maxBars, measure, unitSize, freqBands, directory,"plotSnare.png", noteThreshold, song.GetRMS(), alphaPeak) parsons.SaveCSV5D(x, pc_e,pc_f,y_energy,z_freq,directory, "dataSnare.csv") print("Done.")
def Melody(): noteThreshold = 0.5 unitSize = 0.25 # Continuous, Peaks, 4 by 4, unit 0.25 x_all, y_energy, z_freq = [], [], [] freqBands = [300, 1800] barBlock = 4 for i in range(maxBars // barBlock): barNum = i * barBlock x, y, z = ez.GetNotesPeaks3D_Continuous(freqBands, song, bpm, barNum, barNum + barBlock, measure, unitSize, noteThreshold) offset = i * barBlock * measure * (1 / unitSize) for j in range(len(y)): x_all.append(x[j] + offset) y_energy.append(y[j]) z_freq.append(z[j]) peaks = [] for i in x_all: peaks.append(i * (60 / bpm) * unitSize * song.sampfreq) onset.SavePeaks( peaks, song.sampfreq, 1, song.peakAlphaIndex, directory + "peaksMelody" + "_" + songName.split(".")[0] + ".csv") pc_e, pc_f = parsons.GetPCode(x_all, y_energy), parsons.GetPCode( x_all, z_freq) x = [i * unitSize for i in x_all] ez.PlotComplete(x, pc_e, pc_f, bpm, maxBars, measure, unitSize, freqBands, directory, "plotMelody_" + songName, noteThreshold, song.GetRMS(), alphaPeak) parsons.SaveCSV5D(x, pc_e, pc_f, y_energy, z_freq, directory, "dataMelody_" + songName) print("Done.")