| 2297 | } |
| 2298 | |
| 2299 | bool FireAudioProcessor::getLatestMeterValues(MeterValues& values) |
| 2300 | { |
| 2301 | // Check how many complete data packets are ready to be read. |
| 2302 | int numAvailable = meterFifo.getNumReady(); |
| 2303 | |
| 2304 | // If there's at least one, we can proceed. |
| 2305 | if (numAvailable > 0) |
| 2306 | { |
| 2307 | // We want to get the most recent value. If there are multiple values |
| 2308 | // queued up, we'll read them all but only copy the last one. |
| 2309 | // This prevents the GUI from lagging behind the audio thread. |
| 2310 | |
| 2311 | int start1, size1, start2, size2; |
| 2312 | meterFifo.prepareToRead(numAvailable, start1, size1, start2, size2); |
| 2313 | |
| 2314 | // The fifo might wrap around, so it gives us two contiguous blocks. |
| 2315 | // We just need to find the last element across these two blocks. |
| 2316 | if (size2 > 0) |
| 2317 | { |
| 2318 | // The latest element is at the end of the second block. |
| 2319 | values = meterFifoBuffer[start2 + size2 - 1]; |
| 2320 | } |
| 2321 | else |
| 2322 | { |
| 2323 | // The latest element is at the end of the first block. |
| 2324 | values = meterFifoBuffer[start1 + size1 - 1]; |
| 2325 | } |
| 2326 | |
| 2327 | // Tell the fifo that we've now "consumed" all the available data. |
| 2328 | meterFifo.finishedRead(numAvailable); |
| 2329 | |
| 2330 | // Return true to indicate that we successfully updated the 'values' object. |
| 2331 | return true; |
| 2332 | } |
| 2333 | |
| 2334 | // If no new data was available, return false. |
| 2335 | return false; |
| 2336 | } |
| 2337 | |
| 2338 | bool FireAudioProcessor::getLatestModulatedFilterValues(ModulatedFilterValues& values) |
| 2339 | { |