#NEWLINE# def test_spectral_rolloff_synthetic( ) : #NEWLINE# #INDENT# sr = 22050 #NEWLINE# n_fft = 2048 #NEWLINE# def __test( S , freq , pct ) : #NEWLINE# #INDENT# rolloff = librosa . feature . spectral_rolloff ( S = S , sr = sr , freq = freq , roll_percent = pct ) #NEWLINE# if ( freq is None ) : #NEWLINE# #INDENT# freq = librosa . fft_frequencies ( sr = sr , n_fft = n_fft ) #NEWLINE# #UNINDENT# idx = np . floor ( ( pct * freq . shape [ 0 ] ) ) . astype ( int ) #NEWLINE# assert np . allclose ( rolloff , freq [ idx ] ) #NEWLINE# #UNINDENT# S = np . ones ( ( ( 1 + ( n_fft // 2 ) ) , 10 ) ) #NEWLINE# for pct in [ 0.25 , 0.5 , 0.95 ] : #NEWLINE# #INDENT# ( yield ( __test , S , None , pct ) ) #NEWLINE# freq = librosa . fft_frequencies ( sr = sr , n_fft = n_fft ) #NEWLINE# ( yield ( __test , pct , freq , pct ) ) #NEWLINE# freq = np . cumsum ( np . abs ( np . random . randn ( * S . shape ) ) , axis = 0 ) #NEWLINE# ( yield ( __test , S , freq , pct ) )