Mercurial > hg > beaglert
comparison examples/01-Basics/passthrough/render.cpp @ 537:bfcbeb437869 API-update
Updated RTAudioSettings with in/out, ported some examples and libpd
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Fri, 24 Jun 2016 01:36:07 +0100 |
parents | 5c8f46fcd4d0 |
children | 8f8809c77dda |
comparison
equal
deleted
inserted
replaced
528:5c8f46fcd4d0 | 537:bfcbeb437869 |
---|---|
20 The Bela software is distributed under the GNU Lesser General Public License | 20 The Bela software is distributed under the GNU Lesser General Public License |
21 (LGPL 3.0), available here: https://www.gnu.org/licenses/lgpl-3.0.txt | 21 (LGPL 3.0), available here: https://www.gnu.org/licenses/lgpl-3.0.txt |
22 */ | 22 */ |
23 | 23 |
24 #include <Bela.h> | 24 #include <Bela.h> |
25 #include <Scope.h> | |
26 | |
27 Scope scope; | |
28 | 25 |
29 bool setup(BelaContext *context, void *userData) | 26 bool setup(BelaContext *context, void *userData) |
30 { | 27 { |
31 // Nothing to do here... | 28 // Nothing to do here... |
32 printf("%d %d\n", context->audioInChannels, context->audioOutChannels); | 29 if(context->audioInChannels != context->audioOutChannels || |
33 scope.setup(8, 44100); | 30 context->analogInChannels != context-> analogOutChannels){ |
31 printf("Error: for this project, you need the same number of input and output channels.\n"); | |
32 return false; | |
33 } | |
34 return true; | 34 return true; |
35 } | 35 } |
36 | 36 |
37 void render(BelaContext *context, void *userData) | 37 void render(BelaContext *context, void *userData) |
38 { | 38 { |
39 static const unsigned int audioChannels = min(context->audioInChannels, context->audioOutChannels); | |
40 static const unsigned int analogChannels = min(context->analogInChannels, context->analogOutChannels); | |
41 | 39 |
42 // Simplest possible case: pass inputs through to outputs | 40 // Simplest possible case: pass inputs through to outputs |
43 for(unsigned int n = 0; n < context->audioFrames; n++) { | 41 for(unsigned int n = 0; n < context->audioFrames; n++) { |
44 for(unsigned int ch = 0; ch < audioChannels; ch++){ | 42 for(unsigned int ch = 0; ch < context->audioInChannels; ch++){ |
45 // Two equivalent ways to write this code | 43 // Two equivalent ways to write this code |
46 | 44 |
47 // The long way, using the buffers directly: | 45 // The long way, using the buffers directly: |
48 // context->audioOut[n * context->audioOutChannels + ch] = | 46 // context->audioOut[n * context->audioOutChannels + ch] = |
49 // context->audioIn[n * context->audioInChannels + ch]; | 47 // context->audioIn[n * context->audioInChannels + ch]; |
53 } | 51 } |
54 } | 52 } |
55 | 53 |
56 // Same with analog channels | 54 // Same with analog channels |
57 for(unsigned int n = 0; n < context->analogFrames; n++) { | 55 for(unsigned int n = 0; n < context->analogFrames; n++) { |
58 for(unsigned int ch = 0; ch < analogChannels; ch++) { | 56 for(unsigned int ch = 0; ch < context->analogInChannels; ch++) { |
59 // Two equivalent ways to write this code | 57 // Two equivalent ways to write this code |
60 | 58 |
61 // The long way, using the buffers directly: | 59 // The long way, using the buffers directly: |
62 // context->analogOut[n * context->analogOutChannels + ch] = | 60 // context->analogOut[n * context->analogOutChannels + ch] = |
63 // context->analogIn[n * context->analogInChannels + ch]; | 61 // context->analogIn[n * context->analogInChannels + ch]; |