Beispiel #1
0
def main():

    parser = argparse.ArgumentParser()
    parser.add_argument('source', type=str)
    parser.add_argument('target', type=str)
    args = parser.parse_args()

    filenames = os.listdir(args.source)
    paths = (os.path.join(args.source, filename) for filename in filenames)
    signals = list(map(load_signal, paths))

    # Create spectrograms
    plotargs = {
        'clim': (-40, +40),
        'title': '',
    }

    # Create spectrograms
    for signal in signals:
        create_spectrogram(
            signal,
            os.path.join(args.target, "{}.{}".format(signal.basename,
                                                     EXTENSION)), plotargs)

    # Time-level
    s = Signal(signals, signals[0].fs)
    name = os.path.join(args.target, "levels.{}".format(EXTENSION))
    ax = s.plot_levels()
    ax.legend(labels=[
        create_label(signal.method, signal.kernelsize) for signal in signals
    ])
    fig = ax.get_figure()
    fig.tight_layout()
    fig.savefig(name, dpi=600)
Beispiel #2
0
def main():

    # Without turbulence

    #model.settings['turbulence']['include'] = False
    model.settings['turbulence']['include'] = False
    model.settings['turbulence']['amplitude'] = False
    model.settings['turbulence']['phase'] = False
    signal = mono(rcv.auralise())
    signal = Signal(signal.take(nsamples).toarray(), fs)


    without = signal


    # With turbulence (logamp)

    model.settings['turbulence']['include'] = True
    model.settings['turbulence']['amplitude'] = True
    model.settings['turbulence']['phase'] = False
    signal = mono(rcv.auralise())
    signal = Signal(signal.take(nsamples).toarray(), fs)

    #_ = signal.plot_spectrogram(ylim=(0.0, 4000.0), clim=(-40, +60))

    with_logamp = signal


    # With turbulence (phase)

    model.settings['turbulence']['include'] = True
    model.settings['turbulence']['amplitude'] = False
    model.settings['turbulence']['phase'] = True
    signal = mono(rcv.auralise())
    signal = Signal(signal.take(nsamples).toarray(), fs)


    # In[21]:

    #Audio(data=signal, rate=signal.fs)


    # In[22]:

    _ = signal.plot_spectrogram(ylim=(0.0, 4000.0), clim=(-40, +60))


    # In[23]:

    with_phase = signal


    # ## With turbulence (logamp and phase)

    # In[24]:

    model.settings['turbulence']['include'] = True
    model.settings['turbulence']['amplitude'] = True
    model.settings['turbulence']['phase'] = True
    signal = mono(rcv.auralise())
    signal = Signal(signal.take(nsamples).toarray(), fs)


    # In[25]:

    #Audio(data=signal, rate=signal.fs)


    # In[26]:

    _ = signal.plot_spectrogram(ylim=(0.0, 4000.0), clim=(-40, +60))


    # In[27]:

    with_logamp_and_phase = signal


    # In[28]:

    signals = Signal([without, with_logamp, with_phase, with_logamp_and_phase], fs)


    # In[29]:

    labels = ['Without', 'Logamp', 'Phase', 'Both']


    # In[30]:

    fig = signals.plot_levels(labels=labels)


    # In[31]:

    _ = signals.plot_third_octaves(labels=labels)


    # ## Save figures and audio files

    # In[34]:

    #with sns.axes_style(rc={"axes.grid":False}):

    clim = (0.0, +70)
    ylim = (0.0, 4000.0)

    for signal, label in zip(signals, labels):
        signal.normalize().to_wav("../audio/auralisation_flight_{}.wav".format(label.lower()))
        fig = signal.plot_spectrogram(ylim=ylim, clim=clim, title="")
        fig.subplots_adjust(bottom=0.2, left=0.2)
        fig.savefig("../figures/auralisation_flight_{}.eps".format(label.lower()))
Beispiel #3
0
                          mean_mu_squared,
                          ntaps_corr=ntaps_corr,
                          window=window,
                          include_saturation=include_saturation,
                          state=np.random.RandomState(seed=seed),
                          include_amplitude=include_amplitude,
                          include_phase=include_phase)
both = Signal([tone, modulated], fs)
print(both.levels()[1].std(axis=-1))

saveaudio(tone, "tone.wav")
saveaudio(modulated, "modulated.wav")

# In[9]:
labels = ["Tone", "Modulated"]
ax = both.plot_levels(title="", labels=labels)
fig = ax.get_figure()
fig.tight_layout()
savefig(fig, "modulated_levels")

ax = both.plot_power_spectrum(xlim=(985, 1015),
                              ylim=(30.0, 100.0),
                              xscale='linear',
                              labels=labels,
                              title="")
fig = ax.get_figure()
fig.tight_layout()
savefig(fig, "tone_broadening")

# # Correlation for different speeds