aboutsummaryrefslogtreecommitdiffstats
path: root/maximilian.cpp
diff options
context:
space:
mode:
authorMick Grierson <mickgrierson@strangebook.lan>2011-10-22 21:09:54 +0100
committerMick Grierson <mickgrierson@strangebook.lan>2011-10-22 21:09:54 +0100
commit6bb3b92852d9d7f4efb63994bf818b5a01ca86b9 (patch)
tree77eae09ffeab32ef9f57b43a2e94bce8722d71fe /maximilian.cpp
parent948f46623d24fac7aa41172434f7e8d46ce21ce1 (diff)
fixed the triangle waveform generator. Added some samples to test the drum machine example with
Diffstat (limited to 'maximilian.cpp')
-rw-r--r--maximilian.cpp16
1 files changed, 10 insertions, 6 deletions
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);