Beispiel #1
0
def go(impulses_csv=IMPULSES_CSV, make_plots=False):
    '''
    Initializes an ImpulseResponses object, processes impulses and exports them
    to disk. Plots are generated if specified and saved to disk.
    '''

    impulses = ImpulseResponses(impulses_csv)
    impulses.export_to_npz()

    # generate plots of the processed impulse response
    if make_plots:
        for freq_bin in FREQ_BINS:
            freq_impulses = []
            for impulse in impulses.impulses_ffts.keys():
                freq_impulse = impulses.impulses_ffts[impulse][str(freq_bin)]
                freq_impulses.append(freq_impulse)
                # plot each impulse at given frequency separately
                plot([freq_impulse], impulse + 'bin_{}'.format(freq_bin))
            # plot all impulses at given frequency together
            plot(freq_impulses, 'processed_impulses_bin_{}'.format(freq_bin))
Beispiel #2
0
def go(audio_fname, impulses_fname=PROCESSED_IMPULSES_CSV, k=K_NEIGHBORS, make_plots=False):
    '''
    Initializes a ProcessedImpulses object with the already processed impulses. 
    Initializes a ReverbAudio object using the audio_fname and extracts a reverb signature.
    Calls k_neihbors module to perform a k-nearest neighbors analysis between the impulses 
    and the audio reverb signature.
    Plots are generated if specified and saved to disk.
    '''
    impulses = ProcessedImpulses(impulses_fname)
    reverb = ReverbAudio(audio_fname)
    analysis = k_neighbors.KNeighbors(impulses.impulses, reverb.reverb_signature)
    analysis_results = analysis.do_analysis(k=k, make_plots=make_plots)

    # generate plots of the reverb signature at each frequency bin
    if make_plots:
        for freq_bin in FREQ_BINS:
            reverb_signature = reverb.reverb_signature[str(freq_bin)]
            if reverb_signature[0] != None:
                plot([reverb_signature], reverb.audio.title + '_bin_' + str(freq_bin))

    print('A lower value means a better match.')
    print('A value of 0.0 for k=1 means the match is exact.')
    print(analysis_results)
    return analysis_results