comparison examples/samples/render.cpp @ 375:768acdeea362 prerelease

Merge
author Giulio Moro <giuliomoro@yahoo.it>
date Fri, 10 Jun 2016 00:35:18 +0100
parents db2fe4e1b88e
children
comparison
equal deleted inserted replaced
374:ecad1ea0382a 375:768acdeea362
1 /* 1 /*
2 * render.cpp 2 ____ _____ _ _
3 * 3 | __ )| ____| | / \
4 * Created on: Oct 24, 2014 4 | _ \| _| | | / _ \
5 * Author: Andrew McPherson and Victor Zappi 5 | |_) | |___| |___ / ___ \
6 |____/|_____|_____/_/ \_\.io
7
6 */ 8 */
7 9
10 /*
11 *
12 * Andrew McPherson and Victor Zappi
13 * Queen Mary, University of London
14 */
15
16 /**
17 \example 4_audio_samples
18
19 Playback WAV files
20 ------------------
21
22 This sketch shows how to playback audio samples from a buffer.
23
24 An audio file is loaded into a buffer `SampleData` as `gSampleData`. This is
25 accessed with a read pointer that is incremented at audio rate within the render
26 function: `out += gSampleData.samples[gReadPtr++]`.
27
28 Note that the read pointer is stopped from incrementing past the length of the
29 `gSampleData`. This is achieved by comparing the read pointer value against the
30 sample length which we can access as follows: `gSampleData.sampleLen`.
31
32 The sample is triggered by keyboard input: (a) starts sample playback, (s)
33 stops sample playback. The triggering is treated as a lower priority task than
34 the audio. You can see this at the bottom of the render function:
35 `Bela_scheduleAuxiliaryTask(gTriggerSamplesTask)`;
36 */
8 37
9 #include <Bela.h> 38 #include <Bela.h>
10 #include <cmath> 39 #include <cmath>
11 #include "SampleData.h" 40 #include "SampleData.h"
12 41