comparison examples/07-DataLogging/logging-sensors/render.cpp @ 501:6962184f8567 prerelease

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