From f503ca27011a707b73c70ea58ea65a412dbcad65 Mon Sep 17 00:00:00 2001 From: Tom Poole Date: Tue, 16 Jan 2018 16:38:18 +0000 Subject: [PATCH] Fixed a bug in the InterAppAudioEffect demo --- .../Source/IAAEffectEditor.h | 24 ++++++++++++------- .../InterAppAudioEffect/Source/SimpleMeter.h | 1 + 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/examples/PlugInSamples/InterAppAudioEffect/Source/IAAEffectEditor.h b/examples/PlugInSamples/InterAppAudioEffect/Source/IAAEffectEditor.h index f27820d83d..f7e1cffc24 100644 --- a/examples/PlugInSamples/InterAppAudioEffect/Source/IAAEffectEditor.h +++ b/examples/PlugInSamples/InterAppAudioEffect/Source/IAAEffectEditor.h @@ -96,6 +96,11 @@ public: startTimerHz (60); } + ~IAAEffectEditor() + { + processor.removeMeterListener (*this); + } + //============================================================================== void paint (Graphics& g) override { @@ -145,6 +150,7 @@ private: { auto timeInfoSuccess = processor.updateCurrentTimeInfoFromHost (lastPosInfo); transportText.setVisible (timeInfoSuccess); + if (timeInfoSuccess) updateTransportTextDisplay(); @@ -157,6 +163,7 @@ private: void buttonClicked (Button* b) override { auto playHead = processor.getPlayHead(); + if (playHead != nullptr && playHead->canControlTransport()) { if (b == &rewindButton) @@ -215,10 +222,10 @@ private: MemoryOutputStream displayText; displayText << "[" << SystemStats::getJUCEVersion() << "]\n" - << String (lastPosInfo.bpm, 2) << " bpm\n" - << lastPosInfo.timeSigNumerator << '/' << lastPosInfo.timeSigDenominator << "\n" - << timeToTimecodeString (lastPosInfo.timeInSeconds) << "\n" - << quarterNotePositionToBarsBeatsString (lastPosInfo.ppqPosition, + << String (lastPosInfo.bpm, 2) << " bpm\n" + << lastPosInfo.timeSigNumerator << '/' << lastPosInfo.timeSigDenominator << "\n" + << timeToTimecodeString (lastPosInfo.timeInSeconds) << "\n" + << quarterNotePositionToBarsBeatsString (lastPosInfo.ppqPosition, lastPosInfo.timeSigNumerator, lastPosInfo.timeSigDenominator) << "\n"; @@ -257,13 +264,15 @@ private: void updateSwitchToHostDisplay() { PluginHostType hostType; - const bool visible = hostType.isInterAppAudioConnected(); + auto visible = hostType.isInterAppAudioConnected(); if (switchToHostButtonLabel.isVisible() != visible) { switchToHostButtonLabel.setVisible (visible); switchToHostButton.setVisible (visible); - if (visible) { + + if (visible) + { auto icon = hostType.getHostIcon (buttonSize); switchToHostButton.setImages(false, true, true, icon, 1.0, Colours::transparentBlack, @@ -283,13 +292,12 @@ private: ShapeButton recordButton {"Record", defaultButtonColour, defaultButtonColour, defaultButtonColour}; Slider gainSlider; - AudioProcessorValueTreeState::SliderAttachment gainAttachment = {parameters, "gain", gainSlider}; + AudioProcessorValueTreeState::SliderAttachment gainAttachment = { parameters, "gain", gainSlider }; std::array meters; ImageButton switchToHostButton; Label transportText, switchToHostButtonLabel; - Image hostImage; AudioPlayHead::CurrentPositionInfo lastPosInfo; diff --git a/examples/PlugInSamples/InterAppAudioEffect/Source/SimpleMeter.h b/examples/PlugInSamples/InterAppAudioEffect/Source/SimpleMeter.h index 7f963b0f14..14cfa94f34 100644 --- a/examples/PlugInSamples/InterAppAudioEffect/Source/SimpleMeter.h +++ b/examples/PlugInSamples/InterAppAudioEffect/Source/SimpleMeter.h @@ -72,6 +72,7 @@ private: auto callbackLevel = maxLevel.exchange (0.0); auto decayFactor = 0.95; + if (callbackLevel > level) level = callbackLevel; else if (level > 0.001)