Mercurial > hg > beaglert
comparison projects/filter_FIR/render.cpp @ 14:06f93bef7dd2
Updated remaining examples to new API
author | andrewm |
---|---|
date | Fri, 23 Jan 2015 15:35:10 +0000 |
parents | 09f03ac40fcc |
children | a6d223473ea2 |
comparison
equal
deleted
inserted
replaced
13:6adb088196a7 | 14:06f93bef7dd2 |
---|---|
15 #include "SampleData.h" | 15 #include "SampleData.h" |
16 #include "FIRfilter.h" | 16 #include "FIRfilter.h" |
17 | 17 |
18 SampleData gSampleData; // User defined structure to get complex data from main | 18 SampleData gSampleData; // User defined structure to get complex data from main |
19 int gReadPtr; // Position of last read sample from file | 19 int gReadPtr; // Position of last read sample from file |
20 int gNumChannels; | |
21 | |
22 | 20 |
23 // filter vars | 21 // filter vars |
24 ne10_fir_instance_f32_t gFIRfilter; | 22 ne10_fir_instance_f32_t gFIRfilter; |
25 ne10_float32_t *gFIRfilterIn; | 23 ne10_float32_t *gFIRfilterIn; |
26 ne10_float32_t *gFIRfilterOut; | 24 ne10_float32_t *gFIRfilterOut; |
46 // userData holds an opaque pointer to a data structure that was passed | 44 // userData holds an opaque pointer to a data structure that was passed |
47 // in from the call to initAudio(). | 45 // in from the call to initAudio(). |
48 // | 46 // |
49 // Return true on success; returning false halts the program. | 47 // Return true on success; returning false halts the program. |
50 | 48 |
51 bool initialise_render(int numChannels, int numMatrixFramesPerPeriod, | 49 bool initialise_render(int numMatrixChannels, int numAudioChannels, |
52 int numAudioFramesPerPeriod, float matrixSampleRate, | 50 int numMatrixFramesPerPeriod, |
53 float audioSampleRate, void *userData) | 51 int numAudioFramesPerPeriod, |
52 float matrixSampleRate, float audioSampleRate, | |
53 void *userData) | |
54 { | 54 { |
55 | 55 |
56 // Retrieve a parameter passed in from the initAudio() call | 56 // Retrieve a parameter passed in from the initAudio() call |
57 gSampleData = *(SampleData *)userData; | 57 gSampleData = *(SampleData *)userData; |
58 | 58 |
59 gReadPtr = -1; | 59 gReadPtr = -1; |
60 gNumChannels = numChannels; | |
61 gPeriodSize = numMatrixFramesPerPeriod; | 60 gPeriodSize = numMatrixFramesPerPeriod; |
62 | 61 |
63 initialise_filter(); | 62 initialise_filter(); |
64 | 63 |
65 // Initialise auxiliary tasks | 64 // Initialise auxiliary tasks |
91 } | 90 } |
92 | 91 |
93 ne10_fir_float_neon(&gFIRfilter, gFIRfilterIn, gFIRfilterOut, blockSize); | 92 ne10_fir_float_neon(&gFIRfilter, gFIRfilterIn, gFIRfilterOut, blockSize); |
94 | 93 |
95 for(int n = 0; n < numAudioFrames; n++) { | 94 for(int n = 0; n < numAudioFrames; n++) { |
96 for(int channel = 0; channel < gNumChannels; channel++) | 95 for(int channel = 0; channel < gNumAudioChannels; channel++) |
97 audioOut[n * gNumChannels + channel] = gFIRfilterOut[n]; // ...and put it in both left and right channel | 96 audioOut[n * gNumAudioChannels + channel] = gFIRfilterOut[n]; // ...and put it in both left and right channel |
98 } | 97 } |
99 | 98 |
100 | 99 |
101 // Request that the lower-priority task run at next opportunity | 100 // Request that the lower-priority task run at next opportunity |
102 scheduleAuxiliaryTask(gTriggerSamplesTask); | 101 scheduleAuxiliaryTask(gTriggerSamplesTask); |