Beispiel #1
0
def getChords(spectra):
	chords = []
	
	for chromum in getChroma(spectra):
		chord, score = Pitch.getChord(chromum)
		chords.append(chord)
	
	return chords
Beispiel #2
0
def getChords(spectra):
    chords = []

    for chromum in getChroma(spectra):
        chord, score = Pitch.getChord(chromum)
        chords.append(chord)

    return chords
Beispiel #3
0
def writeCsv(sampling,frames,output):

    csvfile = open(output, 'wb');

    writer = csv.writer(csvfile, delimiter=',',
                    quotechar='"', quoting=csv.QUOTE_MINIMAL);

    writer.writerow(["Timestamp",
                       "ZCR",
                       "Spectrum Variance",
                       "RMS",
                       "STE",
                       "Pitch",
                       "ZCR diff.",
                       "Spec. Var. diff.",
                       "RMS diff.",
                       "STE diff."]);

    prev_zcr = 0.;
    prev_var = 0.;
    prev_rms = 0.;
    prev_ste = 0.;

    for i  in xrange(0,len(frames)):
        windowSize = len(frames[i]) - 1
        timestamp = "%0.3f" % (sampling[i] / float(freq))
        chord, score = Pitch.getChord(frames[i].spectrum().chroma())

        diff_zcr = frames[i].zcr() - prev_zcr;
        diff_var = frames[i].spectrum().variance() - prev_var;
        diff_rms = frames[i].rms() - prev_rms;
        diff_ste = frames[i].energy(windowSize)[0] - prev_ste;

        row = [timestamp,
               frames[i].zcr(),
               frames[i].spectrum().variance(),
               frames[i].rms(),
               frames[i].energy(windowSize)[0],
               score,
               diff_zcr,
               diff_var,
               diff_rms,
               diff_ste];
        writer.writerow(row);

        prev_zcr = frames[i].zcr();
        prev_var = frames[i].spectrum().variance();
        prev_rms = frames[i].rms();
        prev_ste = frames[i].energy(windowSize)[0];


    print "The result is written on %s" % output
Beispiel #4
0
print o

print "Extracting Frames"
frames = audiofile.framesFromOnsets(o)
#for i in range(0, len(frames)):
#	print "Frame " + str(i)
#	plt.plot(frames[i])
#	plt.show()

#frameSize = 16384
#frames = audioFile.frames(frameSize)

print "Start | End  | Chord | (% match)"
print "-------------------------------"

frameIndex = 0
startIndex = 0
for frame in frames:
    spectrum = frame.spectrum()
    chroma = spectrum.chroma()
    chord, score = Pitch.getChord(chroma)

    endIndex = startIndex + len(frame)

    startTime = startIndex / frame.sampleRate
    endTime = endIndex / frame.sampleRate

    print "%.2f  | %.2f | %-4s | (%.2f)" % (startTime, endTime, chord, score)

    frameIndex = frameIndex + 1
    startIndex = startIndex + len(frame)
Beispiel #5
0
 def chroma(self):
     """
     Compute the 12-ET chroma vector from this spectrum
     """
     return Pitch.chroma(self)
Beispiel #6
0
 def chroma(self):
     """
     Compute the 12-ET chroma vector from this spectrum
     """
     return Pitch.chroma(self)
Beispiel #7
0
def getNotes(spectra):
	return [Pitch.naivePitch(spectrum) for spectrum in spectra]
Beispiel #8
0
print "Extracting Frames"
frames = audiofile.framesFromOnsets(o)
#for i in range(0, len(frames)):
#	print "Frame " + str(i)
#	plt.plot(frames[i])
#	plt.show()

#frameSize = 16384
#frames = audioFile.frames(frameSize)

print "Start | End  | Chord | (% match)"
print "-------------------------------"

frameIndex = 0
startIndex = 0
for frame in frames:
	spectrum = frame.spectrum()
	chroma = spectrum.chroma()
	print chroma
	
	chord, score = Pitch.getChord(chroma)

	endIndex = startIndex + len(frame)

	startTime = startIndex / frame.sampleRate
	endTime = endIndex / frame.sampleRate

	print "%.2f  | %.2f | %-4s | (%.2f)" % (startTime, endTime, chord, score)
    
	frameIndex = frameIndex + 1
	startIndex = startIndex + len(frame)
Beispiel #9
0
def getNotes(spectra):
    return [Pitch.naivePitch(spectrum) for spectrum in spectra]