#NEWLINE# def test_cqt_position( ) : #NEWLINE# #INDENT# sr = 22050 #NEWLINE# freq = librosa . midi_to_hz ( 60 ) #NEWLINE# y = np . sin ( ( ( ( 2 * np . pi ) * freq ) * np . linspace ( 0 , 2.0 , ( 2 * sr ) ) ) ) #NEWLINE# def __test( note_min ) : #NEWLINE# #INDENT# C = np . abs ( librosa . cqt ( y , sr = sr , fmin = librosa . midi_to_hz ( note_min ) , real = False ) ) #NEWLINE# Cbar = np . median ( C , axis = 1 ) #NEWLINE# idx = np . argmax ( Cbar ) #NEWLINE# eq_ ( idx , ( 60 - note_min ) ) #NEWLINE# Cscale = ( Cbar / Cbar [ idx ] ) #NEWLINE# Cscale [ idx ] = np . nan #NEWLINE# assert ( np . nanmax ( Cscale ) < 0.6 ) #NEWLINE# Cscale [ ( idx - 1 ) : ( idx + 2 ) ] = np . nan #NEWLINE# assert ( np . nanmax ( Cscale ) < 0.05 ) #NEWLINE# #UNINDENT# for note_min in [ 12 , 18 , 24 , 30 , 36 ] : #NEWLINE# #INDENT# ( yield ( __test , note_min ) )