示例#1
0
def bias():
    from matplotlib import pyplot as plot
    synth = WaveSynth(samplerate=1000)
    waves = [synth.sine(2, 4, 0.02, bias=0.1),
             synth.triangle(2, 4, 0.02, bias=0.2),
             synth.pulse(2, 4, 0.02, bias=0.3, pulsewidth=0.45),
             synth.harmonics(2, 4, [(n, 1 / n) for n in range(1, 8)], 0.02, bias=0.4),
             synth.sawtooth(2, 4, 0.02, bias=0.5),
             synth.sawtooth_h(2, 4, 7, 0.02, bias=0.6),
             synth.square(2, 4, 0.02, bias=0.7),
             synth.square_h(2, 4, 7, 0.02, bias=0.8),
             synth.white_noise(frequency=100, duration=4, amplitude=0.02, bias=0.9)]
    for wave in waves:
        plot.plot(wave.get_frame_array())
    plot.title("All waveforms biased to levels above zero")
    plot.show()
示例#2
0
def demo_plot():
    from matplotlib import pyplot as plot
    plot.title("Various waveforms")
    synth = WaveSynth(samplerate=1000)
    freq = 4
    s = synth.sawtooth(freq, duration=1)
    plot.plot(s.get_frame_array())
    s = synth.sine(freq, duration=1)
    plot.plot(s.get_frame_array())
    s = synth.triangle(freq, duration=1)
    plot.plot(s.get_frame_array())
    s = synth.square(freq, duration=1)
    plot.plot(s.get_frame_array())
    s = synth.square_h(freq, duration=1)
    plot.plot(s.get_frame_array())
    s = synth.pulse(freq, duration=1, pulsewidth=0.2)
    plot.plot(s.get_frame_array())
    plot.show()