Ejemplo n.º 1
0
def main():
    wave_data, wave_params = read_wave_data(IN_FILENAME)

    fft_util = FftUtil(1024)

    freq_domain_data = fft_util.analysis(wave_data)
    plot_spectrogram(freq_domain_data, wave_params.framerate, 'Unaltered freq domain data')
    
    spectrogram_data = reduce_to_spectrogram_data(freq_domain_data)
    plot_spectrogram(spectrogram_data, wave_params.framerate, "Spectrogram data")
        
    expanded_spectrogram_data = expand_from_spectrogram_data(spectrogram_data)
    plot_spectrogram(expanded_spectrogram_data, wave_params.framerate, "Expanded spectrogram data")

    lg_freq_domain, lg_signal = lim_griffen_reconstruction(spectrogram_data, wave_params)
    plot_spectrogram(lg_freq_domain, wave_params.framerate, "Lim Griffen reconstruction")

    reconverted_audio = fft_util.resynthesis(freq_domain_data)
    reconverted_spectrogram_data = fft_util.resynthesis(expanded_spectrogram_data)

    write_wave_data(OUT_FILENAME, reconverted_spectrogram_data, wave_params)
    print("L2-norm of original audio and resynthesis of unmodified data: ", 
          np.linalg.norm(wave_data - reconverted_audio))
    print("L2-norm of original audio and resynthesis of spectrogram_data data: ", 
          np.linalg.norm(wave_data - reconverted_spectrogram_data))
    print("L2-norm of original audio and lim griffen reconstruction: ",
          np.linalg.norm(wave_data - lg_signal))

    plot_comparison(wave_data, lg_signal)
Ejemplo n.º 2
0
def test_analysis_resynthesis():
    fft_util = FftUtil(1024)
    wave_data, wave_params = read_wave_data(IN_FILENAME)
    complex_data = fft_util.analysis(wave_data)
    output = fft_util.resynthesis(complex_data)
    write_wave_data(OUT_FILENAME, output, wave_params)