| 195 | } |
| 196 | |
| 197 | void GRainbowAudioProcessorEditor::timerCallback() { |
| 198 | // Update progress bar when loading audio clip |
| 199 | // Will overlay on the other center components |
| 200 | if (mParameters.ui.isLoading) { |
| 201 | mProgressBar.setVisible(true); |
| 202 | } else if (mProgressBar.isVisible()) { |
| 203 | mPianoPanel.waveform.load(mSynth.getAudioBuffer()); |
| 204 | mProgressBar.setVisible(false); |
| 205 | } |
| 206 | |
| 207 | // Check for buffers needing to be updated |
| 208 | if (!mParameters.ui.specComplete) { |
| 209 | std::vector<Utils::SpecBuffer*> specs = mSynth.getProcessedSpecs(); |
| 210 | for (size_t i = 0; i < specs.size(); ++i) { |
| 211 | if (specs[i] != nullptr && mArcSpec.shouldLoadImage((ParamUI::SpecType)i)) { |
| 212 | mArcSpec.loadSpecBuffer(specs[i], (ParamUI::SpecType)i); |
| 213 | } |
| 214 | } |
| 215 | } else if (mParameters.ui.isLoading) { |
| 216 | // Spec complete, we're done loading |
| 217 | mArcSpec.setSpecType(ParamUI::SpecType::HPCP); |
| 218 | mTitlePresetPanel.btnSavePreset.setEnabled(true); |
| 219 | mParameters.ui.isLoading = false; |
| 220 | } |
| 221 | |
| 222 | bool isNotLoaded = mParameters.ui.fileName != mParameters.ui.loadedFileName; |
| 223 | if (mTitlePresetPanel.labelFileName.getText() != mParameters.ui.loadedFileName || isNotLoaded) { |
| 224 | // Set title bar to display new preset name |
| 225 | mTitlePresetPanel.labelFileName.setText(isNotLoaded ? mParameters.ui.fileName : mParameters.ui.loadedFileName, juce::dontSendNotification); |
| 226 | } |
| 227 | |
| 228 | // Get notes being played, send off to each children and then redraw. |
| 229 | // Grab the notes from the Synth instead of MidiKeyboardState::Listener to not block the thread to draw. |
| 230 | // There is a chance notes are pressed and released inbetween timer callback if they are super short, but can always increase the |
| 231 | // callback timer |
| 232 | const juce::Array<Utils::MidiNote>& midiNotes = mSynth.getMidiNotes(); |
| 233 | // Each component has has a different use for the midi notes, so just give them the notes and have them do what logic they want |
| 234 | // with it |
| 235 | mPianoPanel.keyboard.setMidiNotes(midiNotes); |
| 236 | mArcSpec.setMidiNotes(midiNotes); |
| 237 | |
| 238 | /* if (PowerUserSettings::get().getResourceUsage()) { |
| 239 | const double cpuPerc = mAudioDeviceManager.getCpuUsage() * 100; |
| 240 | size_t virtual_memory = 0; |
| 241 | size_t resident_memory = 0; |
| 242 | #if defined(__linux__) |
| 243 | FILE* file = fopen("/proc/self/statm", "r"); |
| 244 | if (file) { |
| 245 | unsigned long VmSize = 0; |
| 246 | unsigned long VmRSS = 0; |
| 247 | fscanf(file, "%lu %lu", &VmSize, &VmRSS); |
| 248 | fclose(file); |
| 249 | virtual_memory = static_cast<size_t>(VmSize) * getpagesize(); |
| 250 | resident_memory = static_cast<size_t>(VmRSS) * getpagesize(); |
| 251 | } |
| 252 | #elif defined(_WINDOWS) |
| 253 | // According to MSDN |
| 254 | PROCESS_MEMORY_COUNTERS counters; |
nothing calls this directly
no test coverage detected