annotate examples/01-Basics/minimal/render.cpp @ 500:b935f890e512 prerelease

Updated Doxy to 1.8.11 Amended example titles in render.cpp and file locations in Doxy file.
author Robert Jack <robert.h.jack@gmail.com>
date Wed, 22 Jun 2016 00:27:13 +0100
parents 8fcfbfb32aa0
children 1cec96845a23
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 #include <Bela.h>
robert@464 25
robert@464 26
robert@464 27 // setup() is called once before the audio rendering starts.
robert@464 28 // Use it to perform any initialisation and allocation which is dependent
robert@464 29 // on the period size or sample rate.
robert@464 30 //
robert@464 31 // userData holds an opaque pointer to a data structure that was passed
robert@464 32 // in from the call to initAudio().
robert@464 33 //
robert@464 34 // Return true on success; returning false halts the program.
robert@464 35 bool setup(BelaContext *context, void *userData)
robert@464 36 {
robert@464 37 return true;
robert@464 38 }
robert@464 39
robert@464 40 // render() is called regularly at the highest priority by the audio engine.
robert@464 41 // Input and output are given from the audio hardware and the other
robert@464 42 // ADCs and DACs (if available). If only audio is available, numMatrixFrames
robert@464 43 // will be 0.
robert@464 44 void render(BelaContext *context, void *userData)
robert@464 45 {
robert@464 46
robert@464 47 }
robert@464 48
robert@464 49 // cleanup() is called once at the end, after the audio has stopped.
robert@464 50 // Release any resources that were allocated in setup().
robert@464 51 void cleanup(BelaContext *context, void *userData)
robert@464 52 {
robert@464 53
robert@464 54 }
robert@464 55
robert@464 56 /* ------------ Project Explantation ------------ */
robert@464 57
robert@464 58 /**
robert@464 59
robert@500 60 \example minimal/render.cpp
robert@464 61
robert@464 62 The bare bones
robert@464 63 ----------------------
robert@464 64
robert@464 65 The structure of a render.cpp file
robert@464 66 ----------------------------------
robert@464 67 A render.cpp file has three functions: `setup()`, `render()` and `cleanup()`.
robert@464 68
robert@464 69 `setup()` is an initialisation function which runs before audio rendering begins.
robert@464 70 It is called once when the project starts. Use it to prepare any memory or
robert@464 71 resources that will be needed in `render()`.
robert@464 72
robert@464 73 `render()` is a function that is regularly called, over and over continuously, at
robert@464 74 the highest priority by the audio engine. It is used to process audio and
robert@464 75 sensor data. This function is called regularly by the system every time there
robert@464 76 is a new block of audio and/or sensor data to process.
robert@464 77
robert@464 78 `cleanup()` is a function that is called when the program stops, to finish up any
robert@464 79 processes that might still be running.
robert@464 80
robert@464 81 Here we will briefly explain each function and the structure of the render.cpp
robert@464 82
robert@464 83 Before any of the functions
robert@464 84 ---------------------------
robert@464 85 At the top of the file, include any libraries you might need.
robert@464 86
robert@464 87 Additionally, declare any global variables. In these tutorial sketches, all
robert@464 88 global variables are preceded by a `g` so we always know which variables are
robert@464 89 global - `gSampleData`, for example. It's not mandatory but is a really good way
robert@464 90 of keeping track of what's global and what's not.
robert@464 91
robert@464 92 Sometimes it's necessary to access a variable from another file, such as
robert@464 93 main.cpp. In this case, precede this variable with the keyword `extern`.
robert@464 94
robert@464 95 Function arguments
robert@464 96 ------------------
robert@464 97 `setup()`, `render()` and `cleanup()` each take the same arguments. These are:
robert@464 98
robert@464 99 `0ext *context`
robert@464 100 `void *userData`
robert@464 101
robert@464 102 These arguments are pointers to data structures. The main one that's used is
robert@464 103 `context`, which is a pointer to a data structure containing lots of information
robert@464 104 you need.
robert@464 105
robert@464 106 Take a look at what's in the data structure [here]
robert@464 107 (https://code.soundsoftware.ac.uk/projects/beaglert/embedded/structBeagleRTContext.html).
robert@464 108
robert@464 109 You can access any of these bits of information about current audio and sensor
robert@464 110 settings and pointers to data buffers that are contained in the data structure
robert@464 111 like this: `context->name_of_item`.
robert@464 112
robert@464 113 For example, `context->audioChannels` returns the number of audio channels.
robert@464 114 `context->audioSampleRate` returns the audio sample rate.
robert@464 115 `context->audioIn[n]` would give you the current input sample (assuming that
robert@464 116 your input is mono - if it's not you will have to account for multiple channels).
robert@464 117
robert@464 118 Note that `audioIn`, `audioOut`, `analogIn`, `analogOut` are all arrays (buffers).
robert@464 119
robert@464 120 */