Last active
June 19, 2016 19:45
-
-
Save grav/fb1c729e691ac3b08a32c142b9cace7c to your computer and use it in GitHub Desktop.
Simple oscillator in python, using pyext (http://grrrr.org/research/software/py/)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class osc(pyext._class): | |
t = 0.0 | |
f = 0.0 | |
def bang_3(self): | |
print "SR:",self._samplerate(),"BS:",self._blocksize(),"F:",self.f | |
def _dsp(self): | |
# if _dsp is present it must return True to enable DSP | |
return pyext._arraysupport() | |
def _signal(self): | |
# not great, since | |
# only allow f to change once per block | |
self.f = self._invec(0)[0] | |
d = self.f*2*pi*(self._blocksize()/self._samplerate()) | |
self._outvec(0)[:] = np.sin(np.linspace(self.t,self.t+d,self._blocksize())) | |
self.t += d | |
if self.t > 2.0*pi: | |
self.t -= 2.0*pi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment