Exemplo n.º 1
0
def populate_figure(figure):
    axes = figure.add_subplot(1, 1, 1)
    wave, sample_rate = sine_wave(num_periods=2, samples_per_period=44.1)
    axes.stem(wave * 32767, markerfmt='.', basefmt=' ')
    format_waveform_plot(figure)
    axes.set_xlabel('Time (samples)')
    axes.set_ylabel('Sample value')
    axes.set_yticks([-32767, -16384, 0, 16384, 32767])
Exemplo n.º 2
0
def populate_figure(figure, wavefilter=lambda x: x, include_detail=False):
    wave, sample_rate = sine_wave(frequency=1000, num_periods=3)
    wave = wavefilter(wave)
    axes = figure.add_subplot(1, 1, 1)
    waveform(axes, wave, sample_rate)
    format_waveform_plot(figure)
    if include_detail: annotate_amplitude(axes, wave)
    axes.set_xticks([])
    axes.set_xlabel('')
    axes.set_ylabel('')
Exemplo n.º 3
0
def populate_figure_wavesum(figure, wave1, wave2, sample_rate):
    axes = figure.add_subplot(1, 1, 1)
    wavesum = wave1 + wave2

    waveform(axes, wave1, sample_rate, label='Wave 1')
    waveform(axes, wave2, sample_rate, label='Wave 2')
    waveform(axes, wavesum, sample_rate, label='Sum')

    format_waveform_plot(figure)
    axes.legend(loc='upper right')
    axes.set_xticks([])
    axes.set_xlabel('Time')
    axes.set_ylim(-10, 10)
Exemplo n.º 4
0
def populate_figure(figure):
    axes = figure.add_subplot(1, 1, 1)
    # These are the default matplotlib colors, but we're hardcoding them
    # because they are mentioned explicitly in the accompanying text.
    for plot in plots:
        wave, sample_rate = sine_wave(frequency=1000,
                                      num_periods=2,
                                      phase_radians=np.radians(
                                          plot['phase_degrees']))
        waveform(axes,
                 wave,
                 sample_rate,
                 linestyle=plot['linestyle'],
                 color=plot['color'],
                 label=str(plot['phase_degrees']) + '°')
    format_waveform_plot(figure)
    axes.legend(loc='upper right')
    axes.set_yticks([])
Exemplo n.º 5
0
def populate_figure_wave(figure, wave, sample_rate):
    axes = figure.add_subplot(1, 1, 1)
    waveform(axes, wave, sample_rate)
    format_waveform_plot(figure)
    axes.set_yticks([])
Exemplo n.º 6
0
def populate_figure(figure):
    waveform(figure.add_subplot(1, 1, 1), *noisy_sine_wave(num_periods=3))
    format_waveform_plot(figure)
Exemplo n.º 7
0
def populate_figure(figure):
    axes = figure.add_subplot(1, 1, 1)
    wave, sample_rate = sine_wave(frequency=1000, num_periods=2)
    waveform(axes, wave*1.41, sample_rate)
    format_waveform_plot(figure)
    axes.set_ylabel('Voltage (volts)')
Exemplo n.º 8
0
def populate_figure(figure):
    axes = figure.add_subplot(1, 1, 1)
    wave, sample_rate = sine_wave(frequency=1000, num_periods=2)
    waveform(axes, wave*0.356, sample_rate)
    format_waveform_plot(figure)
    axes.set_ylabel('Sound pressure (Pa)')