#NEWLINE# @ register_pydub_effect #NEWLINE# def low_pass_filter( seg , cutoff ) : #NEWLINE# #INDENT# '\n        cutoff - Frequency (in Hz) where higher frequency signal will begin to\n            be reduced by 6dB per octave (doubling in frequency) above this point\n    ' #NEWLINE# RC = ( 1.0 / ( ( cutoff * 2 ) * math . pi ) ) #NEWLINE# dt = ( 1.0 / seg . frame_rate ) #NEWLINE# alpha = ( dt / ( RC + dt ) ) #NEWLINE# original = seg . get_array_of_samples ( ) #NEWLINE# filteredArray = array . array ( seg . array_type , original ) #NEWLINE# frame_count = int ( seg . frame_count ( ) ) #NEWLINE# last_val = ( [ 0 ] * seg . channels ) #NEWLINE# for i in range ( seg . channels ) : #NEWLINE# #INDENT# last_val [ i ] = filteredArray [ i ] = original [ i ] #NEWLINE# #UNINDENT# for i in range ( 1 , frame_count ) : #NEWLINE# #INDENT# for j in range ( seg . channels ) : #NEWLINE# #INDENT# offset = ( ( i * seg . channels ) + j ) #NEWLINE# last_val [ j ] = ( last_val [ j ] + ( alpha * ( original [ offset ] - last_val [ j ] ) ) ) #NEWLINE# filteredArray [ offset ] = int ( last_val [ j ] ) #NEWLINE# #UNINDENT# #UNINDENT# return seg . _spawn ( data = filteredArray . tostring ( ) )