robert@501: /* robert@501: ____ _____ _ _ robert@501: | __ )| ____| | / \ robert@501: | _ \| _| | | / _ \ robert@501: | |_) | |___| |___ / ___ \ robert@501: |____/|_____|_____/_/ \_\ robert@501: robert@501: The platform for ultra-low latency audio and sensor processing robert@501: robert@501: http://bela.io robert@501: robert@501: A project of the Augmented Instruments Laboratory within the robert@501: Centre for Digital Music at Queen Mary University of London. robert@501: http://www.eecs.qmul.ac.uk/~andrewm robert@501: robert@501: (c) 2016 Augmented Instruments Laboratory: Andrew McPherson, robert@501: Astrid Bin, Liam Donovan, Christian Heinrichs, Robert Jack, robert@501: Giulio Moro, Laurel Pardue, Victor Zappi. All rights reserved. robert@501: robert@501: The Bela software is distributed under the GNU Lesser General Public License robert@501: (LGPL 3.0), available here: https://www.gnu.org/licenses/lgpl-3.0.txt robert@501: */ robert@501: robert@501: robert@501: #include robert@501: #include robert@501: #include robert@501: robert@501: WriteFile file1; robert@501: WriteFile file2; robert@501: robert@501: bool setup(BelaContext *context, void *userData) robert@501: { robert@501: file1.init("out.bin"); //set the file name to write to robert@501: file1.setEchoInterval(1000); robert@501: file1.setFileType(kBinary); robert@501: 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: file2.init("out.m"); //set the file name to write to robert@501: file2.setHeader("myvar=[\n"); //set one or more lines to be printed at the beginning of the file robert@501: file2.setFooter("];\n"); //set one or more lines to be printed at the end of the file robert@501: file2.setFormat("%.4f\n"); // set the format that you want to use for your output. Please use %f only (with modifiers) robert@501: file2.setFileType(kText); robert@501: file2.setEchoInterval(10000); // only print to the console 1 line every other 10000 robert@501: return true; robert@501: } robert@501: robert@501: void render(BelaContext *context, void *userData) robert@501: { robert@501: for(unsigned int n = 0; n < context->analogFrames; n++) { robert@501: file1.log(&(context->analogIn[n*context->analogFrames]), 2); // log an array of values robert@501: file2.log(context->analogIn[n*context->analogFrames]); // log a single value robert@501: } robert@501: } robert@501: robert@501: // cleanup_render() is called once at the end, after the audio has stopped. robert@501: // Release any resources that were allocated in initialise_render(). robert@501: robert@501: void cleanup(BelaContext *context, void *userData) robert@501: { robert@501: robert@501: } robert@501: robert@501: /* ------------ Project Explantation ------------ */ robert@501: robert@501: /** robert@502: \example logging-sensors/render.cpp robert@501: robert@501: Logging Sensor Data robert@501: --------------------------- robert@501: robert@501: This sketch demonstrates how to log sensor data for later processing or analysis. robert@501: */ robert@501: