Exemple #1
0
 def test_harmonics(self):
     wt = dsp.wt('sine')
     wt = wt.harmonics()
     wt.graph('tests/renders/graph_harmonics.png', stroke=3)
     osc = Osc(wt, freq=80)
     out = osc.play(10)
     out.write('tests/renders/osc_harmonics.wav')
Exemple #2
0
 def test_harmonics(self):
     wt = dsp.wt('sine')
     wt = wt.harmonics()
     wt.graph('tests/renders/graph_harmonics.png', stroke=3)
     osc = Osc(wt, freq=80)
     out = osc.play(10)
     out.write('tests/renders/osc_harmonics.wav')
Exemple #3
0
 def test_bandlimiting_osc(self):
     sr = 44100
     time = 4
     length = sr * time
     sweep = np.logspace(0, 9, length, base = 2) * 30
     out = Osc('tri', freq=sweep, quality=6).play(time)
     out.write('tests/renders/osc_bl.wav')
Exemple #4
0
    def test_fm_osc(self):
        pm = Osc('sine', freq=200.0).play(1).env('tri') * 1000
        out = Osc('sine', freq=pm).play(1)
        out.write('tests/renders/osc_fm.wav')

        pm = Osc('sine', freq=[200.0, 300, 400], freq_interpolator='trunc').play(1).env('tri') * 1000
        out = Osc('sine', freq=pm).play(1)
        out.write('tests/renders/osc_fm_trunc.wav')
Exemple #5
0
    def test_create_sinewave(self):
        osc = Osc('sine', freq=200.0)
        length = 1
        out = osc.play(length)
        out.write('tests/renders/osc_sinewave.wav')
        self.assertEqual(len(out), int(length * out.samplerate))

        wtA = [ random.random() for _ in range(random.randint(10, 1000)) ]
        osc = Osc(wtA, freq=200.0)
        length = 1
        out = osc.play(length)
        out.write('tests/renders/osc_rand_list_wt.wav')
        self.assertEqual(len(out), int(length * out.samplerate))

        wtB = dsp.wt([ random.random() for _ in range(random.randint(10, 1000)) ])
        osc = Osc(wtB, freq=200.0)
        length = 1
        out = osc.play(length)
        out.write('tests/renders/osc_rand_wt_wt.wav')
        self.assertEqual(len(out), int(length * out.samplerate))

        wtC = SoundBuffer(filename='tests/sounds/guitar1s.wav')
        osc = Osc(wtC, freq=200.0)
        length = 1
        out = osc.play(length)
        out.write('tests/renders/osc_guitar_wt.wav')
        self.assertEqual(len(out), int(length * out.samplerate))
    def __init__(self, params):
        buff = SoundBuffer(channels=1)
        length = 1
        if params.isNoise == 1:
            buff = noise.bln(params.getOscType(),
                             params.getLength(),
                             30,
                             150000,
                             channels=1)
        else:
            buff = Osc(str(params.getOscType()),
                       freq=list(params.getPitches()),
                       channels=1).play(params.getLength())

        buff = buff.adsr(a=params.A, d=params.D, s=params.S, r=params.R)
        bpfilter = params.getBandPass()
        buff.frames = helpers.butter_bandpass_filter(buff.frames,
                                                     bpfilter[0],
                                                     bpfilter[1],
                                                     sr,
                                                     order=bpfilter[2])
        #a high pass
        buff.frames = helpers.butter_bandpass_filter(buff.frames,
                                                     80,
                                                     15000,
                                                     sr,
                                                     order=8)
        self.buff = buff
    def __init__(self, params):
        buff = SoundBuffer(channels=1)
        length = 1
        if params.isNoise == 1:
            buff = noise.bln(str(params.oscType),
                             params.length,
                             30,
                             150000,
                             channels=1)
        else:
            buff = Osc(str(params.oscType), freq=params.pitches,
                       channels=1).play(params.length)

        buff = buff.adsr(a=params.A, d=params.D, s=params.S, r=params.R)
        buff.frames = butter_bandpass_filter(buff.frames,
                                             params.bpCutLow,
                                             params.bpCutHigh,
                                             sr,
                                             order=params.bpOrder)
        self.buff = buff
Exemple #8
0
    def test_create_sinewave(self):
        osc = Osc('sine', freq=200.0)
        length = 1
        out = osc.play(length)
        out.write('tests/renders/osc_sinewave.wav')
        self.assertEqual(len(out), int(length * out.samplerate))

        wtA = [random.random() for _ in range(random.randint(10, 1000))]
        osc = Osc(wtA, freq=200.0)
        length = 1
        out = osc.play(length)
        out.write('tests/renders/osc_rand_list_wt.wav')
        self.assertEqual(len(out), int(length * out.samplerate))

        wtB = dsp.wt(
            [random.random() for _ in range(random.randint(10, 1000))])
        osc = Osc(wtB, freq=200.0)
        length = 1
        out = osc.play(length)
        out.write('tests/renders/osc_rand_wt_wt.wav')
        self.assertEqual(len(out), int(length * out.samplerate))

        wtC = SoundBuffer(filename='tests/sounds/guitar1s.wav')
        osc = Osc(wtC, freq=200.0)
        length = 1
        out = osc.play(length)
        out.write('tests/renders/osc_guitar_wt.wav')
        self.assertEqual(len(out), int(length * out.samplerate))
Exemple #9
0
 def test_pm_osc(self):
     pmtest = Osc('sine', freq=[0, 800, 0], quality=6).play(1).env('tri')
     out = Osc('sine', freq=200, pm = pmtest, quality=6).play(1).env("tri")
     out.write('tests/renders/osc_pm.wav')
Exemple #10
0
import random

from pippi import dsp
from pippi.oscs import Osc

# Create a wavetable osc with a randomly 
# selected waveform type
osc = Osc(freq=440, wavetable=dsp.RND)

# Length in seconds
length = 1

# Fill a SoundBuffer with output from the osc
out = osc.play(length) * 0.5

# Write the output buffer to a WAV file
out.write('simple_osc.wav')
Exemple #11
0
 def test_fm_osc(self):
     pm = Osc('sine', freq=200.0).play(1).env('tri') * 1000
     out = Osc('sine', freq=pm).play(1)
     out.write('tests/renders/osc_fm.wav')
Exemple #12
0
import random

from pippi.oscs import Osc

waveform_types = ['square', 'sine', 'triangle', 'saw', 'rsaw', 'cosine']

# Create a wavetable osc with a randomly
# selected waveform type
osc = Osc(freq=440, wavetable=random.choice(waveform_types))

# Length in frames
length = 44100

# Fill a SoundBuffer with output from the osc
out = osc.play(length, amp=0.5)

# Write the output buffer to a WAV file
out.write('simple_osc.wav')
Exemple #13
0
    def test_create_sinewave(self):
        osc = Osc(dsp.SINE, random.triangular(20, 20000))
        length = random.triangular(0.01, 1)
        out = osc.play(length)

        self.assertEqual(len(out), int(length * out.samplerate))
Exemple #14
0
    def test_create_sinewave(self):
        osc = Osc(random.triangular(20, 20000), wavetable='sine')
        length = random.randint(1, 44100)
        out = osc.play(length)

        self.assertEqual(len(out), length)