def Hats(): noteThreshold = 0.7 unitSize = 0.25 print("\nObtaining HiHats...") # Continuous, Peaks, all bars, unit 0.25 x_all, y_energy, z_freq = [],[],[] freqBands = [9000,16000] barBlock = maxBars for i in range(maxBars//barBlock): barNum = i*barBlock x,y,z = ez.GetNotesPeaks3D_Continuous_Sum(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 + "peaksHats" + "_" + 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, "plotHats_" + songName, noteThreshold, song.GetRMS(), alphaPeak) parsons.SaveCSV3D(x, pc_e,pc_f, directory, "dataHats_" + songName) print("Done.")
def Snare(): noteThreshold = 0.6 unitSize = 0.5 print("\nObtaining Snare...") # 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" + "_" + 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, "plotSnare_" + songName, noteThreshold, song.GetRMS(), alphaPeak) parsons.SaveCSV3D(x, pc_e,pc_f, directory, "dataSnare_" + songName) print("Done.")
def Bass(): noteThreshold = 0.5 unitSize = 0.25 # Continuous, Peaks, all bars, unit 0.25 x_all, y_energy, z_freq = [],[],[] freqBands = [0,120] barBlock = maxBars 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 + "peaksBass.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, "plotBass.png", noteThreshold, song.GetRMS(), alphaPeak) parsons.SaveCSV5D(x, pc_e,pc_f,y_energy,z_freq,directory, "dataBass.csv") print("Done.")
#print(x,y,z) 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, 0, "reaper/Files/peaks.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, plotPath, songName, noteTR, song.GetRMS(), alphaPeak) parsons.SaveCSV3D(x, pc_e, pc_f, csvPath, songName) ''' ez.PlotPart(x,y_freq, maxBars, measure, unitSize, plotPath + "zRefs/" + str(songName.split(".")[0]) + "_freq.png") ez.PlotPart(x,y_energy, maxBars, measure, unitSize, plotPath + "zRefs/" + str(songName.split(".")[0]) + "_energy.png") parsons.SaveCSV(x,y_freq, csvPath + "zRefs/" + str(songName.split(".")[0]) + "_freq.csv") parsons.SaveCSV(x,y_energy, csvPath + "zRefs/" + str(songName.split(".")[0]) + "_energy.csv") BAR BY BAR PLOTS #ez.PlotGridEnergy(freqBands, song, bpm, 0, 1, measure, unitSize, "test.png") #ez.PlotNotesEnergy(freqBands, song, bpm, 0, 1, measure, unitSize, tr, "test.png") #ez.PlotNotesFrequency(freqBands, song, bpm, 0, 1, measure, unitSize, tr, "test.png") COMPLETE SONG PLOTS