Mercurial > hg > beaglert
diff 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 |
line wrap: on
line diff
--- a/examples/samples/render.cpp Fri Jun 10 00:02:48 2016 +0100 +++ b/examples/samples/render.cpp Fri Jun 10 00:35:18 2016 +0100 @@ -1,10 +1,39 @@ /* - * render.cpp - * - * Created on: Oct 24, 2014 - * Author: Andrew McPherson and Victor Zappi + ____ _____ _ _ +| __ )| ____| | / \ +| _ \| _| | | / _ \ +| |_) | |___| |___ / ___ \ +|____/|_____|_____/_/ \_\.io + */ +/* + * + * Andrew McPherson and Victor Zappi + * Queen Mary, University of London + */ + +/** +\example 4_audio_samples + +Playback WAV files +------------------ + +This sketch shows how to playback audio samples from a buffer. + +An audio file is loaded into a buffer `SampleData` as `gSampleData`. This is +accessed with a read pointer that is incremented at audio rate within the render +function: `out += gSampleData.samples[gReadPtr++]`. + +Note that the read pointer is stopped from incrementing past the length of the +`gSampleData`. This is achieved by comparing the read pointer value against the +sample length which we can access as follows: `gSampleData.sampleLen`. + +The sample is triggered by keyboard input: (a) starts sample playback, (s) +stops sample playback. The triggering is treated as a lower priority task than +the audio. You can see this at the bottom of the render function: +`Bela_scheduleAuxiliaryTask(gTriggerSamplesTask)`; +*/ #include <Bela.h> #include <cmath>