annotate examples/07-DataLogging/loggingSensors/render.cpp @ 478:cb875406a594 prerelease

Makefile does syntax check of the project files only (ignores core)
author Giulio Moro <giuliomoro@yahoo.it>
date Mon, 20 Jun 2016 21:38:57 +0100
parents 8fcfbfb32aa0
children
rev   line source
robert@464 1 /*
robert@464 2 ____ _____ _ _
robert@464 3 | __ )| ____| | / \
robert@464 4 | _ \| _| | | / _ \
robert@464 5 | |_) | |___| |___ / ___ \
robert@464 6 |____/|_____|_____/_/ \_\
robert@464 7
robert@464 8 The platform for ultra-low latency audio and sensor processing
robert@464 9
robert@464 10 http://bela.io
robert@464 11
robert@464 12 A project of the Augmented Instruments Laboratory within the
robert@464 13 Centre for Digital Music at Queen Mary University of London.
robert@464 14 http://www.eecs.qmul.ac.uk/~andrewm
robert@464 15
robert@464 16 (c) 2016 Augmented Instruments Laboratory: Andrew McPherson,
robert@464 17 Astrid Bin, Liam Donovan, Christian Heinrichs, Robert Jack,
robert@464 18 Giulio Moro, Laurel Pardue, Victor Zappi. All rights reserved.
robert@464 19
robert@464 20 The Bela software is distributed under the GNU Lesser General Public License
robert@464 21 (LGPL 3.0), available here: https://www.gnu.org/licenses/lgpl-3.0.txt
robert@464 22 */
robert@464 23
robert@464 24
robert@464 25 #include <Bela.h>
robert@464 26 #include <cmath>
robert@464 27 #include <WriteFile.h>
robert@464 28
robert@464 29 WriteFile file1;
robert@464 30 WriteFile file2;
robert@464 31
robert@464 32 bool setup(BelaContext *context, void *userData)
robert@464 33 {
robert@464 34 file1.init("out.bin"); //set the file name to write to
robert@464 35 file1.setEchoInterval(1000);
robert@464 36 file1.setFileType(kBinary);
robert@464 37 file1.setFormat("%.4f %.4f\n"); // set the format that you want to use for your output. Please use %f only (with modifiers). When in binary mode, this is used only for echoing to console
robert@464 38 file2.init("out.m"); //set the file name to write to
robert@464 39 file2.setHeader("myvar=[\n"); //set one or more lines to be printed at the beginning of the file
robert@464 40 file2.setFooter("];\n"); //set one or more lines to be printed at the end of the file
robert@464 41 file2.setFormat("%.4f\n"); // set the format that you want to use for your output. Please use %f only (with modifiers)
robert@464 42 file2.setFileType(kText);
robert@464 43 file2.setEchoInterval(10000); // only print to the console 1 line every other 10000
robert@464 44 return true;
robert@464 45 }
robert@464 46
robert@464 47 void render(BelaContext *context, void *userData)
robert@464 48 {
robert@464 49 for(unsigned int n = 0; n < context->analogFrames; n++) {
robert@464 50 file1.log(&(context->analogIn[n*context->analogFrames]), 2); // log an array of values
robert@464 51 file2.log(context->analogIn[n*context->analogFrames]); // log a single value
robert@464 52 }
robert@464 53 }
robert@464 54
robert@464 55 // cleanup_render() is called once at the end, after the audio has stopped.
robert@464 56 // Release any resources that were allocated in initialise_render().
robert@464 57
robert@464 58 void cleanup(BelaContext *context, void *userData)
robert@464 59 {
robert@464 60
robert@464 61 }
robert@464 62
robert@464 63 /* ------------ Project Explantation ------------ */
robert@464 64
robert@464 65 /**
robert@464 66 \example 07-logging-sensors
robert@464 67
robert@464 68 Logging Sensor Data
robert@464 69 ---------------------------
robert@464 70
robert@464 71 This sketch demonstrates how to log sensor data for later processing or analysis.
robert@464 72 */
robert@464 73