From 64c75bc6c4d34b68cd9e0ac5c4b948198028b6ec Mon Sep 17 00:00:00 2001 From: Mark Wilkins Date: Tue, 4 Jul 2023 12:49:59 -0600 Subject: [PATCH] fix: Remove the unused debug code that had a bug (#18) #what Remove the debug code that I had in place during development that showed last information played and stuff like that. #why I probably won't use it again and can add it if needed. But mostly, it had a concurrency bug. I was using a structure to store the currently active notes and accessed it from another thread. No locks around it. Sigh. Co-authored-by: Mark Wilkins --- src/PluginEditor.cpp | 50 +---------------------------------------- src/PluginEditor.h | 5 ----- src/PluginProcessor.cpp | 12 ---------- src/PluginProcessor.h | 5 ----- 4 files changed, 1 insertion(+), 71 deletions(-) diff --git a/src/PluginEditor.cpp b/src/PluginEditor.cpp index 3d8ffae..a2ed506 100644 --- a/src/PluginEditor.cpp +++ b/src/PluginEditor.cpp @@ -21,17 +21,8 @@ MidiChordsAudioProcessorEditor::MidiChordsAudioProcessorEditor (MidiChordsAudioP { getLookAndFeel().setDefaultLookAndFeel(&lookAndFeel); setResizable(true, true); - // To see the debug controls, make the height 400 here setSize (1000, 210); - - lastTimeStamp.setColour(juce::Label::ColourIds::textColourId, juce::Colours::black); - debugInfo1.setColour(juce::Label::ColourIds::textColourId, juce::Colours::black); - currentChords.setColour(juce::Label::ColourIds::textColourId, juce::Colours::black); - - addAndMakeVisible(&lastTimeStamp); - addAndMakeVisible(&debugInfo1); - addAndMakeVisible(¤tChords); addAndMakeVisible(&options); addAndMakeVisible(&chordView); @@ -45,22 +36,12 @@ MidiChordsAudioProcessorEditor::~MidiChordsAudioProcessorEditor() void MidiChordsAudioProcessorEditor::timerCallback() { - // some debug stuff that is hidden unless debugInfoSize is adjusted below - juce::String text; - std::unordered_set::iterator it; - text = "8:26 last: " + audioProcessor.lastNote + ": "; - for (it = audioProcessor.currentNotes.begin(); it != audioProcessor.currentNotes.end(); it++) { - text = text + " " + *it; - } // The setDirty method for vst3 has this bit of code for setting dirty. I don't think it works, but leaving // it here for further testing when I feel like it. If I figure out that it does work, then I need to set // this when actual changes occur (e.g., when isViewUpToDate is set to false and for props like allowStateChange) // this->audioProcessor.updateHostDisplay(AudioPluginInstance::ChangeDetails{}.withNonParameterStateChanged(true)); - juce::String lastTime = std::to_string(audioProcessor.lastEventTime); - juce::String lastTimestampValue = std::to_string((int64)(audioProcessor.lastEventTimestamp)); - lastTimeStamp.setText("lasttime: " + lastTimestampValue, juce::NotificationType::sendNotification); // This is very cheesy - refresh the control settings in case the state has changed. I need to figure // out the listener stuff better. But there are very few controls, so not expensive @@ -77,28 +58,6 @@ void MidiChordsAudioProcessorEditor::timerCallback() MidiStore *ms = audioProcessor.getMidiState(); ms->updateStaticViewIfOutOfDate(); - debugInfo1.setText("visible chord count: " + std::to_string(ms->getViewWindowChordCount()), juce::NotificationType::sendNotification); - - /* - std::string info = ""; - std::vector eventTimes = ms->getEventTimes(); - for (std::vector::iterator i = eventTimes.begin(); i != eventTimes.end(); ++i) - { - // info += std::to_string(*i) + ", "; - vector itNotes = ms->getAllNotesOnAtTime(0, *i); - lastChord = cn.nameChord(itNotes); - if (lastChord != "") - { - double seconds = ms->getEventTimeInSeconds(*i); - ostringstream oss; - oss << info << lastChord << " (" << *i << ", " << seconds << "), "; - info = oss.str(); - } - } - currentChords.setText("all chords: " + info, juce::NotificationType::sendNotification); - */ - - } @@ -117,13 +76,6 @@ void MidiChordsAudioProcessorEditor::paint (juce::Graphics& g) void MidiChordsAudioProcessorEditor::resized() { // sets the position and size of the slider with arguments (x, y, width, height) - lastTimeStamp.setBounds(10, 10, 100, 30); - debugInfo1.setBounds(10, 40, getWidth() - 10, 30); - currentChords.setBounds(10, 70, getWidth() - 10, 60); - // Make this bigger to be able to see the debug info. Probably will remove this - // stuff at some point - int debugInfoSize = 0; - options.setBounds(0, getHeight() - 100, getWidth(), 100); - chordView.setBounds(0, debugInfoSize + 10, getWidth(), getHeight() - (debugInfoSize + 120)); + chordView.setBounds(0, 10, getWidth(), getHeight() - 120); } diff --git a/src/PluginEditor.h b/src/PluginEditor.h index b360329..088b5d2 100644 --- a/src/PluginEditor.h +++ b/src/PluginEditor.h @@ -35,11 +35,6 @@ class MidiChordsAudioProcessorEditor : public juce::AudioProcessorEditor, // access the processor object that created it. MidiChordsAudioProcessor& audioProcessor; - // some debug info placeholders - juce::Label currentChords; - juce::Label lastTimeStamp; - juce::Label debugInfo1; - OptionsComponent options; ChordView chordView; diff --git a/src/PluginProcessor.cpp b/src/PluginProcessor.cpp index f75a119..149ea81 100644 --- a/src/PluginProcessor.cpp +++ b/src/PluginProcessor.cpp @@ -162,15 +162,9 @@ void MidiChordsAudioProcessor::processBlock (juce::AudioBuffer& buffer, j auto message = metadata.getMessage(); int noteNumber = message.getNoteNumber(); - lastNote = message.getMidiNoteName(noteNumber, true, false, 4); auto messageEventTime = (int64)message.getTimeStamp() + posOfBlock.first; if (message.isNoteOn()) { - this->currentNotes.insert(lastNote); - // mlwtbd: These two values were for helping me debug/understand. Probably will delete these two values. - this->lastEventTime = metadata.samplePosition; - this->lastEventTimestamp = messageEventTime; - // DBG("Note on: " + message.getDescription() + " at time " + std::to_string(lastEventTime)); midiState.addNoteEventAtTime(messageEventTime, noteNumber, true); // mlwtbd - Store the current time in seconds that "might be" associated with this event. // However this value is the current position of the playhead ... and we are offsetting the @@ -183,12 +177,6 @@ void MidiChordsAudioProcessor::processBlock (juce::AudioBuffer& buffer, j } if (message.isNoteOff()) { - // mlwtbd TODO: is the isMidiStop event included in this? This would let me know if this event is a "true" - // note off event versus one generated by stopping playback - std::unordered_set::iterator pos = currentNotes.find(lastNote); - if (pos != currentNotes.end()) { - currentNotes.erase(pos); - } // DBG("Note off: " + message.getDescription()); midiState.addNoteEventAtTime(messageEventTime, noteNumber, false); midiState.setEventTimeSeconds(messageEventTime, posOfBlock.second); diff --git a/src/PluginProcessor.h b/src/PluginProcessor.h index a062b29..d54addf 100644 --- a/src/PluginProcessor.h +++ b/src/PluginProcessor.h @@ -60,11 +60,6 @@ class MidiChordsAudioProcessor : public juce::AudioProcessor void getStateInformation (juce::MemoryBlock& destData) override; void setStateInformation (const void* data, int sizeInBytes) override; - juce::String lastNote; - int lastEventTime = 0; - int64 lastEventTimestamp = 0; - std::unordered_set currentNotes; - MidiStore* getMidiState() { return &midiState; } private: