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