def testImpulses(self):
        imp_sig = thinkdsp.Impulses([0.01, 0.4, 0.8, 1.2],
                                    amps=[1, 0.5, 0.25, 0.1])
        impulses = imp_sig.make_wave(start=0, duration=1.3,
                                     framerate=11025)

        self.assertEqual(len(impulses), 14332)
Exemple #2
0
def plot_beeps():
    wave = thinkdsp.read_wave('253887__themusicalnomad__positive-beeps.wav')
    wave.normalize()

    thinkplot.preplot(3)

    # top left
    ax1 = plt.subplot2grid((4, 2), (0, 0), rowspan=2)
    plt.setp(ax1.get_xticklabels(), visible=False)

    wave.plot()
    thinkplot.config(title='Input waves', legend=False)

    # bottom left
    imp_sig = thinkdsp.Impulses([0.01, 0.4, 0.8, 1.2],
                                amps=[1, 0.5, 0.25, 0.1])
    impulses = imp_sig.make_wave(start=0,
                                 duration=1.3,
                                 framerate=wave.framerate)

    ax2 = plt.subplot2grid((4, 2), (2, 0), rowspan=2, sharex=ax1)
    impulses.plot()
    thinkplot.config(xlabel='Time (s)')

    # center right
    convolved = wave.convolve(impulses)

    ax3 = plt.subplot2grid((4, 2), (1, 1), rowspan=2)
    plt.title('Convolution')
    convolved.plot()
    thinkplot.config(xlabel='Time (s)')

    thinkplot.save(root='sampling1', formats=FORMATS, legend=False)