Ejemplo n.º 1
0
	def _calcChordThread(self, begin, end):
		self.updateProgressText.emit("Opening wave...")
		wave = wave2.Wave(self.wave.data[begin:end], self.wave.sampleRate)
		
		self.updateProgressText.emit("Analyzing frequencies...")
		freqs = freqSet.fromWave(wave)
		self.updateProgress.emit(40)
		
		self.updateProgressText.emit("Grouping into notes...")
		notes = noteset.fromFreqSet(freqs)
		self.updateProgress.emit(80)
		
		self.updateProgressText.emit("Finding chords...")
		chords = scalefinder.findTriad(notes)
		self.updateProgress.emit(85)
		
		self.updateProgressText.emit("Correcting weights...")
		chords = functions.makeWeightsCorrect(chords)
		self.updateProgress.emit(90)
		
		self.updateProgressText.emit("Sorting to likeliness...")
		chords = sorted(chords, key=lambda x: x[1])
		
		self.updateProgress.emit(0)
		self.updateProgressText.emit("")
		
		self.updateResult.emit(ResultTypes.CHORDS, chords)
Ejemplo n.º 2
0
    if filename != '':
        return wave2.getFromFile(filename)
    else:
    	print 'File name not specified.'
    	return


def _calcChord(wave, begin, end):
	'''Analyzes the chords between begin and end point of the wave object
	@param wave: wave data
	@param begin: beginning point of the wave
	@param end: ending point of the wave'''
    _wave = wave2.Wave(wave.data[begin:end], wave.sampleRate)
    freqs = freqSet.fromWave(_wave)
    notes = noteset.fromFreqSet(freqs)
    chords = scalefinder.findTriad(notes)
    chords = functions.makeWeightsCorrect(chords)
    chords = sorted(chords, key=lambda x : x[1])

    # The first element in the tuple being the most accurate chord
    return (chords[-1][0], chords[-2][0], chords[-3][0])




if __name__ == '__main__':
	filename = raw_input("Enter the WAV file name to analyze : ")
	[wave, totaltime] = _openWave(filename)
	beat = # function to find the beat of the music
	intervals = _determineIntervals(beat, totaltime)
	result = []