comparison examples/basic_passthru/render.cpp @ 300:dbeed520b014 prerelease

Renamed projects to examples
author Giulio Moro <giuliomoro@yahoo.it>
date Fri, 27 May 2016 13:58:20 +0100
parents projects/basic_passthru/render.cpp@07cfd337ad18
children e4392164b458
comparison
equal deleted inserted replaced
297:a3d83ebdf49b 300:dbeed520b014
1 /*
2 * render.cpp
3 *
4 * Created on: Oct 24, 2014
5 * Author: parallels
6 */
7
8
9 #include <BeagleRT.h>
10 #include <Utilities.h>
11 #include <rtdk.h>
12
13 // setup() is called once before the audio rendering starts.
14 // Use it to perform any initialisation and allocation which is dependent
15 // on the period size or sample rate.
16 //
17 // userData holds an opaque pointer to a data structure that was passed
18 // in from the call to initAudio().
19 //
20 // Return true on success; returning false halts the program.
21
22 bool setup(BeagleRTContext *context, void *userData)
23 {
24 // Nothing to do here...
25 return true;
26 }
27
28 // render() is called regularly at the highest priority by the audio engine.
29 // Input and output are given from the audio hardware and the other
30 // ADCs and DACs (if available). If only audio is available, numMatrixFrames
31 // will be 0.
32
33 void render(BeagleRTContext *context, void *userData)
34 {
35 // Simplest possible case: pass inputs through to outputs
36 for(unsigned int n = 0; n < context->audioFrames; n++) {
37 for(unsigned int ch = 0; ch < context->audioChannels; ch++){
38 // Two equivalent ways to write this code
39
40 // The long way, using the buffers directly:
41 // context->audioOut[n * context->audioChannels + ch] =
42 // context->audioIn[n * context->audioChannels + ch];
43
44 // Or using the macros:
45 audioWriteFrame(context, n, ch, audioReadFrame(context, n, ch));
46 }
47 }
48
49 // Same with analog channelss
50 for(unsigned int n = 0; n < context->analogFrames; n++) {
51 for(unsigned int ch = 0; ch < context->analogChannels; ch++) {
52 // Two equivalent ways to write this code
53
54 // The long way, using the buffers directly:
55 // context->analogOut[n * context->analogChannels + ch] = context->analogIn[n * context->analogChannels + ch];
56
57 // Or using the macros:
58 analogWriteFrame(context, n, ch, analogReadFrame(context, n, ch));
59 }
60 }
61 }
62
63 // cleanup() is called once at the end, after the audio has stopped.
64 // Release any resources that were allocated in setup().
65
66 void cleanup(BeagleRTContext *context, void *userData)
67 {
68
69 }