Guest User

Untitled

a guest
Dec 28th, 2012
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 29.13 KB | None | 0 0
  1. /*
  2.   ==============================================================================
  3.  
  4.    This file is part of the JUCE library - "Jules' Utility Class Extensions"
  5.    Copyright 2004-11 by Raw Material Software Ltd.
  6.  
  7.   ------------------------------------------------------------------------------
  8.  
  9.    JUCE can be redistributed and/or modified under the terms of the GNU General
  10.    Public License (Version 2), as published by the Free Software Foundation.
  11.    A copy of the license is included in the JUCE distribution, or can be found
  12.    online at www.gnu.org/licenses.
  13.  
  14.    JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  15.    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  16.    A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  17.  
  18.   ------------------------------------------------------------------------------
  19.  
  20.    To release a closed-source product which uses JUCE, commercial licenses are
  21.    available: visit www.rawmaterialsoftware.com/juce for more information.
  22.  
  23.   ==============================================================================
  24. */
  25.  
  26. #ifndef __JUCE_AUDIOPROCESSOR_JUCEHEADER__
  27. #define __JUCE_AUDIOPROCESSOR_JUCEHEADER__
  28.  
  29. #include "juce_AudioProcessorEditor.h"
  30. #include "juce_AudioProcessorListener.h"
  31. #include "juce_AudioPlayHead.h"
  32.  
  33.  
  34. //==============================================================================
  35. /**
  36.     Base class for audio processing filters or plugins.
  37.  
  38.     This is intended to act as a base class of audio filter that is general enough to
  39.     be wrapped as a VST, AU, RTAS, etc, or used internally.
  40.  
  41.     It is also used by the plugin hosting code as the wrapper around an instance
  42.     of a loaded plugin.
  43.  
  44.     Derive your filter class from this base class, and if you're building a plugin,
  45.     you should implement a global function called createPluginFilter() which creates
  46.     and returns a new instance of your subclass.
  47. */
  48. class JUCE_API  AudioProcessor
  49. {
  50. protected:
  51.     //==============================================================================
  52.     /** Constructor.
  53.  
  54.         You can also do your initialisation tasks in the initialiseFilterInfo()
  55.         call, which will be made after this object has been created.
  56.     */
  57.     AudioProcessor();
  58.  
  59. public:
  60.     /** Destructor. */
  61.     virtual ~AudioProcessor();
  62.  
  63.     //==============================================================================
  64.     /** Returns the name of this processor. */
  65.     virtual const String getName() const = 0;
  66.  
  67.     //==============================================================================
  68.     /** Called before playback starts, to let the filter prepare itself.
  69.  
  70.         The sample rate is the target sample rate, and will remain constant until
  71.         playback stops.
  72.  
  73.         The estimatedSamplesPerBlock value is a HINT about the typical number of
  74.         samples that will be processed for each callback, but isn't any kind
  75.         of guarantee. The actual block sizes that the host uses may be different
  76.         each time the callback happens, and may be more or less than this value.
  77.     */
  78.     virtual void prepareToPlay (double sampleRate,
  79.                                 int estimatedSamplesPerBlock) = 0;
  80.  
  81.     /** Called after playback has stopped, to let the filter free up any resources it
  82.         no longer needs.
  83.     */
  84.     virtual void releaseResources() = 0;
  85.  
  86.     /** Renders the next block.
  87.  
  88.         When this method is called, the buffer contains a number of channels which is
  89.         at least as great as the maximum number of input and output channels that
  90.         this filter is using. It will be filled with the filter's input data and
  91.         should be replaced with the filter's output.
  92.  
  93.         So for example if your filter has 2 input channels and 4 output channels, then
  94.         the buffer will contain 4 channels, the first two being filled with the
  95.         input data. Your filter should read these, do its processing, and replace
  96.         the contents of all 4 channels with its output.
  97.  
  98.         Or if your filter has 5 inputs and 2 outputs, the buffer will have 5 channels,
  99.         all filled with data, and your filter should overwrite the first 2 of these
  100.         with its output. But be VERY careful not to write anything to the last 3
  101.         channels, as these might be mapped to memory that the host assumes is read-only!
  102.  
  103.         Note that if you have more outputs than inputs, then only those channels that
  104.         correspond to an input channel are guaranteed to contain sensible data - e.g.
  105.         in the case of 2 inputs and 4 outputs, the first two channels contain the input,
  106.         but the last two channels may contain garbage, so you should be careful not to
  107.         let this pass through without being overwritten or cleared.
  108.  
  109.         Also note that the buffer may have more channels than are strictly necessary,
  110.         but your should only read/write from the ones that your filter is supposed to
  111.         be using.
  112.  
  113.         The number of samples in these buffers is NOT guaranteed to be the same for every
  114.         callback, and may be more or less than the estimated value given to prepareToPlay().
  115.         Your code must be able to cope with variable-sized blocks, or you're going to get
  116.         clicks and crashes!
  117.  
  118.         If the filter is receiving a midi input, then the midiMessages array will be filled
  119.         with the midi messages for this block. Each message's timestamp will indicate the
  120.         message's time, as a number of samples from the start of the block.
  121.  
  122.         Any messages left in the midi buffer when this method has finished are assumed to
  123.         be the filter's midi output. This means that your filter should be careful to
  124.         clear any incoming messages from the array if it doesn't want them to be passed-on.
  125.  
  126.         Be very careful about what you do in this callback - it's going to be called by
  127.         the audio thread, so any kind of interaction with the UI is absolutely
  128.         out of the question. If you change a parameter in here and need to tell your UI to
  129.         update itself, the best way is probably to inherit from a ChangeBroadcaster, let
  130.         the UI components register as listeners, and then call sendChangeMessage() inside the
  131.         processBlock() method to send out an asynchronous message. You could also use
  132.         the AsyncUpdater class in a similar way.
  133.     */
  134.     virtual void processBlock (AudioSampleBuffer& buffer,
  135.                                MidiBuffer& midiMessages) = 0;
  136.  
  137.     /** Renders the next block when the processor is being bypassed.
  138.         The default implementation of this method will pass-through any incoming audio, but
  139.         you may override this method e.g. to add latency compensation to the data to match
  140.         the processor's latency characteristics. This will avoid situations where bypassing
  141.         will shift the signal forward in time, possibly creating pre-echo effects and odd timings.
  142.         Another use for this method would be to cross-fade or morph between the wet (not bypassed)
  143.         and dry (bypassed) signals.
  144.     */
  145.     virtual void processBlockBypassed (AudioSampleBuffer& buffer,
  146.                                        MidiBuffer& midiMessages);
  147.  
  148.     //==============================================================================
  149.     /** Returns the current AudioPlayHead object that should be used to find
  150.         out the state and position of the playhead.
  151.  
  152.         You can call this from your processBlock() method, and use the AudioPlayHead
  153.         object to get the details about the time of the start of the block currently
  154.         being processed.
  155.  
  156.         If the host hasn't supplied a playhead object, this will return nullptr.
  157.     */
  158.     AudioPlayHead* getPlayHead() const noexcept                 { return playHead; }
  159.  
  160.  
  161.     //==============================================================================
  162.     /** Returns the current sample rate.
  163.  
  164.         This can be called from your processBlock() method - it's not guaranteed
  165.         to be valid at any other time, and may return 0 if it's unknown.
  166.     */
  167.     double getSampleRate() const noexcept                       { return sampleRate; }
  168.  
  169.     /** Returns the current typical block size that is being used.
  170.  
  171.         This can be called from your processBlock() method - it's not guaranteed
  172.         to be valid at any other time.
  173.  
  174.         Remember it's not the ONLY block size that may be used when calling
  175.         processBlock, it's just the normal one. The actual block sizes used may be
  176.         larger or smaller than this, and will vary between successive calls.
  177.     */
  178.     int getBlockSize() const noexcept                           { return blockSize; }
  179.  
  180.     //==============================================================================
  181.     /** Returns the number of input channels that the host will be sending the filter.
  182.  
  183.         If writing a plugin, your configuration macros should specify the number of
  184.         channels that your filter would prefer to have, and this method lets
  185.         you know how many the host is actually using.
  186.  
  187.         Note that this method is only valid during or after the prepareToPlay()
  188.         method call. Until that point, the number of channels will be unknown.
  189.     */
  190.     int getNumInputChannels() const noexcept                    { return numInputChannels; }
  191.  
  192.     /** Returns the number of output channels that the host will be sending the filter.
  193.  
  194.         If writing a plugin, your configuration macros should specify the number of
  195.         channels that your filter would prefer to have, and this method lets
  196.         you know how many the host is actually using.
  197.  
  198.         Note that this method is only valid during or after the prepareToPlay()
  199.         method call. Until that point, the number of channels will be unknown.
  200.     */
  201.     int getNumOutputChannels() const noexcept                   { return numOutputChannels; }
  202.  
  203.     /** Returns a string containing a whitespace-separated list of speaker types
  204.         corresponding to each input channel.
  205.         For example in a 5.1 arrangement, the string may be "L R C Lfe Ls Rs"
  206.         If the speaker arrangement is unknown, the returned string will be empty.
  207.     */
  208.     const String& getInputSpeakerArrangement() const noexcept   { return inputSpeakerArrangement; }
  209.  
  210.     /** Returns a string containing a whitespace-separated list of speaker types
  211.         corresponding to each output channel.
  212.         For example in a 5.1 arrangement, the string may be "L R C Lfe Ls Rs"
  213.         If the speaker arrangement is unknown, the returned string will be empty.
  214.     */
  215.     const String& getOutputSpeakerArrangement() const noexcept  { return outputSpeakerArrangement; }
  216.  
  217.     //==============================================================================
  218.     /** Returns the name of one of the processor's input channels.
  219.  
  220.         The processor might not supply very useful names for channels, and this might be
  221.         something like "1", "2", "left", "right", etc.
  222.     */
  223.     virtual const String getInputChannelName (int channelIndex) const = 0;
  224.  
  225.     /** Returns the name of one of the processor's output channels.
  226.  
  227.         The processor might not supply very useful names for channels, and this might be
  228.         something like "1", "2", "left", "right", etc.
  229.     */
  230.     virtual const String getOutputChannelName (int channelIndex) const = 0;
  231.  
  232.     /** Returns true if the specified channel is part of a stereo pair with its neighbour. */
  233.     virtual bool isInputChannelStereoPair (int index) const = 0;
  234.  
  235.     /** Returns true if the specified channel is part of a stereo pair with its neighbour. */
  236.     virtual bool isOutputChannelStereoPair (int index) const = 0;
  237.  
  238.     /** This returns the number of samples delay that the filter imposes on the audio
  239.         passing through it.
  240.  
  241.         The host will call this to find the latency - the filter itself should set this value
  242.         by calling setLatencySamples() as soon as it can during its initialisation.
  243.     */
  244.     int getLatencySamples() const noexcept                      { return latencySamples; }
  245.  
  246.     /** The filter should call this to set the number of samples delay that it introduces.
  247.  
  248.         The filter should call this as soon as it can during initialisation, and can call it
  249.         later if the value changes.
  250.     */
  251.     void setLatencySamples (int newLatency);
  252.  
  253.     /** Returns true if a silent input always produces a silent output (i.e. it has no tail). */
  254.     virtual bool silenceInProducesSilenceOut() const = 0;
  255.  
  256.     /** Returns true if the processor wants midi messages. */
  257.     virtual bool acceptsMidi() const = 0;
  258.  
  259.     /** Returns true if the processor produces midi messages. */
  260.     virtual bool producesMidi() const = 0;
  261.  
  262.     //==============================================================================
  263.     /** This returns a critical section that will automatically be locked while the host
  264.         is calling the processBlock() method.
  265.  
  266.         Use it from your UI or other threads to lock access to variables that are used
  267.         by the process callback, but obviously be careful not to keep it locked for
  268.         too long, because that could cause stuttering playback. If you need to do something
  269.         that'll take a long time and need the processing to stop while it happens, use the
  270.         suspendProcessing() method instead.
  271.  
  272.         @see suspendProcessing
  273.     */
  274.     const CriticalSection& getCallbackLock() const noexcept     { return callbackLock; }
  275.  
  276.     /** Enables and disables the processing callback.
  277.  
  278.         If you need to do something time-consuming on a thread and would like to make sure
  279.         the audio processing callback doesn't happen until you've finished, use this
  280.         to disable the callback and re-enable it again afterwards.
  281.  
  282.         E.g.
  283.         @code
  284.         void loadNewPatch()
  285.         {
  286.             suspendProcessing (true);
  287.  
  288.             ..do something that takes ages..
  289.  
  290.             suspendProcessing (false);
  291.         }
  292.         @endcode
  293.  
  294.         If the host tries to make an audio callback while processing is suspended, the
  295.         filter will return an empty buffer, but won't block the audio thread like it would
  296.         do if you use the getCallbackLock() critical section to synchronise access.
  297.  
  298.         If you're going to use this, your processBlock() method must call isSuspended() and
  299.         check whether it's suspended or not. If it is, then it should skip doing any real
  300.         processing, either emitting silence or passing the input through unchanged.
  301.  
  302.         @see getCallbackLock
  303.     */
  304.     void suspendProcessing (bool shouldBeSuspended);
  305.  
  306.     /** Returns true if processing is currently suspended.
  307.         @see suspendProcessing
  308.     */
  309.     bool isSuspended() const noexcept                                   { return suspended; }
  310.  
  311.     /** A plugin can override this to be told when it should reset any playing voices.
  312.  
  313.         The default implementation does nothing, but a host may call this to tell the
  314.         plugin that it should stop any tails or sounds that have been left running.
  315.     */
  316.     virtual void reset();
  317.  
  318.     //==============================================================================
  319.     /** Returns true if the processor is being run in an offline mode for rendering.
  320.  
  321.         If the processor is being run live on realtime signals, this returns false.
  322.         If the mode is unknown, this will assume it's realtime and return false.
  323.  
  324.         This value may be unreliable until the prepareToPlay() method has been called,
  325.         and could change each time prepareToPlay() is called.
  326.  
  327.         @see setNonRealtime()
  328.     */
  329.     bool isNonRealtime() const noexcept                                 { return nonRealtime; }
  330.  
  331.     /** Called by the host to tell this processor whether it's being used in a non-realime
  332.         capacity for offline rendering or bouncing.
  333.  
  334.         Whatever value is passed-in will be
  335.     */
  336.     void setNonRealtime (bool isNonRealtime) noexcept;
  337.  
  338.     //==============================================================================
  339.     /** Creates the filter's UI.
  340.  
  341.         This can return nullptr if you want a UI-less filter, in which case the host may create
  342.         a generic UI that lets the user twiddle the parameters directly.
  343.  
  344.         If you do want to pass back a component, the component should be created and set to
  345.         the correct size before returning it. If you implement this method, you must
  346.         also implement the hasEditor() method and make it return true.
  347.  
  348.         Remember not to do anything silly like allowing your filter to keep a pointer to
  349.         the component that gets created - it could be deleted later without any warning, which
  350.         would make your pointer into a dangler. Use the getActiveEditor() method instead.
  351.  
  352.         The correct way to handle the connection between an editor component and its
  353.         filter is to use something like a ChangeBroadcaster so that the editor can
  354.         register itself as a listener, and be told when a change occurs. This lets them
  355.         safely unregister themselves when they are deleted.
  356.  
  357.         Here are a few things to bear in mind when writing an editor:
  358.  
  359.         - Initially there won't be an editor, until the user opens one, or they might
  360.           not open one at all. Your filter mustn't rely on it being there.
  361.         - An editor object may be deleted and a replacement one created again at any time.
  362.         - It's safe to assume that an editor will be deleted before its filter.
  363.  
  364.         @see hasEditor
  365.     */
  366.     virtual AudioProcessorEditor* createEditor() = 0;
  367.  
  368.     /** Your filter must override this and return true if it can create an editor component.
  369.         @see createEditor
  370.     */
  371.     virtual bool hasEditor() const = 0;
  372.  
  373.     //==============================================================================
  374.     /** Returns the active editor, if there is one.
  375.         Bear in mind this can return nullptr, even if an editor has previously been opened.
  376.     */
  377.     AudioProcessorEditor* getActiveEditor() const noexcept             { return activeEditor; }
  378.  
  379.     /** Returns the active editor, or if there isn't one, it will create one.
  380.         This may call createEditor() internally to create the component.
  381.     */
  382.     AudioProcessorEditor* createEditorIfNeeded();
  383.  
  384.     //==============================================================================
  385.     /** This must return the correct value immediately after the object has been
  386.         created, and mustn't change the number of parameters later.
  387.     */
  388.     virtual int getNumParameters() = 0;
  389.  
  390.     /** Returns the name of a particular parameter. */
  391.     virtual const String getParameterName (int parameterIndex) = 0;
  392.  
  393.     /** Called by the host to find out the value of one of the filter's parameters.
  394.  
  395.         The host will expect the value returned to be between 0 and 1.0.
  396.  
  397.         This could be called quite frequently, so try to make your code efficient.
  398.         It's also likely to be called by non-UI threads, so the code in here should
  399.         be thread-aware.
  400.     */
  401.     virtual float getParameter (int parameterIndex) = 0;
  402.  
  403.     /** Returns the value of a parameter as a text string. */
  404.     virtual const String getParameterText (int parameterIndex) = 0;
  405.  
  406.     /** Some plugin types may be able to return a label string for a
  407.         parameter's units.
  408.     */
  409.     virtual String getParameterLabel (int index) const;
  410.  
  411.     /** The host will call this method to change the value of one of the filter's parameters.
  412.  
  413.         The host may call this at any time, including during the audio processing
  414.         callback, so the filter has to process this very fast and avoid blocking.
  415.  
  416.         If you want to set the value of a parameter internally, e.g. from your
  417.         editor component, then don't call this directly - instead, use the
  418.         setParameterNotifyingHost() method, which will also send a message to
  419.         the host telling it about the change. If the message isn't sent, the host
  420.         won't be able to automate your parameters properly.
  421.  
  422.         The value passed will be between 0 and 1.0.
  423.     */
  424.     virtual void setParameter (int parameterIndex, float newValue) = 0;
  425.  
  426.     /** Your filter can call this when it needs to change one of its parameters.
  427.  
  428.         This could happen when the editor or some other internal operation changes
  429.         a parameter. This method will call the setParameter() method to change the
  430.         value, and will then send a message to the host telling it about the change.
  431.  
  432.         Note that to make sure the host correctly handles automation, you should call
  433.         the beginParameterChangeGesture() and endParameterChangeGesture() methods to
  434.         tell the host when the user has started and stopped changing the parameter.
  435.     */
  436.     void setParameterNotifyingHost (int parameterIndex, float newValue);
  437.  
  438.     /** Returns true if the host can automate this parameter.
  439.  
  440.         By default, this returns true for all parameters.
  441.     */
  442.     virtual bool isParameterAutomatable (int parameterIndex) const;
  443.  
  444.     /** Should return true if this parameter is a "meta" parameter.
  445.  
  446.         A meta-parameter is a parameter that changes other params. It is used
  447.         by some hosts (e.g. AudioUnit hosts).
  448.  
  449.         By default this returns false.
  450.     */
  451.     virtual bool isMetaParameter (int parameterIndex) const;
  452.  
  453.     /** Sends a signal to the host to tell it that the user is about to start changing this
  454.         parameter.
  455.  
  456.         This allows the host to know when a parameter is actively being held by the user, and
  457.         it may use this information to help it record automation.
  458.  
  459.         If you call this, it must be matched by a later call to endParameterChangeGesture().
  460.     */
  461.     void beginParameterChangeGesture (int parameterIndex);
  462.  
  463.     /** Tells the host that the user has finished changing this parameter.
  464.  
  465.         This allows the host to know when a parameter is actively being held by the user, and
  466.         it may use this information to help it record automation.
  467.  
  468.         A call to this method must follow a call to beginParameterChangeGesture().
  469.     */
  470.     void endParameterChangeGesture (int parameterIndex);
  471.  
  472.     /** The filter can call this when something (apart from a parameter value) has changed.
  473.  
  474.         It sends a hint to the host that something like the program, number of parameters,
  475.         etc, has changed, and that it should update itself.
  476.     */
  477.     void updateHostDisplay();
  478.  
  479.     //==============================================================================
  480.     /** Returns the number of preset programs the filter supports.
  481.  
  482.         The value returned must be valid as soon as this object is created, and
  483.         must not change over its lifetime.
  484.  
  485.         This value shouldn't be less than 1.
  486.     */
  487.     virtual int getNumPrograms() = 0;
  488.  
  489.     /** Returns the number of the currently active program. */
  490.     virtual int getCurrentProgram() = 0;
  491.  
  492.     /** Called by the host to change the current program. */
  493.     virtual void setCurrentProgram (int index) = 0;
  494.  
  495.     /** Must return the name of a given program. */
  496.     virtual const String getProgramName (int index) = 0;
  497.  
  498.     /** Called by the host to rename a program. */
  499.     virtual void changeProgramName (int index, const String& newName) = 0;
  500.  
  501.     //==============================================================================
  502.     /** The host will call this method when it wants to save the filter's internal state.
  503.  
  504.         This must copy any info about the filter's state into the block of memory provided,
  505.         so that the host can store this and later restore it using setStateInformation().
  506.  
  507.         Note that there's also a getCurrentProgramStateInformation() method, which only
  508.         stores the current program, not the state of the entire filter.
  509.  
  510.         See also the helper function copyXmlToBinary() for storing settings as XML.
  511.  
  512.         @see getCurrentProgramStateInformation
  513.     */
  514.     virtual void getStateInformation (juce::MemoryBlock& destData) = 0;
  515.  
  516.     /** The host will call this method if it wants to save the state of just the filter's
  517.         current program.
  518.  
  519.         Unlike getStateInformation, this should only return the current program's state.
  520.  
  521.         Not all hosts support this, and if you don't implement it, the base class
  522.         method just calls getStateInformation() instead. If you do implement it, be
  523.         sure to also implement getCurrentProgramStateInformation.
  524.  
  525.         @see getStateInformation, setCurrentProgramStateInformation
  526.     */
  527.     virtual void getCurrentProgramStateInformation (juce::MemoryBlock& destData);
  528.  
  529.     /** This must restore the filter's state from a block of data previously created
  530.         using getStateInformation().
  531.  
  532.         Note that there's also a setCurrentProgramStateInformation() method, which tries
  533.         to restore just the current program, not the state of the entire filter.
  534.  
  535.         See also the helper function getXmlFromBinary() for loading settings as XML.
  536.  
  537.         @see setCurrentProgramStateInformation
  538.     */
  539.     virtual void setStateInformation (const void* data, int sizeInBytes) = 0;
  540.  
  541.     /** The host will call this method if it wants to restore the state of just the filter's
  542.         current program.
  543.  
  544.         Not all hosts support this, and if you don't implement it, the base class
  545.         method just calls setStateInformation() instead. If you do implement it, be
  546.         sure to also implement getCurrentProgramStateInformation.
  547.  
  548.         @see setStateInformation, getCurrentProgramStateInformation
  549.     */
  550.     virtual void setCurrentProgramStateInformation (const void* data, int sizeInBytes);
  551.  
  552.     /** This method is called when the number of input or output channels is changed. */
  553.     virtual void numChannelsChanged();
  554.  
  555.     //==============================================================================
  556.     /** Adds a listener that will be called when an aspect of this processor changes. */
  557.     void addListener (AudioProcessorListener* newListener);
  558.  
  559.     /** Removes a previously added listener. */
  560.     void removeListener (AudioProcessorListener* listenerToRemove);
  561.  
  562.     //==============================================================================
  563.     /** Tells the processor to use this playhead object.
  564.         The processor will not take ownership of the object, so the caller must delete it when
  565.         it is no longer being used.
  566.     */
  567.     void setPlayHead (AudioPlayHead* newPlayHead) noexcept;
  568.  
  569.     //==============================================================================
  570.     /** Not for public use - this is called before deleting an editor component. */
  571.     void editorBeingDeleted (AudioProcessorEditor*) noexcept;
  572.  
  573.     /** Not for public use - this is called to initialise the processor before playing. */
  574.     void setPlayConfigDetails (int numIns, int numOuts, double sampleRate, int blockSize) noexcept;
  575.  
  576.     /** Not for public use - this is called to initialise the processor before playing. */
  577.     void setSpeakerArrangement (const String& inputs, const String& outputs);
  578.  
  579.     /** Flags to indicate the type of plugin context in which a processor is being used. */
  580.     enum WrapperType
  581.     {
  582.         wrapperType_Undefined = 0,
  583.         wrapperType_VST,
  584.         wrapperType_AudioUnit,
  585.         wrapperType_RTAS,
  586.         wrapperType_AAX,
  587.         wrapperType_Standalone
  588.     };
  589.  
  590.     /** When loaded by a plugin wrapper, this flag will be set to indicate the type
  591.         of plugin within which the processor is running.
  592.     */
  593.     WrapperType wrapperType;
  594.  
  595.     /** @internal */
  596.     static void setTypeOfNextNewPlugin (WrapperType);
  597.  
  598. protected:
  599.     //==============================================================================
  600.     /** Helper function that just converts an xml element into a binary blob.
  601.  
  602.         Use this in your filter's getStateInformation() method if you want to
  603.         store its state as xml.
  604.  
  605.         Then use getXmlFromBinary() to reverse this operation and retrieve the XML
  606.         from a binary blob.
  607.     */
  608.     static void copyXmlToBinary (const XmlElement& xml,
  609.                                  juce::MemoryBlock& destData);
  610.  
  611.     /** Retrieves an XML element that was stored as binary with the copyXmlToBinary() method.
  612.  
  613.         This might return nullptr if the data's unsuitable or corrupted. Otherwise it will return
  614.         an XmlElement object that the caller must delete when no longer needed.
  615.     */
  616.     static XmlElement* getXmlFromBinary (const void* data, int sizeInBytes);
  617.  
  618.     /** @internal */
  619.     AudioPlayHead* playHead;
  620.  
  621.     /** @internal */
  622.     void sendParamChangeMessageToListeners (int parameterIndex, float newValue);
  623.  
  624. private:
  625.     Array <AudioProcessorListener*> listeners;
  626.     Component::SafePointer<AudioProcessorEditor> activeEditor;
  627.     double sampleRate;
  628.     int blockSize, numInputChannels, numOutputChannels, latencySamples;
  629.     bool suspended, nonRealtime;
  630.     CriticalSection callbackLock, listenerLock;
  631.     String inputSpeakerArrangement, outputSpeakerArrangement;
  632.  
  633.    #if JUCE_DEBUG
  634.     BigInteger changingParams;
  635.    #endif
  636.  
  637.     JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioProcessor)
  638. };
  639.  
  640.  
  641. #endif   // __JUCE_AUDIOPROCESSOR_JUCEHEADER__
Advertisement
Add Comment
Please, Sign In to add comment