aboutsummaryrefslogtreecommitdiffstats
path: root/maximilian_examples/2.TwoTones.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/2.TwoTones.cpp
parentb155008277cbdba3534ca392d67e2db199d9c458 (diff)
redoing tutorials a bit
Diffstat (limited to 'maximilian_examples/2.TwoTones.cpp')
-rwxr-xr-xmaximilian_examples/2.TwoTones.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/maximilian_examples/2.TwoTones.cpp b/maximilian_examples/2.TwoTones.cpp
index 4e22994..fb29288 100755
--- a/maximilian_examples/2.TwoTones.cpp
+++ b/maximilian_examples/2.TwoTones.cpp
@@ -1,14 +1,17 @@
+//This examples shows another fundamental building block of digital audio - adding two sine waves together. When you add waves together they create a new wave whose amplitude at any time is computed by adding the current amplitudes of each wave together. So, if one wave has an amplitude of 1, and the other has an amplitude of 1, the new wave will be equal to 2 at that point in time. Whereas, later, if one wave has an amplitude of -1, and the other has an amplitude of 1, the new wave - the one you hear - will equal 0. This can create some interesting effects, including 'beating', when the waves interact to create a single wave that fades up and down based on the frequencies of the two interacting waves. The frequency of the 'beating' i.e. the fading in and out, is equal to the difference in frequency between the two waves.
+
#include "maximilian.h"
maxiOsc mySine,myOtherSine;//Two oscillators with names.
void setup() {//some inits
- //nothing to go here this time
+ //nothing to go here this time
}
void play(double *output) {//this is where the magic happens. Very slow magic.
-
- *output=mySine.sinewave(440)+myOtherSine.sinewave(441);//these two sines will beat together. They're now a bit too loud though..
-
+
+ //output[0] is the left output. output[1] is the right output
+ output[0]=mySine.sinewave(440)+myOtherSine.sinewave(441);//these two sines will beat together. They're now a bit too loud though..
+
}