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/5.FM1.cpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'maximilian_examples/5.FM1.cpp') diff --git a/maximilian_examples/5.FM1.cpp b/maximilian_examples/5.FM1.cpp index c734dcf..14f6593 100755 --- a/maximilian_examples/5.FM1.cpp +++ b/maximilian_examples/5.FM1.cpp @@ -1,14 +1,34 @@ +// One way of thinking about FM synthesis is to see it as vibrato. +// You make a pitch, then vary it up and down at some rate. +// You can change the speed of the pitch variation (modulation frequency), and also the amount of variation (modulation index). +// In FM, usually only one of the waveforms - the carrier that provides the initial pitch - is sent to the output. +// The frequency of the the carrier wave is continually adjusted at a rate equal to the frequency of the second wave (the modulator). +// So at any given point in time, the frequency of the carrier can increase by an amount equal to the current amp of the modulator. +// This has some interesting effects. + #include "maximilian.h" maxiOsc mySine,myOtherSine;//Two oscillators void setup() {//some inits - //nothing to go here this time + //nothing to go here this time } void play(double *output) { - - *output=mySine.sinewave(myOtherSine.sinewave(1)*440); - + + // In this example, the 'myOtherSine.sinewave' is at an amplitude of 1, it's original amplitude. + // This is pretty simple and not too useful. + //output[0]=mySine.sinewave(440*myOtherSine.sinewave(1)); + + // Perhaps you should comment out the above line and uncomment the below one instead + // It shows how the frequency of the carrier is altered by ADDING a second waveform to its frequency value. + // The carrier frequency is 440, and the modulation frequency is 1. + // It also shows how the modulation index works. In this case the modulation index is 100 + // Try adjusting the modolation index. Also, try altering the modulation frequency. + output[0]=mySine.sinewave(440+(myOtherSine.sinewave(1)*100)); + } + +// In complex FM systems you can have lots of modulators stacked together in interesting ways, and theoretically this can make any sound. +// John Chowning is the guy you probably want to talk to about that. \ No newline at end of file -- cgit v1.3