Mercurial > hg > beaglert
comparison projects/samples/render.cpp @ 14:06f93bef7dd2
Updated remaining examples to new API
author | andrewm |
---|---|
date | Fri, 23 Jan 2015 15:35:10 +0000 |
parents | 24fc8026ae8e |
children | a6d223473ea2 |
comparison
equal
deleted
inserted
replaced
13:6adb088196a7 | 14:06f93bef7dd2 |
---|---|
13 #include <stdio.h> | 13 #include <stdio.h> |
14 #include "SampleData.h" | 14 #include "SampleData.h" |
15 | 15 |
16 SampleData gSampleData; // User defined structure to get complex data from main | 16 SampleData gSampleData; // User defined structure to get complex data from main |
17 int gReadPtr; // Position of last read sample from file | 17 int gReadPtr; // Position of last read sample from file |
18 int gNumChannels; | |
19 | 18 |
20 // Task for handling the update of the frequencies using the matrix | 19 // Task for handling the update of the frequencies using the matrix |
21 AuxiliaryTask gTriggerSamplesTask; | 20 AuxiliaryTask gTriggerSamplesTask; |
22 | 21 |
23 bool initialise_trigger(); | 22 bool initialise_trigger(); |
30 // userData holds an opaque pointer to a data structure that was passed | 29 // userData holds an opaque pointer to a data structure that was passed |
31 // in from the call to initAudio(). | 30 // in from the call to initAudio(). |
32 // | 31 // |
33 // Return true on success; returning false halts the program. | 32 // Return true on success; returning false halts the program. |
34 | 33 |
35 bool initialise_render(int numChannels, int numMatrixFramesPerPeriod, | 34 bool initialise_render(int numMatrixChannels, int numAudioChannels, |
36 int numAudioFramesPerPeriod, float matrixSampleRate, | 35 int numMatrixFramesPerPeriod, |
37 float audioSampleRate, void *userData) | 36 int numAudioFramesPerPeriod, |
37 float matrixSampleRate, float audioSampleRate, | |
38 void *userData) | |
38 { | 39 { |
39 | 40 |
40 // Retrieve a parameter passed in from the initAudio() call | 41 // Retrieve a parameter passed in from the initAudio() call |
41 gSampleData = *(SampleData *)userData; | 42 gSampleData = *(SampleData *)userData; |
42 | 43 |
43 gReadPtr = -1; | 44 gReadPtr = -1; |
44 gNumChannels = numChannels; | |
45 | 45 |
46 // Initialise auxiliary tasks | 46 // Initialise auxiliary tasks |
47 if(!initialise_trigger()) | 47 if(!initialise_trigger()) |
48 return false; | 48 return false; |
49 | 49 |
66 out += gSampleData.samples[gReadPtr++]; // ...read each sample... | 66 out += gSampleData.samples[gReadPtr++]; // ...read each sample... |
67 | 67 |
68 if(gReadPtr >= gSampleData.sampleLen) | 68 if(gReadPtr >= gSampleData.sampleLen) |
69 gReadPtr = -1; | 69 gReadPtr = -1; |
70 | 70 |
71 for(int channel = 0; channel < gNumChannels; channel++) | 71 for(int channel = 0; channel < gNumAudioChannels; channel++) |
72 audioOut[n * gNumChannels + channel] = out; // ...and put it in both left and right channel | 72 audioOut[n * gNumAudioChannels + channel] = out; // ...and put it in both left and right channel |
73 } | 73 } |
74 | 74 |
75 // Request that the lower-priority task run at next opportunity | 75 // Request that the lower-priority task run at next opportunity |
76 scheduleAuxiliaryTask(gTriggerSamplesTask); | 76 scheduleAuxiliaryTask(gTriggerSamplesTask); |
77 } | 77 } |