Mercurial > hg > beaglert
comparison examples/04-Audio/samples/render.cpp @ 544:cdabbaf3a252 prerelease
Updated Audio examples for audioOutChannels etc.
author | Robert Jack <robert.h.jack@gmail.com> |
---|---|
date | Fri, 24 Jun 2016 13:32:07 +0100 |
parents | 1cec96845a23 |
children |
comparison
equal
deleted
inserted
replaced
543:8f8809c77dda | 544:cdabbaf3a252 |
---|---|
36 void trigger_samples(); | 36 void trigger_samples(); |
37 | 37 |
38 bool setup(BelaContext *context, void *userData) | 38 bool setup(BelaContext *context, void *userData) |
39 { | 39 { |
40 | 40 |
41 // Check that we have the same number of inputs and outputs. | |
42 if(context->audioInChannels != context->audioOutChannels || | |
43 context->analogInChannels != context-> analogOutChannels){ | |
44 printf("Error: for this project, you need the same number of input and output channels.\n"); | |
45 return false; | |
46 } | |
47 | |
41 // Retrieve a parameter passed in from the initAudio() call | 48 // Retrieve a parameter passed in from the initAudio() call |
42 gSampleData = *(SampleData *)userData; | 49 gSampleData = *(SampleData *)userData; |
43 | 50 |
44 gReadPtr = -1; | 51 gReadPtr = -1; |
45 | 52 |
60 out += gSampleData.samples[gReadPtr++]; // ...read each sample... | 67 out += gSampleData.samples[gReadPtr++]; // ...read each sample... |
61 | 68 |
62 if(gReadPtr >= gSampleData.sampleLen) | 69 if(gReadPtr >= gSampleData.sampleLen) |
63 gReadPtr = -1; | 70 gReadPtr = -1; |
64 | 71 |
65 for(unsigned int channel = 0; channel < context->audioChannels; channel++) | 72 for(unsigned int channel = 0; channel < context->audioOutChannels; channel++) |
66 context->audioOut[n * context->audioChannels + channel] = out; // ...and put it in both left and right channel | 73 context->audioOut[n * context->audioOutChannels + channel] = out; // ...and put it in both left and right channel |
67 } | 74 } |
68 | 75 |
69 // Request that the lower-priority task run at next opportunity | 76 // Request that the lower-priority task run at next opportunity |
70 Bela_scheduleAuxiliaryTask(gTriggerSamplesTask); | 77 Bela_scheduleAuxiliaryTask(gTriggerSamplesTask); |
71 } | 78 } |