Skip to content

Commit c5c445b

Browse files
committed
Allow for running analysis on demand when selecting objects in ARATestPlugIn
1 parent 0a5158b commit c5c445b

File tree

3 files changed

+54
-13
lines changed

3 files changed

+54
-13
lines changed

ChangeLog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Changes since previous releases:
1919
notifications whenever any part of their persistent state changes
2020
- added new partial persistency split archives test case to TestHost
2121
- added various threading and state validations to TestHost
22+
- added some configurable UI test code to ARATestPlugIn
2223
- various cleanups in macOS info.plist files
2324
- added script target to remove ARATestPlugIn from where it was installed for debugging
2425
- updated Audio Unit SDK from the old CoreAudioUtilityClasses.zip sample code download to

TestPlugIn/ARATestDocumentController.cpp

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,6 @@
4343
#endif
4444

4545

46-
// By default, the test plug-in only analyzes audio sources when explicitly requested by the host.
47-
// The define below allows to always trigger audio source analysis when a new audio source instance
48-
// is created (and the host does not provide all supported content for it), which is closer to the
49-
// behavior of actual plug-ins like Melodyne, and also allows for testing analysis and related
50-
// notifications in hosts that never request audio source analysis.
51-
#if !defined (ARA_ALWAYS_PERFORM_ANALYSIS)
52-
#define ARA_ALWAYS_PERFORM_ANALYSIS 0
53-
#endif
54-
55-
5646
ARA_SETUP_DEBUG_MESSAGE_PREFIX (TEST_PLUGIN_NAME);
5747

5848

@@ -125,6 +115,20 @@ class ARATestNoteContentReader : public ARA::PlugIn::ContentReader
125115

126116
/*******************************************************************************/
127117

118+
void ARATestEditorView::doNotifySelection (const ARA::PlugIn::ViewSelection* selection) noexcept
119+
{
120+
#if !ARA_ALWAYS_PERFORM_ANALYSIS
121+
for (const auto playbackRegion : selection->getEffectivePlaybackRegions ())
122+
{
123+
auto audioSource { playbackRegion->getAudioModification ()->getAudioSource<ARATestAudioSource> () };
124+
if (audioSource->getNoteContent () == nullptr)
125+
getDocumentController<ARATestDocumentController> ()->startOrScheduleAnalysisOfAudioSource (audioSource);
126+
}
127+
#endif
128+
}
129+
130+
/*******************************************************************************/
131+
128132
// helper class to deal with string ownership for persistent IDs
129133
// We're subclassing the actual ARA interface struct and add members that handle the ownership,
130134
// which works because the host receiving the struct will not access any data beyond structSize.
@@ -810,6 +814,19 @@ ARA::PlugIn::PlaybackRenderer* ARATestDocumentController::doCreatePlaybackRender
810814
return new ARATestPlaybackRenderer (this);
811815
}
812816

817+
ARA::PlugIn::EditorView* ARATestDocumentController::doCreateEditorView () noexcept
818+
{
819+
#if !ARA_ALWAYS_PERFORM_ANALYSIS
820+
auto result = new ARATestEditorView { this };
821+
// An actual plug-in would need to control setEditorOpen () from its companion API implementation -
822+
// we'er only doing a crude hack here because we have no such implementation!
823+
result->setEditorOpen (true);
824+
return result;
825+
#else
826+
return new ARA::PlugIn::EditorView (this);
827+
#endif
828+
}
829+
813830
/*******************************************************************************/
814831

815832
bool ARATestDocumentController::rendererWillAccessModelGraph (ARATestPlaybackRenderer* /*playbackRenderer*/) noexcept

TestPlugIn/ARATestDocumentController.h

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,32 @@
2626
#include <unordered_set>
2727

2828

29+
// By default, the test plug-in only analyzes audio sources when explicitly requested by the host,
30+
// or if the user opens its (empty) UI and selects playback regions or region sequences in the host
31+
// for which there is no content data available yet.
32+
// The define below allows to always trigger audio source analysis when a new audio source instance
33+
// is created (and the host does not provide all supported content for it), which is closer to the
34+
// behavior of actual plug-ins like Melodyne, and also allows for testing analysis and related
35+
// notifications in hosts that never request audio source analysis.
36+
#if !defined (ARA_ALWAYS_PERFORM_ANALYSIS)
37+
#define ARA_ALWAYS_PERFORM_ANALYSIS 0
38+
#endif
39+
40+
2941
class ARATestAudioSource;
3042
class ARATestPlaybackRenderer;
3143
class ARATestAnalysisTask;
3244

45+
/*******************************************************************************/
46+
class ARATestEditorView : public ARA::PlugIn::EditorView
47+
{
48+
public:
49+
using ARA::PlugIn::EditorView::EditorView;
50+
51+
protected:
52+
virtual void doNotifySelection (const ARA::PlugIn::ViewSelection* selection) noexcept;
53+
};
54+
3355
/*******************************************************************************/
3456
class ARATestDocumentController : public ARA::PlugIn::DocumentController
3557
{
@@ -99,6 +121,7 @@ class ARATestDocumentController : public ARA::PlugIn::DocumentController
99121

100122
// Plug-In Instance Management
101123
ARA::PlugIn::PlaybackRenderer* doCreatePlaybackRenderer () noexcept override;
124+
ARA::PlugIn::EditorView* doCreateEditorView () noexcept override;
102125

103126
public:
104127
// Render thread synchronization:
@@ -109,13 +132,13 @@ class ARATestDocumentController : public ARA::PlugIn::DocumentController
109132
bool rendererWillAccessModelGraph (ARATestPlaybackRenderer* playbackRenderer) noexcept;
110133
void rendererDidAccessModelGraph (ARATestPlaybackRenderer* playbackRenderer) noexcept;
111134

135+
void startOrScheduleAnalysisOfAudioSource (ARATestAudioSource* audioSource); // does nothing if already analyzing
136+
bool cancelAnalysisOfAudioSource (ARATestAudioSource* audioSource);
137+
112138
private:
113139
void disableRendererModelGraphAccess () noexcept;
114140
void enableRendererModelGraphAccess () noexcept;
115141

116-
void startOrScheduleAnalysisOfAudioSource (ARATestAudioSource* audioSource); // does nothing if already analyzing
117-
bool cancelAnalysisOfAudioSource (ARATestAudioSource* audioSource);
118-
119142
void startAnalysisTaskForAudioSource (ARATestAudioSource* audioSource);
120143
bool cancelAnalysisTaskForAudioSource (ARATestAudioSource* audioSource);
121144
ARATestAnalysisTask* getActiveAnalysisTaskForAudioSource (const ARATestAudioSource* audioSource) noexcept; // returns nullptr if no active analysis for given audio source

0 commit comments

Comments
 (0)