comparison projects/filter_IIR/render.cpp @ 14:06f93bef7dd2

Updated remaining examples to new API
author andrewm
date Fri, 23 Jan 2015 15:35:10 +0000
parents 6810f166482f
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 // filter vars 19 // filter vars
21 float gLastX[2]; 20 float gLastX[2];
22 float gLastY[2]; 21 float gLastY[2];
23 double lb0, lb1, lb2, la1, la2 = 0.0; 22 double lb0, lb1, lb2, la1, la2 = 0.0;
53 // userData holds an opaque pointer to a data structure that was passed 52 // userData holds an opaque pointer to a data structure that was passed
54 // in from the call to initAudio(). 53 // in from the call to initAudio().
55 // 54 //
56 // Return true on success; returning false halts the program. 55 // Return true on success; returning false halts the program.
57 56
58 bool initialise_render(int numChannels, int numMatrixFramesPerPeriod, 57 bool initialise_render(int numMatrixChannels, int numAudioChannels,
59 int numAudioFramesPerPeriod, float matrixSampleRate, 58 int numMatrixFramesPerPeriod,
60 float audioSampleRate, void *userData) 59 int numAudioFramesPerPeriod,
60 float matrixSampleRate, float audioSampleRate,
61 void *userData)
61 { 62 {
62 63
63 // Retrieve a parameter passed in from the initAudio() call 64 // Retrieve a parameter passed in from the initAudio() call
64 gSampleData = *(SampleData *)userData; 65 gSampleData = *(SampleData *)userData;
65 66
66 gReadPtr = -1; 67 gReadPtr = -1;
67 gNumChannels = numChannels;
68 68
69 initialise_filter(200); 69 initialise_filter(200);
70 70
71 // Initialise auxiliary tasks 71 // Initialise auxiliary tasks
72 if(!initialise_aux_tasks()) 72 if(!initialise_aux_tasks())
99 gLastX[1] = gLastX[0]; 99 gLastX[1] = gLastX[0];
100 gLastX[0] = out; 100 gLastX[0] = out;
101 gLastY[1] = gLastY[0]; 101 gLastY[1] = gLastY[0];
102 gLastY[0] = out; 102 gLastY[0] = out;
103 103
104 for(int channel = 0; channel < gNumChannels; channel++) 104 for(int channel = 0; channel < gNumAudioChannels; channel++)
105 audioOut[n * gNumChannels + channel] = out; // ...and put it in both left and right channel 105 audioOut[n * gNumAudioChannels + channel] = out; // ...and put it in both left and right channel
106 106
107 } 107 }
108 108
109 // Request that the lower-priority tasks run at next opportunity 109 // Request that the lower-priority tasks run at next opportunity
110 scheduleAuxiliaryTask(gChangeCoeffTask); 110 scheduleAuxiliaryTask(gChangeCoeffTask);