Mercurial > hg > beaglert
comparison examples/level_meter/render.cpp @ 314:611306d840b3 prerelease
Merge
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Fri, 27 May 2016 19:00:43 +0100 |
parents | 493a07f6ec09 |
children | 9dc5a0ccad25 |
comparison
equal
deleted
inserted
replaced
313:c770cdf3d8b2 | 314:611306d840b3 |
---|---|
58 gThresholds[i] = powf(10.0f, (-1.0 * (NUMBER_OF_SEGMENTS - i)) * .05); | 58 gThresholds[i] = powf(10.0f, (-1.0 * (NUMBER_OF_SEGMENTS - i)) * .05); |
59 } | 59 } |
60 | 60 |
61 for(int i = 0; i < NUMBER_OF_SEGMENTS; i++) { | 61 for(int i = 0; i < NUMBER_OF_SEGMENTS; i++) { |
62 gSamplesToLight[i] = 0; | 62 gSamplesToLight[i] = 0; |
63 pinModeFrame(context, 0, i, OUTPUT); | 63 pinMode(context, 0, i, OUTPUT); |
64 } | 64 } |
65 | 65 |
66 return true; | 66 return true; |
67 } | 67 } |
68 | 68 |
103 if(out > gAudioPeakLevel) | 103 if(out > gAudioPeakLevel) |
104 gAudioPeakLevel = out; | 104 gAudioPeakLevel = out; |
105 else { | 105 else { |
106 // Make peak decay slowly by only multiplying | 106 // Make peak decay slowly by only multiplying |
107 // every few samples | 107 // every few samples |
108 if(((context->audioSampleCount + n) & 31) == 0) | 108 if(((context->audioFramesElapsed + n) & 31) == 0) |
109 gAudioPeakLevel *= gPeakDecayRate; | 109 gAudioPeakLevel *= gPeakDecayRate; |
110 } | 110 } |
111 // LED bargraph on digital outputs 0-9 | 111 // LED bargraph on digital outputs 0-9 |
112 for(int led = 0; led < NUMBER_OF_SEGMENTS; led++) { | 112 for(int led = 0; led < NUMBER_OF_SEGMENTS; led++) { |
113 // All LEDs up to the local level light up. The LED | 113 // All LEDs up to the local level light up. The LED |
124 }*/ | 124 }*/ |
125 else if(--gSamplesToLight[led] > 0) | 125 else if(--gSamplesToLight[led] > 0) |
126 state = HIGH; | 126 state = HIGH; |
127 | 127 |
128 // Write LED | 128 // Write LED |
129 digitalWriteFrameOnce(context, n, led, state); | 129 digitalWriteOnce(context, n, led, state); |
130 } | 130 } |
131 } | 131 } |
132 } | 132 } |
133 | 133 |
134 // cleanup() is called once at the end, after the audio has stopped. | 134 // cleanup() is called once at the end, after the audio has stopped. |