Jamba C++ API 7.5.0
Loading...
Searching...
No Matches
RTProcessor.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018-2019 pongasoft
3 *
4 * Licensed under the Apache License, Version 2.0 or the MIT license,
5 * at your option. You may not use this file except in compliance with
6 * one of these licenses. You may obtain copies of the licenses at:
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 * https://opensource.org/licenses/MIT
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 *
17 * @author Yan Pujante
18 */
19#pragma once
20
21#include <base/source/timer.h>
22#include <public.sdk/source/vst/vstaudioeffect.h>
23#include <pongasoft/VST/Timer.h>
24#include "RTState.h"
25
26namespace pongasoft {
27namespace VST {
28namespace RT {
29
30using namespace Steinberg;
31using namespace Steinberg::Vst;
32
38class RTProcessor : public AudioEffect, public IMessageProducer
39{
40public:
41 explicit RTProcessor(Steinberg::FUID const &iControllerUID);
42
43 ~RTProcessor() override = default;
44
48 virtual RTState *getRTState() = 0;
49
51 tresult PLUGIN_API initialize(FUnknown *context) override;
52
54 tresult PLUGIN_API setActive(TBool state) override;
55
57 tresult PLUGIN_API process(ProcessData &data) override;
58
60 tresult PLUGIN_API canProcessSampleSize(int32 symbolicSampleSize) override;
61
63 tresult PLUGIN_API setState(IBStream *state) override;
64
66 tresult PLUGIN_API getState(IBStream *state) override;
67
69 tresult PLUGIN_API notify(IMessage *message) SMTG_OVERRIDE;
70
71protected:
74 virtual bool canProcess32Bits() const { return true; }
75
78 virtual bool canProcess64Bits() const { return true; }
79
84 virtual tresult processInputs(ProcessData &data);
85
89 virtual tresult processInputs32Bits(ProcessData &data) { return kResultOk; }
90
94 virtual tresult processInputs64Bits(ProcessData &data) { return kResultOk; }
95
102 virtual void onGUITimer() {}
103
108 void enableGUITimer(uint32 iUIFrameRateMs);
109
113
114protected:
115 // interval for gui message timer (can be changed by subclass BEFORE calling initialize)
117
118public:
119 // allocateMessage
120 IPtr<IMessage> allocateMessage() override;
121
122 // sendMessage
123 tresult sendMessage(IPtr<IMessage> iMessage) override;
124
125private:
126 using RTProcessorCallback = void (RTProcessor::*)();
127
128 // wrapper class to dispatch the callback
129 class GUITimerCallback : public ITimerCallback
130 {
131 public:
132 explicit GUITimerCallback(RTProcessor *iProcessor,
133 RTProcessorCallback iCallback) : fProcessor{iProcessor}, fCallback{iCallback} {}
134
135 void onTimer(Timer *timer) override
136 {
137 (fProcessor->*fCallback)();
138 }
139 private:
142 };
143
144
145
146private:
147 // the generic gui timer (enabled with enableGUITimer)
150 std::unique_ptr<AutoReleaseTimer> fGUITimer;
151
152 // the timer that will handle sending messages (enabled when there are messages to handle)
154 std::unique_ptr<AutoReleaseTimer> fGUIMessageTimer;
155
157
158#ifdef JAMBA_DEBUG_LOGGING
159 int32 fSymbolicSampleSize = -1;
160#endif
161};
162
163}
164}
165}
Abstraction for allocating and sending a message.
Definition MessageProducer.h:35
void onTimer(Timer *timer) override
Definition RTProcessor.h:135
RTProcessor * fProcessor
Definition RTProcessor.h:140
GUITimerCallback(RTProcessor *iProcessor, RTProcessorCallback iCallback)
Definition RTProcessor.h:132
RTProcessorCallback fCallback
Definition RTProcessor.h:141
tresult PLUGIN_API setState(IBStream *state) override
Restore the state (ex: after loading preset or project).
Definition RTProcessor.cpp:167
tresult PLUGIN_API process(ProcessData &data) override
Here we go...the process call.
Definition RTProcessor.cpp:87
GUITimerCallback fGUIMessageTimerCallback
Definition RTProcessor.h:153
tresult PLUGIN_API initialize(FUnknown *context) override
Called at first after constructor (setup input/output).
Definition RTProcessor.cpp:191
virtual void sendPendingMessages()
Called (from a GUI timer) to send the messages to the GUI (JmbParam for the moment).
Definition RTProcessor.h:112
std::unique_ptr< AutoReleaseTimer > fGUITimer
Definition RTProcessor.h:150
bool fActive
Definition RTProcessor.h:156
tresult PLUGIN_API getState(IBStream *state) override
Called to save the state (before saving a preset or project).
Definition RTProcessor.cpp:179
std::unique_ptr< AutoReleaseTimer > fGUIMessageTimer
Definition RTProcessor.h:154
virtual RTState * getRTState()=0
Subclasses must implement this method to return the state.
virtual void onGUITimer()
Subclass will implement this method to respond to the GUI timer firing /////// WARNING !
Definition RTProcessor.h:102
tresult PLUGIN_API notify(IMessage *message) SMTG_OVERRIDE
Called to handle a message (coming from GUI).
Definition RTProcessor.cpp:74
uint32 fGUITimerIntervalMs
Definition RTProcessor.h:149
tresult PLUGIN_API setActive(TBool state) override
Switch the Plug-in on/off.
Definition RTProcessor.cpp:42
tresult PLUGIN_API canProcessSampleSize(int32 symbolicSampleSize) override
Asks if a given sample size is supported see SymbolicSampleSizes.
Definition RTProcessor.cpp:144
RTProcessor(Steinberg::FUID const &iControllerUID)
Definition RTProcessor.cpp:28
virtual tresult processInputs32Bits(ProcessData &data)
Processes inputs (step 2 always called after processing the parameters) for 32 bits.
Definition RTProcessor.h:89
virtual bool canProcess32Bits() const
Definition RTProcessor.h:74
virtual bool canProcess64Bits() const
Definition RTProcessor.h:78
virtual tresult processInputs(ProcessData &data)
Processes inputs (step 2 always called after processing the parameters) Delegate to processInputs32Bi...
Definition RTProcessor.cpp:112
void(RTProcessor::*)() RTProcessorCallback
Definition RTProcessor.h:126
~RTProcessor() override=default
IPtr< IMessage > allocateMessage() override
Allocates a message instance.
Definition RTProcessor.cpp:204
GUITimerCallback fGUITimerCallback
Definition RTProcessor.h:148
void enableGUITimer(uint32 iUIFrameRateMs)
Call this method to enable the GUI timer (onGUITimer will be called at the specified frequency) Shoul...
Definition RTProcessor.cpp:159
virtual tresult processInputs64Bits(ProcessData &data)
Processes inputs (step 2 always called after processing the parameters) for 64 bits.
Definition RTProcessor.h:94
uint32 fGUIMessageTimerIntervalMs
Definition RTProcessor.h:116
tresult sendMessage(IPtr< IMessage > iMessage) override
Sends the given message to the peer.
Definition RTProcessor.cpp:212
Manages the state used by the processor: you add all the parameters that the state manages using the ...
Definition RTState.h:46
virtual tresult sendPendingMessages(IMessageProducer *iMessageProducer)
Called (from a GUI timer) to send the messages to the GUI (JmbParam for the moment).
Definition RTState.cpp:334
Definition RTJmbInParameter.h:26
Definition Clock.h:24
Definition Clock.h:23