# FFT length
frame_len = 512
# parameter update of the sigma in sigma tracking
alpha = 0.1  # smaller value allows noise floor to change faster
threshold = 0.003

plot_spec = True
"""
Prepare input file
"""
signal_fp = os.path.join(os.path.dirname(__file__), 'input_samples',
                         'cmu_arctic_us_aew_a0001.wav')
noise_fp = os.path.join(os.path.dirname(__file__), 'input_samples',
                        'doing_the_dishes.wav')
noisy_signal, signal, noise, fs = pra.create_noisy_signal(signal_fp,
                                                          snr=snr,
                                                          noise_fp=noise_fp)
wavfile.write(
    os.path.join(os.path.dirname(__file__), 'output_samples',
                 'denoise_input_IterativeWiener.wav'), fs,
    noisy_signal.astype(np.float32))
"""
Apply approach
"""

scnr = IterativeWiener(frame_len, lpc_order, iterations, alpha, threshold)

# derived parameters
hop = frame_len // 2
win = pra.hann(frame_len, flag='asymmetric', length='full')
stft = pra.transform.STFT(frame_len,
def white_noise(snr):
    np.random.seed(0)
    noisy_signal, signal, noise, fs = create_noisy_signal(signal_fp, snr=snr)
    _snr = 20 * np.log10(rms(signal) / rms(noise))
    err = abs(snr - _snr)
    return err, noisy_signal, fs