diff options
Diffstat (limited to 'maximilian_examples/3.AM1.cpp')
| -rwxr-xr-x | maximilian_examples/3.AM1.cpp | 16 |
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); + } |
