From 6bb3b92852d9d7f4efb63994bf818b5a01ca86b9 Mon Sep 17 00:00:00 2001 From: Mick Grierson Date: Sat, 22 Oct 2011 21:09:54 +0100 Subject: fixed the triangle waveform generator. Added some samples to test the drum machine example with --- maximilian.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'maximilian.cpp') diff --git a/maximilian.cpp b/maximilian.cpp index d55793d..92f1292 100644 --- a/maximilian.cpp +++ b/maximilian.cpp @@ -66,6 +66,11 @@ double maxiOsc::noise() { return(output); } +void maxiOsc::phaseReset(double phaseIn) { + phase=phaseIn; + +} + double maxiOsc::sinewave(double frequency) { output=sin (phase*(TWOPI)); if ( phase >= 1.0 ) phase -= 1.0; @@ -164,14 +169,13 @@ double maxiOsc::saw(double frequency) { } -double maxiOsc::triangle(double frequency, double phase) { - output=tri*2; +double maxiOsc::triangle(double frequency) { if ( phase >= 1.0 ) phase -= 1.0; - phase += (1./(maxiSettings::sampleRate/(frequency*chandiv))); + phase += (1./(maxiSettings::sampleRate/(frequency))); if (phase <= 0.5 ) { - tri = phase; - } else { - tri =(1-phase); + output =((phase)*4)-1; + } else { + output =((0.5-phase)*4)-1; } return(output); -- cgit v1.3