Skip to content

Commit

Permalink
Merge pull request #3 from AntiMatterAMA/master
Browse files Browse the repository at this point in the history
added triangle waveform support
  • Loading branch information
yuma-m authored Mar 17, 2019
2 parents 64dcef6 + ab494e8 commit 32e22d2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion synthesizer/synthesizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Waveform(Enum):
sine = "sine"
sawtooth = "sawtooth"
square = "square"
triangle = "triangle"


class Oscillator(object):
Expand Down Expand Up @@ -36,12 +37,16 @@ def _wave_func(self):
return scipy.signal.sawtooth
elif self._waveform is Waveform.square:
return scipy.signal.square
elif self._waveform is Waveform.triangle:
return self.gen_triang
raise TypeError("unknown waveform: {}".format(self._waveform))

def generate_wave(self, phases):
phases = np.copy(phases) * self._freq_transpose
return self._volume * self._wave_func(phases)


def gen_triang(self,t,width=0.5):
return scipy.signal.sawtooth(t,width)

class Synthesizer(object):
u""" Virtual analog synthesizer object
Expand Down

0 comments on commit 32e22d2

Please sign in to comment.