def impulse(self, amp, width, pan, hz): width = int(dsp.htf(hz) * math.fabs(width)) snd = dsp.cycle(dsp.fth(width)) snd = dsp.amp(snd, amp) snd = dsp.pan(snd, pan) snd = dsp.pad(snd, 0, dsp.htf(hz) - dsp.flen(snd)) return snd
def train(self, length, hz): num = int(length / dsp.htf(hz)) print dsp.fts(length), hz amp = self.pop(num) wtables = ['gauss', 'line', 'phasor'] + ['vary' for v in range(12)] width = dsp.wavetable(wtables[int(self.rpop(0, 14))], num, self.rpop(0.0, 2.5), self.rpop(2.5, 5.0), self.rpop) # Not random anymore, yay! pan = self.pop(num) return ''.join([ self.impulse(amp[i], width[i], pan[i], hz) for i in range(num) ])
def test_lengths(self): freqs = range(1, 20000, 200) for freq in freqs: self.assertEqual(dsp.flen(dsp.cycle(freq, 'random')), dsp.htf(freq))