コード例 #1
0
ファイル: foldy.py プロジェクト: hecanjog/sketches
def makenote(length, freq, lfo=0.5, amp=0.05, factor=10):
    wavetable = 'tri'
    wtsize = 4096
    ftable = [ v * factor + 1 for v in wavetables.wavetable('random', wtsize) ]
    factors = [ v * ftable[i] for i, v in enumerate(wavetables.wavetable('sine', wtsize)) ]
    osc = oscs.Fold(wavetable, factors, freq, lfo, amp)
    return osc.play(length)
コード例 #2
0
 def test_bad_wavetable_type(self):
     length = random.randint(1, 1000)
     wt = wavetables.wavetable('this is not a wavetable type', length)
     self.assertEqual(length, len(wt))
コード例 #3
0
 def test_random_wavetable(self):
     length = random.randint(1, 1000)
     wt = wavetables.wavetable('random', length)
     self.assertEqual(length, len(wt))
コード例 #4
0
    if i // 4 % 3 == 0:
        hat_onsets = rhythm.onsets([1, 1, 0, 0] * 4, beat)
        for onset in hat_onsets:
            h = hat.copy()
            h.fill(441 * random.randint(10, 30))
            h = h.env('phasor').speed(random.triangular(1, 1.25))
            bar.dub(h * random.triangular(0.25, 0.3), onset)

    kick_onsets = rhythm.onsets([1, 0, 0, 0], beat * 4)
    for onset in kick_onsets:
        k = kick.copy()
        k.fill(441 * random.randint(10, 60))
        k = k.env('phasor').speed(random.triangular(1.4, 1.6))
        bar.dub(k * random.triangular(0.25, 0.35), onset)

    osc.freq = freqs[0] * 0.25
    bass_onsets = rhythm.onsets([0, 0, 1] * 3, beat * 3)
    for onset in bass_onsets:
        osc.wavetable = wavetables.wavetable('square', 512)
        bass = osc.play(beat * random.randint(1, 3)).env('phasor') * 0.08
        bar.dub(bass, onset)

        osc.wavetable = wavetables.wavetable('tri', 512)
        bass = osc.play(beat * random.randint(2, 5)).env('phasor') * 0.35
        bar.dub(bass, onset)

    bar.fill(beat * 16)
    out += bar

out.write('technoish.wav')