Mercurial > hg > beaglert
diff projects/basic/render.cpp @ 180:07cfd337ad18
Updated examples with new audioWrite macros
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Sat, 02 Jan 2016 13:55:01 +0100 |
parents | 3c3a1357657d |
children | ac8eb07afcf5 |
line wrap: on
line diff
--- a/projects/basic/render.cpp Sat Jan 02 13:50:36 2016 +0100 +++ b/projects/basic/render.cpp Sat Jan 02 13:55:01 2016 +0100 @@ -8,6 +8,7 @@ #include <BeagleRT.h> #include <cmath> +#include <Utilities.h> float gFrequency = 440.0; float gPhase; @@ -47,8 +48,15 @@ if(gPhase > 2.0 * M_PI) gPhase -= 2.0 * M_PI; - for(unsigned int channel = 0; channel < context->audioChannels; channel++) - context->audioOut[n * context->audioChannels + channel] = out; + for(unsigned int channel = 0; channel < context->audioChannels; channel++) { + // Two equivalent ways to write this code + + // The long way, using the buffers directly: + // context->audioOut[n * context->audioChannels + channel] = out; + + // Or using the macros: + audioWriteFrame(context, n, channel, out); + } } }