forked from platypush/platypush
Expressed triangular wave as a function of the associated sawtooth-shape wave
This commit is contained in:
parent
debf9a017b
commit
2e82651dbf
1 changed files with 3 additions and 4 deletions
|
@ -145,12 +145,11 @@ class Sound(object):
|
||||||
if self.shape == WaveShape.SQUARE:
|
if self.shape == WaveShape.SQUARE:
|
||||||
wave[wave < 0] = -1
|
wave[wave < 0] = -1
|
||||||
wave[wave >= 0] = 1
|
wave[wave >= 0] = 1
|
||||||
elif self.shape == WaveShape.SAWTOOTH:
|
elif self.shape == WaveShape.SAWTOOTH or self.shape == WaveShape.TRIANG:
|
||||||
wave = 2 * (self.frequency*x -
|
wave = 2 * (self.frequency*x -
|
||||||
np.floor(0.5 + self.frequency*x))
|
np.floor(0.5 + self.frequency*x))
|
||||||
elif self.shape == WaveShape.TRIANG:
|
if self.shape == WaveShape.TRIANG:
|
||||||
wave = 2 * np.abs(2 * (self.frequency*x -
|
wave = 2 * np.abs(wave) - 1
|
||||||
np.floor(0.5 + self.frequency*x))) -1
|
|
||||||
else:
|
else:
|
||||||
raise RuntimeError('Unsupported wave shape: {}'.format(self.shape))
|
raise RuntimeError('Unsupported wave shape: {}'.format(self.shape))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue