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 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 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.")
                                            barNum + barBlock, measure,
                                            unitSize, noteTR)
    offset = i * barBlock * measure * (1 / unitSize)
    #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")
freqs = []
limits = []

for i in range(len(data)):
    if i > 0:
        freqs.append([])
        for j in data[i].split(","):
            try:
                freqs[i - 1].append(float(j))
            except:
                pass
    else:
        for i in data[i].split(","):
            try:
                limits.append(int(i))
            except:
                pass

bandSeq = ps.LoudestBand(limits, freqs)
print(bandSeq)
print(ps.GetPCode(bandSeq))

pCodeNum = ps.GetPCode_Num(bandSeq)

plt.figure(figsize=(20, 5))
plt.scatter(range(len(pCodeNum)), pCodeNum)
plt.plot(range(len(pCodeNum)), pCodeNum)
plt.xticks([i * 16 for i in range(len(freqs) // 16)])
plt.savefig("parsonsSeq.png")
plt.show()
Beispiel #6
0
    try:
        x, y = ez.GetNotesPeakFrequency(freqBands, song, bpm, i, i + 1,
                                        measure, unitSize, noteTR, False)
        for j in range(len(y)):
            x_freq.append(x[j] + (i * measure * (1 / unitSize)))
            y_freq.append(y[j])

        x, y = ez.GetNotesPeakEnergy(freqBands, song, bpm, i, i + 1, measure,
                                     unitSize, noteTR, False)
        for j in range(len(y)):
            x_energy.append(x[j] + (i * measure * (1 / unitSize)))
            y_energy.append(y[j])
    except:
        break

pc_e = parsons.GetPCode(x_energy, y_energy)
pc_f = parsons.GetPCode(x_freq, y_freq)

x = [i * unitSize for i in x_freq]

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")