comparison examples/cape_test/render.cpp @ 311:493a07f6ec09 prerelease

Renamed BelaContext->audioSampleCount to BelaContext->audioFramesElapsed for consistency of terminology
author andrewm
date Fri, 27 May 2016 18:37:51 +0100
parents e4392164b458
children
comparison
equal deleted inserted replaced
310:02c4ca0e3718 311:493a07f6ec09
108 gAudioTestSuccessCounter = 0; 108 gAudioTestSuccessCounter = 0;
109 } 109 }
110 110
111 } 111 }
112 else { 112 else {
113 if(!((context->audioSampleCount + n) % 22050)) { 113 if(!((context->audioFramesElapsed + n) % 22050)) {
114 // Debugging print messages 114 // Debugging print messages
115 if((gPositivePeakLevels[0] - gNegativePeakLevels[0]) < gPeakLevelHighThreshold) 115 if((gPositivePeakLevels[0] - gNegativePeakLevels[0]) < gPeakLevelHighThreshold)
116 rt_printf("Left Audio In FAIL: insufficient signal: %f\n", 116 rt_printf("Left Audio In FAIL: insufficient signal: %f\n",
117 gPositivePeakLevels[0] - gNegativePeakLevels[0]); 117 gPositivePeakLevels[0] - gNegativePeakLevels[0]);
118 else if(gPositivePeakLevels[1] - gNegativePeakLevels[1] > gPeakLevelLowThreshold) 118 else if(gPositivePeakLevels[1] - gNegativePeakLevels[1] > gPeakLevelLowThreshold)
153 gAudioTestStateSampleCount = 0; 153 gAudioTestStateSampleCount = 0;
154 gAudioTestState = kStateTestingAudioDone; 154 gAudioTestState = kStateTestingAudioDone;
155 } 155 }
156 } 156 }
157 else { 157 else {
158 if(!((context->audioSampleCount + n) % 22050)) { 158 if(!((context->audioFramesElapsed + n) % 22050)) {
159 // Debugging print messages 159 // Debugging print messages
160 if((gPositivePeakLevels[1] - gNegativePeakLevels[1]) < gPeakLevelHighThreshold) 160 if((gPositivePeakLevels[1] - gNegativePeakLevels[1]) < gPeakLevelHighThreshold)
161 rt_printf("Right Audio In FAIL: insufficient signal: %f\n", 161 rt_printf("Right Audio In FAIL: insufficient signal: %f\n",
162 gPositivePeakLevels[1] - gNegativePeakLevels[1]); 162 gPositivePeakLevels[1] - gNegativePeakLevels[1]);
163 else if(gPositivePeakLevels[0] - gNegativePeakLevels[0] > gPeakLevelLowThreshold) 163 else if(gPositivePeakLevels[0] - gNegativePeakLevels[0] > gPeakLevelLowThreshold)
180 context->audioOut[2*n] = gEnvelopeValueL * sinf(phase); 180 context->audioOut[2*n] = gEnvelopeValueL * sinf(phase);
181 context->audioOut[2*n + 1] = gEnvelopeValueR * sinf(phase); 181 context->audioOut[2*n + 1] = gEnvelopeValueR * sinf(phase);
182 182
183 // If one second has gone by with no error, play one sound, else 183 // If one second has gone by with no error, play one sound, else
184 // play another 184 // play another
185 if(context->audioSampleCount + n - gLastErrorFrame > 44100) { 185 if(context->audioFramesElapsed + n - gLastErrorFrame > 44100) {
186 gEnvelopeValueL *= gEnvelopeDecayRate; 186 gEnvelopeValueL *= gEnvelopeDecayRate;
187 gEnvelopeValueR *= gEnvelopeDecayRate; 187 gEnvelopeValueR *= gEnvelopeDecayRate;
188 gEnvelopeSampleCount++; 188 gEnvelopeSampleCount++;
189 if(gEnvelopeSampleCount > 22050) { 189 if(gEnvelopeSampleCount > 22050) {
190 if(gEnvelopeLastChannel == 0) 190 if(gEnvelopeLastChannel == 0)
231 if(sampleCounter == 256) { 231 if(sampleCounter == 256) {
232 for(int k = 0; k < 8; k++) { 232 for(int k = 0; k < 8; k++) {
233 if(k == invertChannel) { 233 if(k == invertChannel) {
234 if(context->analogIn[n*8 + k] < ANALOG_HIGH) { 234 if(context->analogIn[n*8 + k] < ANALOG_HIGH) {
235 rt_printf("FAIL [output %d, input %d] -- output HIGH input %f (inverted)\n", gDACPinOrder[k], k, context->analogIn[n*8 + k]); 235 rt_printf("FAIL [output %d, input %d] -- output HIGH input %f (inverted)\n", gDACPinOrder[k], k, context->analogIn[n*8 + k]);
236 gLastErrorFrame = context->audioSampleCount + n; 236 gLastErrorFrame = context->audioFramesElapsed + n;
237 } 237 }
238 } 238 }
239 else { 239 else {
240 if(context->analogIn[n*8 + k] > ANALOG_LOW) { 240 if(context->analogIn[n*8 + k] > ANALOG_LOW) {
241 rt_printf("FAIL [output %d, input %d] -- output LOW --> input %f\n", gDACPinOrder[k], k, context->analogIn[n*8 + k]); 241 rt_printf("FAIL [output %d, input %d] -- output LOW --> input %f\n", gDACPinOrder[k], k, context->analogIn[n*8 + k]);
242 gLastErrorFrame = context->audioSampleCount + n; 242 gLastErrorFrame = context->audioFramesElapsed + n;
243 } 243 }
244 } 244 }
245 } 245 }
246 } 246 }
247 else if(sampleCounter == 768) { 247 else if(sampleCounter == 768) {
248 for(int k = 0; k < 8; k++) { 248 for(int k = 0; k < 8; k++) {
249 if(k == invertChannel) { 249 if(k == invertChannel) {
250 if(context->analogIn[n*8 + k] > ANALOG_LOW) { 250 if(context->analogIn[n*8 + k] > ANALOG_LOW) {
251 rt_printf("FAIL [output %d, input %d] -- output LOW input %f (inverted)\n", gDACPinOrder[k], k, context->analogIn[n*8 + k]); 251 rt_printf("FAIL [output %d, input %d] -- output LOW input %f (inverted)\n", gDACPinOrder[k], k, context->analogIn[n*8 + k]);
252 gLastErrorFrame = context->audioSampleCount + n; 252 gLastErrorFrame = context->audioFramesElapsed + n;
253 } 253 }
254 } 254 }
255 else { 255 else {
256 if(context->analogIn[n*8 + k] < ANALOG_HIGH) { 256 if(context->analogIn[n*8 + k] < ANALOG_HIGH) {
257 rt_printf("FAIL [output %d, input %d] -- output HIGH input %f\n", gDACPinOrder[k], k, context->analogIn[n*8 + k]); 257 rt_printf("FAIL [output %d, input %d] -- output HIGH input %f\n", gDACPinOrder[k], k, context->analogIn[n*8 + k]);
258 gLastErrorFrame = context->audioSampleCount + n; 258 gLastErrorFrame = context->audioFramesElapsed + n;
259 } 259 }
260 } 260 }
261 } 261 }
262 } 262 }
263 263