From 2e82651dbfdb2e892cfe69a79519c0882e786d5a Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Thu, 27 Dec 2018 17:33:05 +0100 Subject: [PATCH] Expressed triangular wave as a function of the associated sawtooth-shape wave --- platypush/plugins/sound/core.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/platypush/plugins/sound/core.py b/platypush/plugins/sound/core.py index bbca23c0a..c3282e543 100644 --- a/platypush/plugins/sound/core.py +++ b/platypush/plugins/sound/core.py @@ -145,12 +145,11 @@ class Sound(object): if self.shape == WaveShape.SQUARE: 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 - np.floor(0.5 + self.frequency*x)) - elif self.shape == WaveShape.TRIANG: - wave = 2 * np.abs(2 * (self.frequency*x - - np.floor(0.5 + self.frequency*x))) -1 + if self.shape == WaveShape.TRIANG: + wave = 2 * np.abs(wave) - 1 else: raise RuntimeError('Unsupported wave shape: {}'.format(self.shape))