Mercurial > hg > beaglert
diff projects/basic_analog_output/render.cpp @ 56:3c3a1357657d newapi
Further API update to name three primary functions setup(), render() and cleanup(). Changed include paths so now can #include <BeagleRT.h>. Removed stale pru_rtaudio.bin file as this is now done as pru_rtaudio_bin.h. Updated examples to new API and fixed minor compiler warnings along the way. Network example needs further attention to compile.
author | andrewm |
---|---|
date | Wed, 15 Jul 2015 12:10:51 +0100 |
parents | a6d223473ea2 |
children | ac8eb07afcf5 |
line wrap: on
line diff
--- a/projects/basic_analog_output/render.cpp Mon Jun 15 18:16:00 2015 +0100 +++ b/projects/basic_analog_output/render.cpp Wed Jul 15 12:10:51 2015 +0100 @@ -6,8 +6,8 @@ */ -#include "../../include/BeagleRT.h" -#include "../../include/Utilities.h" +#include <BeagleRT.h> +#include <Utilities.h> #include <rtdk.h> #include <cmath> @@ -19,7 +19,7 @@ float gPhase; float gInverseSampleRate; -// initialise_render() is called once before the audio rendering starts. +// setup() is called once before the audio rendering starts. // Use it to perform any initialisation and allocation which is dependent // on the period size or sample rate. // @@ -28,7 +28,7 @@ // // Return true on success; returning false halts the program. -bool initialise_render(BeagleRTContext *context, void *userData) +bool setup(BeagleRTContext *context, void *userData) { // Retrieve a parameter passed in from the initAudio() call gFrequency = *(float *)userData; @@ -51,10 +51,10 @@ void render(BeagleRTContext *context, void *userData) { - for(int n = 0; n < context->analogFrames; n++) { + for(unsigned int n = 0; n < context->analogFrames; n++) { // Set LED to different phase for each matrix channel float relativePhase = 0.0; - for(int channel = 0; channel < context->analogChannels; channel++) { + for(unsigned int channel = 0; channel < context->analogChannels; channel++) { float out = kMinimumAmplitude + kAmplitudeRange * 0.5f * (1.0f + sinf(gPhase + relativePhase)); analogWriteFrame(context, n, channel, out); @@ -69,10 +69,10 @@ } } -// cleanup_render() is called once at the end, after the audio has stopped. -// Release any resources that were allocated in initialise_render(). +// cleanup() is called once at the end, after the audio has stopped. +// Release any resources that were allocated in setup(). -void cleanup_render(BeagleRTContext *context, void *userData) +void cleanup(BeagleRTContext *context, void *userData) { }