Ejemplo n.º 1
0
 def Melody():
     noteThreshold = 0.6
     unitSize = 0.25
     print("\nObtaining Melody...")
     # 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.SaveCSV3D(x, pc_e,pc_f, directory, "dataMelody_" + songName)
     print("Done.")
Ejemplo n.º 2
0
 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.")
Ejemplo n.º 3
0
#freqBands = [i*60 for i in range(5,26)] # Melody/Lead use continuous
#freqBands = [i*60 for i in range(2,6)] # Body/Snare use step
#freqBands = [9000, 16000] # High/Hats need custom de-peak process
freqBands = [i * 60 for i in range(0, 3)]  # Bass/Kick use continuous

maxBars = int((song.length_seconds * (1 / (60 / bpm)) / measure))
print("Song duration in bars: " + str(maxBars))

x_all, y_energy, z_freq = [], [], []

barBlock = 4
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, 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)