AAX SDK  2.4.1
Avid Audio Extensions Development Kit
AAX_CMonolithicParameters.h
Go to the documentation of this file.
1 /*================================================================================================*/
2 /*
3  * Copyright 2014-2016, 2019 by Avid Technology, Inc.
4  * All rights reserved.
5  *
6  * CONFIDENTIAL: This document contains confidential information. Do not
7  * read or examine this document unless you are an Avid Technology employee
8  * or have signed a non-disclosure agreement with Avid Technology which protects
9  * the confidentiality of this document. DO NOT DISCLOSE ANY INFORMATION
10  * CONTAINED IN THIS DOCUMENT TO ANY THIRD-PARTY WITHOUT THE PRIOR WRITTEN CONSENT
11  * OF Avid Technology, INC.
12  */
13 
20 /*================================================================================================*/
21 
22 
23 #ifndef AAX_CMONOLITHICPARAMETERS_H
24 #define AAX_CMONOLITHICPARAMETERS_H
25 
26 // AAX headers
27 //
28 // Parent class
29 #include "AAX_CEffectParameters.h"
30 //
31 // Describe
32 #include "AAX_IEffectDescriptor.h"
34 #include "AAX_IPropertyMap.h"
35 //
36 // Utilities
37 #include "AAX_CAtomicQueue.h"
38 #include "AAX_IParameter.h"
39 #include "AAX_IMIDINode.h"
40 #include "AAX_IString.h"
41 
42 // Standard Includes
43 #include <set>
44 #include <list>
45 #include <utility>
46 
47 
48 // Max number of additional midi nodes is 15, for a grand total of 16 input midi nodes. We're not aware of any plug-in that uses more.
49 #define kMaxAdditionalMIDINodes 15
50 
51 // You can increase this if you need, it is not a system limitation.
52 #define kMaxAuxOutputStems 32
53 
54 // You can increase this if you need; it should be set to a value greater than or equal to the number of synchronized parameters in your plug-in
55 #define kSynchronizedParameterQueueSize 32
56 
57 
64 {
65  //Global MIDI Nodes
67  const char* mGlobalMIDINodeName;
69 
70  //Input MIDI Nodes
72  const char* mInputMIDINodeName;
75 
76  //Transport
78  const char* mTransportMIDINodeName;
79 
80  //Meters
81  int32_t mNumMeters;
83 
84  //Aux Output Stems Feature.
88 
89  //AAX Hybrid
92 
93 
94  //General Properties
98  bool mCanBypass;
103 
111 
112 
119  {
120  mNeedsGlobalMIDI = false;
121  mGlobalMIDINodeName = "GlobalMIDI";
122  mGlobalMIDIEventMask = 0xffff;
123  mNeedsInputMIDI = false;
124  mInputMIDINodeName = "InputMIDI";
125  mInputMIDIChannelMask = 0xffff;
127  mNeedsTransport = false;
128  mTransportMIDINodeName = "Transport";
129  mNumMeters = 0;
130  mMeterIDs = 0;
133  mUseHostGeneratedGUI = false;
134  mCanBypass = true;
135  mManufacturerID = 'none';
136  mProductID = 'none';
137  mPluginID = 'none';
138  mAudiosuiteID = 'none';
139  mMultiMonoSupport = true;
140 
141  mNumAuxOutputStems = 0;
142  for (int32_t i=0; i<kMaxAuxOutputStems; i++)
143  {
144  mAuxOutputStemNames[i] = 0;
146  }
147 
150  }
151 };
152 
153 class AAX_CMonolithicParameters; //predefined for AAX_SInstrumentPrivateData
160 {
168 
169  //<DMT> Removed mOutputStemFormat. Adding it to this structure was not intentional. Please call Controller()->GetOutputStemFormat() from your RenderAudio call if you need this info.
170  //<DMT> Please note, nothing else should be added to this struct. All host information is accessible through the AAX_IController in the RenderAudio call.
171 };
172 
173 
178 {
179  float** mAudioInputs;
180  float** mAudioOutputs;
181  int32_t* mNumSamples;
183 
188 
190 
191  float** mMeters;
192 
193  int64_t* mCurrentStateNum;
194 };
195 
221 {
222 public:
225 
226 protected:
227  typedef std::pair<AAX_CParamID const, const AAX_IParameterValue*> TParamValPair;
228 
244  virtual void RenderAudio(AAX_SInstrumentRenderInfo* ioRenderInfo, const TParamValPair* inSynchronizedParamValues[], int32_t inNumSynchronizedParamValues) {}
246 
261  void AddSynchronizedParameter(const AAX_IParameter& inParameter);
263 
264 public:
271  // Overrides from \ref AAX_CEffectParameters
274  AAX_Result ResetFieldData (AAX_CFieldIndex iFieldIndex, void * oData, uint32_t iDataSize) const AAX_OVERRIDE;
284  static AAX_Result StaticDescribe (AAX_IEffectDescriptor * ioDescriptor, const AAX_SInstrumentSetupInfo & setupInfo);
293  static void AAX_CALLBACK StaticRenderAudio(AAX_SInstrumentRenderInfo* const inInstancesBegin [], const void* inInstancesEnd);
295 
296 private:
297  // This structure is used on the render thread to set up the contiguous array of TParamValPair* values
298  // which is passed to RenderAudio(). The values are drawn from lists of parameter value updates which
299  // were queued during GenerateCoefficients()
300  struct SParamValList
301  {
302  // Using 4x the preset queue size: the buffer must be large enough to accommodate the maximum
303  // number of updates that we expect to be queued between/before executions of the render callback.
304  // The maximum queuing that will likely ever occur is during a preset change (i.e. a call to
305  // SetChunk()), in which updates to all parameters may be queued in the same state frame. It is
306  // possible that the host would call SetChunk() on the plug-in more than once before the render
307  // callback executes, but probably not more than 2-3x. Therefore 4x seems like a safe upper limit
308  // for the capacity of this buffer.
309  static const int32_t sCap = 4*kSynchronizedParameterQueueSize;
310 
311  TParamValPair* mElem[sCap];
312  int32_t mSize;
313 
314  SParamValList()
315  {
316  Clear();
317  }
318 
319  void Add(TParamValPair* inElem)
320  {
321  AAX_ASSERT(sCap > mSize);
322  if (sCap > mSize)
323  {
324  mElem[mSize++] = inElem;
325  }
326  }
327 
328  void Append(const SParamValList& inOther)
329  {
330  AAX_ASSERT(sCap >= mSize + inOther.mSize);
331  for (int32_t i = 0; i < inOther.mSize; ++i)
332  {
333  Add(inOther.mElem[i]);
334  }
335  }
336 
337  void Append(const std::list<TParamValPair*>& inOther)
338  {
339  AAX_ASSERT(sCap >= mSize + (int64_t)inOther.size());
340  for (std::list<TParamValPair*>::const_iterator iter = inOther.begin(); iter != inOther.end(); ++iter)
341  {
342  Add(*iter);
343  }
344  }
345 
346  void Merge(AAX_IPointerQueue<TParamValPair>& inOther)
347  {
348  do
349  {
350  TParamValPair* const val = inOther.Pop();
351  if (NULL == val) { break; }
352  Add(val);
353  } while (1);
354  }
355 
356  void Clear()
357  {
358  std::memset(mElem, 0x0, sizeof(mElem));
359  mSize = 0;
360  }
361  };
362 
363  typedef std::set<const AAX_IParameter*> TParamSet;
364  typedef std::pair<int64_t, std::list<TParamValPair*> > TNumberedParamStateList;
365  typedef AAX_CAtomicQueue<TNumberedParamStateList, 256> TNumberedStateListQueue;
367 
368 
369  SParamValList GetUpdatesForState(int64_t inTargetStateNum);
370  void DeleteUsedParameterChanges();
371 
372 private:
373  std::set<std::string> mSynchronizedParameters;
374  int64_t mStateCounter;
375  TParamSet mDirtyParameters;
376  TNumberedStateListQueue mQueuedParameterChanges;
377  TNumberedStateListQueue mFinishedParameterChanges; // Parameter changes ready for deletion
378  TParamValPairQueue mFinishedParameterValues; // Parameter values ready for deletion
379 };
380 
381 
382 
383 
384 
385 #endif // AAX_CMONOLITHICPARAMETERS_H
const char * AAX_CParamID
Parameter identifier.
Definition: AAX.h:352
int32_t AAX_Result
Definition: AAX.h:337
uint8_t AAX_CBoolean
Cross-compiler boolean type used by AAX interfaces.
Definition: AAX.h:329
#define AAX_CALLBACK
Definition: AAX.h:285
int64_t AAX_CTimestamp
Time stamp value. Measured against the DAE clock (see AAX_IComponentDescriptor::AddClock() )
Definition: AAX.h:331
#define AAX_OVERRIDE
override keyword macro
Definition: AAX.h:141
uint32_t AAX_CTypeID
Matches type of OSType used in classic plugins.
Definition: AAX.h:336
AAX_CIndex AAX_CFieldIndex
Not used by AAX plug-ins (except in AAX_FIELD_INDEX macro)
Definition: AAX.h:349
#define AAX_ASSERT(condition)
Asserts that a condition is true and logs an error if the condition is false.
Definition: AAX_Assert.h:268
Atomic, non-blocking queue.
A default implementation of the AAX_IeffectParameters interface.
AAX_EUpdateSource
Source for values passed into UpdateParameterNormalizedValue().
Definition: AAX_Enums.h:1028
AAX_EStemFormat
Stem format definitions.
Definition: AAX_Enums.h:232
@ AAX_eStemFormat_Mono
M.
Definition: AAX_Enums.h:234
@ AAX_eStemFormat_None
Definition: AAX_Enums.h:264
Description interface for an AAX plug-in algorithm.
Description interface for an effect's (plug-in type's) components.
Declaration of the base MIDI Node interface.
The base interface for all normalizable plug-in parameters.
Generic plug-in description property map.
An AAX string interface.
#define kSynchronizedParameterQueueSize
Definition: AAX_CMonolithicParameters.h:55
#define kMaxAuxOutputStems
Definition: AAX_CMonolithicParameters.h:52
#define kMaxAdditionalMIDINodes
Definition: AAX_CMonolithicParameters.h:49
Default implementation of the AAX_IEffectParameters interface.
Definition: AAX_CEffectParameters.h:66
Description interface for an effect's (plug-in type's) components.
Definition: AAX_IEffectDescriptor.h:50
Interface for accessing information in a MIDI node.
Definition: AAX_IMIDINode.h:40
The base interface for all normalizable plug-in parameters.
Definition: AAX_IParameter.h:140
Definition: AAX_IPointerQueue.h:35
virtual value_type Pop()=0
Information used to describe the instrument.
Definition: AAX_CMonolithicParameters.h:64
AAX_CBoolean mMultiMonoSupport
Definition: AAX_CMonolithicParameters.h:110
AAX_CTypeID mProductID
Product ID
Definition: AAX_CMonolithicParameters.h:100
AAX_EStemFormat mHybridOutputStemFormat
Hybrid output stem format
Definition: AAX_CMonolithicParameters.h:91
int32_t mNumAdditionalInputMIDINodes
Number of additional input MIDI Nodes. These will all share the same channelMask and base MIDINodeNam...
Definition: AAX_CMonolithicParameters.h:74
bool mUseHostGeneratedGUI
Allow Pro Tools or other host to generate a generic GUI. This can be useful for early development.
Definition: AAX_CMonolithicParameters.h:97
uint32_t mGlobalMIDIEventMask
Global MIDI node event mask of AAX_EMidiGlobalNodeSelectors, if used.
Definition: AAX_CMonolithicParameters.h:68
const char * mAuxOutputStemNames[kMaxAuxOutputStems]
Names of the aux output stems.
Definition: AAX_CMonolithicParameters.h:86
int32_t mNumMeters
Number of meter taps used by the instrument. Must match the size of mMeterIDs.
Definition: AAX_CMonolithicParameters.h:81
bool mNeedsInputMIDI
Does the instrument use a local MIDI input node?
Definition: AAX_CMonolithicParameters.h:71
AAX_CTypeID mPluginID
Plug-In (Type) ID
Definition: AAX_CMonolithicParameters.h:101
bool mCanBypass
Can this instrument be bypassed?
Definition: AAX_CMonolithicParameters.h:98
const char * mTransportMIDINodeName
Name of the MIDI transport node, if used.
Definition: AAX_CMonolithicParameters.h:78
const AAX_CTypeID * mMeterIDs
Array of meter IDs.
Definition: AAX_CMonolithicParameters.h:82
AAX_CTypeID mAudiosuiteID
AudioSuite ID
Definition: AAX_CMonolithicParameters.h:102
AAX_CTypeID mManufacturerID
Manufacturer ID
Definition: AAX_CMonolithicParameters.h:99
AAX_SInstrumentSetupInfo()
Default constructor.
Definition: AAX_CMonolithicParameters.h:118
AAX_EStemFormat mOutputStemFormat
Output stem format
Definition: AAX_CMonolithicParameters.h:96
const char * mInputMIDINodeName
Name of the MIDI input node, if used.
Definition: AAX_CMonolithicParameters.h:72
int32_t mNumAuxOutputStems
Number of aux output stems for the plug-in.
Definition: AAX_CMonolithicParameters.h:85
uint32_t mInputMIDIChannelMask
MIDI input node channel mask, if used.
Definition: AAX_CMonolithicParameters.h:73
const char * mGlobalMIDINodeName
Name of the global MIDI node, if used.
Definition: AAX_CMonolithicParameters.h:67
bool mNeedsGlobalMIDI
Does the instrument use a global MIDI input node?
Definition: AAX_CMonolithicParameters.h:66
AAX_EStemFormat mInputStemFormat
Input stem format
Definition: AAX_CMonolithicParameters.h:95
AAX_EStemFormat mHybridInputStemFormat
Hybrid input stem format
Definition: AAX_CMonolithicParameters.h:90
bool mNeedsTransport
Does the instrument use the transport interface?
Definition: AAX_CMonolithicParameters.h:77
AAX_EStemFormat mAuxOutputStemFormats[kMaxAuxOutputStems]
Stem formats for the output stems.
Definition: AAX_CMonolithicParameters.h:87
Utility struct for AAX_CMonolithicParameters.
Definition: AAX_CMonolithicParameters.h:160
AAX_CMonolithicParameters * mMonolithicParametersPtr
A pointer to the instrument's data model.
Definition: AAX_CMonolithicParameters.h:167
Information used to parameterize AAX_CMonolithicParameters::RenderAudio()
Definition: AAX_CMonolithicParameters.h:178
float ** mAudioOutputs
Audio output buffers, including any aux output stems.
Definition: AAX_CMonolithicParameters.h:180
AAX_IMIDINode * mGlobalNode
Buffered global MIDI input node. Used for global events like beat updates in metronomes.
Definition: AAX_CMonolithicParameters.h:185
AAX_CTimestamp * mClock
Pointer to the global running time clock.
Definition: AAX_CMonolithicParameters.h:182
AAX_IMIDINode * mTransportNode
Transport MIDI node. Used for querying the state of the MIDI transport.
Definition: AAX_CMonolithicParameters.h:186
float ** mMeters
Array of meter taps. One meter value should be entered per tap for each render call.
Definition: AAX_CMonolithicParameters.h:191
int32_t * mNumSamples
Number of samples in each buffer. Bounded as per AAE_EAudioBufferLengthNative. The exact value can va...
Definition: AAX_CMonolithicParameters.h:181
int64_t * mCurrentStateNum
State counter.
Definition: AAX_CMonolithicParameters.h:193
float ** mAudioInputs
Audio input buffers.
Definition: AAX_CMonolithicParameters.h:179
AAX_IMIDINode * mInputNode
Buffered local MIDI input node. Used for incoming MIDI messages directed to the instrument.
Definition: AAX_CMonolithicParameters.h:184
AAX_IMIDINode * mAdditionalInputMIDINodes[kMaxAdditionalMIDINodes]
List of additional input MIDI nodes, if your plugin needs them.
Definition: AAX_CMonolithicParameters.h:187
AAX_SInstrumentPrivateData * mPrivateData
Struct containing private data relating to the instance. You should not need to use this data.
Definition: AAX_CMonolithicParameters.h:189
Extension of the AAX_CEffectParameters class for monolithic VIs and effects.
Definition: AAX_CMonolithicParameters.h:221
virtual void RenderAudio(AAX_SInstrumentRenderInfo *ioRenderInfo, const TParamValPair *inSynchronizedParamValues[], int32_t inNumSynchronizedParamValues)
Definition: AAX_CMonolithicParameters.h:244
void AddSynchronizedParameter(const AAX_IParameter &inParameter)
Definition: AAX_CMonolithicParameters.cpp:40
AAX_CMonolithicParameters(void)
Definition: AAX_CMonolithicParameters.cpp:22
AAX_Result ResetFieldData(AAX_CFieldIndex iFieldIndex, void *oData, uint32_t iDataSize) const AAX_OVERRIDE
Called by the host to reset a private data field in the plug-in's algorithm.
Definition: AAX_CMonolithicParameters.cpp:104
AAX_Result GenerateCoefficients() AAX_OVERRIDE
Generates and dispatches new coefficient packets.
Definition: AAX_CMonolithicParameters.cpp:65
static AAX_Result StaticDescribe(AAX_IEffectDescriptor *ioDescriptor, const AAX_SInstrumentSetupInfo &setupInfo)
Definition: AAX_CMonolithicParameters.cpp:132
AAX_Result UpdateParameterNormalizedValue(AAX_CParamID iParamID, double aValue, AAX_EUpdateSource inSource) AAX_OVERRIDE
Updates a single parameter's state to its current value.
Definition: AAX_CMonolithicParameters.cpp:47
std::pair< AAX_CParamID const, const AAX_IParameterValue * > TParamValPair
Definition: AAX_CMonolithicParameters.h:227
AAX_Result TimerWakeup() AAX_OVERRIDE
Periodic wakeup callback for idle-time operations.
Definition: AAX_CMonolithicParameters.cpp:123
~AAX_CMonolithicParameters(void) AAX_OVERRIDE
Definition: AAX_CMonolithicParameters.cpp:34
static void AAX_CALLBACK StaticRenderAudio(AAX_SInstrumentRenderInfo *const inInstancesBegin[], const void *inInstancesEnd)
Definition: AAX_CMonolithicParameters.cpp:236