From 5b37d13616c303538a61b520e6930b322e4ff378 Mon Sep 17 00:00:00 2001 From: mick grierson Date: Thu, 27 Aug 2015 13:33:41 +0100 Subject: redoing tutorials a bit --- maximilian_examples/2.TwoTones.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'maximilian_examples/2.TwoTones.cpp') 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.. + } -- cgit v1.3