aboutsummaryrefslogtreecommitdiffstats
path: root/maximilian_examples/3.AM1.cpp
diff options
context:
space:
mode:
authormick grierson <mickgrierson@gmail.com>2015-08-27 13:33:41 +0100
committermick grierson <mickgrierson@gmail.com>2015-08-27 13:33:41 +0100
commit5b37d13616c303538a61b520e6930b322e4ff378 (patch)
treea616325e9bdd71ba22fd22ad419963035322e8a0 /maximilian_examples/3.AM1.cpp
parentb155008277cbdba3534ca392d67e2db199d9c458 (diff)
redoing tutorials a bit
Diffstat (limited to 'maximilian_examples/3.AM1.cpp')
-rwxr-xr-xmaximilian_examples/3.AM1.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/maximilian_examples/3.AM1.cpp b/maximilian_examples/3.AM1.cpp
index ec96c7f..384a7f5 100755
--- a/maximilian_examples/3.AM1.cpp
+++ b/maximilian_examples/3.AM1.cpp
@@ -1,15 +1,21 @@
#include "maximilian.h"
-//This shows how to use maximilian to do basic amplitude modulation
+//This shows how to use maximilian to do basic amplitude modulation. Amplitude modulation is when you multiply waves together. In maximilian you just use the * inbetween the two waveforms.
maxiOsc mySine,myOtherSine;//Two oscillators. They can be called anything. They can be any of the available waveforms. These ones will be sinewaves
void setup() {//some inits
- //nothing to go here this time
+ //nothing to go here this time
}
void play(double *output) {
-
- *output=mySine.sinewave(440)*myOtherSine.sinewave(10);
-
+
+ // This form of amplitude modulation is straightforward multiplication of two waveforms.
+ // Notice that the maths is different to when you add waves.
+ // The waves aren't 'beating'. Instead, the amplitude of one is modulating the amplitude of the other
+ // Remember that the sine wave has positive and negative sections as it oscillates.
+ // When you multiply something by -1, its phase is inverted but it retains its amplitude.
+ // So you hear 2 waves per second, not 1, even though the frequency is 1.
+ output[0]=mySine.sinewave(440)*myOtherSine.sinewave(1);
+
}