4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include <vst/aeffectx.h>
26 #include "ardour/session.h"
27 #include "ardour/vst_plugin.h"
31 // #define DEBUG_CALLBACKS
33 #ifdef DEBUG_CALLBACKS
34 #define SHOW_CALLBACK printf
36 #define SHOW_CALLBACK(...)
39 using namespace ARDOUR;
41 long Session::vst_callback (AEffect* effect,
48 static VstTimeInfo _timeInfo;
52 SHOW_CALLBACK ("am callback, opcode = %d", opcode);
54 if (effect && effect->user) {
55 plug = (VSTPlugin*) (effect->user);
56 session = &plug->session();
64 case audioMasterAutomate:
65 SHOW_CALLBACK ("amc: audioMasterAutomate\n");
66 // index, value, returns 0
68 effect->setParameter (effect, index, opt);
72 case audioMasterVersion:
73 SHOW_CALLBACK ("amc: audioMasterVersion\n");
74 // vst version, currently 2 (0 for older)
77 case audioMasterCurrentId:
78 SHOW_CALLBACK ("amc: audioMasterCurrentId\n");
79 // returns the unique id of a plug that's currently
84 SHOW_CALLBACK ("amc: audioMasterIdle\n");
85 // call application idle routine (this will
86 // call effEditIdle for all open editors too)
88 effect->dispatcher(effect, effEditIdle, 0, 0, NULL, 0.0f);
92 case audioMasterPinConnected:
93 SHOW_CALLBACK ("amc: audioMasterPinConnected\n");
94 // inquire if an input or output is beeing connected;
95 // index enumerates input or output counting from zero:
96 // value is 0 for input and != 0 otherwise. note: the
97 // return value is 0 for <true> such that older versions
98 // will always return true.
101 case audioMasterWantMidi:
102 SHOW_CALLBACK ("amc: audioMasterWantMidi\n");
103 // <value> is a filter which is currently ignored
106 case audioMasterGetTime:
107 SHOW_CALLBACK ("amc: audioMasterGetTime\n");
108 // returns const VstTimeInfo* (or 0 if not supported)
109 // <value> should contain a mask indicating which fields are required
110 // (see valid masks above), as some items may require extensive
112 memset(&_timeInfo, 0, sizeof(_timeInfo));
114 _timeInfo.samplePos = session->transport_frame();
115 _timeInfo.sampleRate = session->frame_rate();
117 return (long)&_timeInfo;
119 case audioMasterProcessEvents:
120 SHOW_CALLBACK ("amc: audioMasterProcessEvents\n");
121 // VstEvents* in <ptr>
124 case audioMasterSetTime:
125 SHOW_CALLBACK ("amc: audioMasterSetTime\n");
126 // VstTimenfo* in <ptr>, filter in <value>, not supported
128 case audioMasterTempoAt:
129 SHOW_CALLBACK ("amc: audioMasterTempoAt\n");
130 // returns tempo (in bpm * 10000) at sample frame location passed in <value>
133 case audioMasterGetNumAutomatableParameters:
134 SHOW_CALLBACK ("amc: audioMasterGetNumAutomatableParameters\n");
137 case audioMasterGetParameterQuantization:
138 SHOW_CALLBACK ("amc: audioMasterGetParameterQuantization\n");
139 // returns the integer value for +1.0 representation,
140 // or 1 if full single float precision is maintained
141 // in automation. parameter index in <value> (-1: all, any)
144 case audioMasterIOChanged:
145 SHOW_CALLBACK ("amc: audioMasterIOChanged\n");
146 // numInputs and/or numOutputs has changed
149 case audioMasterNeedIdle:
150 SHOW_CALLBACK ("amc: audioMasterNeedIdle\n");
151 // plug needs idle calls (outside its editor window)
154 case audioMasterSizeWindow:
155 SHOW_CALLBACK ("amc: audioMasterSizeWindow\n");
156 // index: width, value: height
159 case audioMasterGetSampleRate:
160 SHOW_CALLBACK ("amc: audioMasterGetSampleRate\n");
163 case audioMasterGetBlockSize:
164 SHOW_CALLBACK ("amc: audioMasterGetBlockSize\n");
167 case audioMasterGetInputLatency:
168 SHOW_CALLBACK ("amc: audioMasterGetInputLatency\n");
171 case audioMasterGetOutputLatency:
172 SHOW_CALLBACK ("amc: audioMasterGetOutputLatency\n");
175 case audioMasterGetPreviousPlug:
176 SHOW_CALLBACK ("amc: audioMasterGetPreviousPlug\n");
177 // input pin in <value> (-1: first to come), returns cEffect*
180 case audioMasterGetNextPlug:
181 SHOW_CALLBACK ("amc: audioMasterGetNextPlug\n");
182 // output pin in <value> (-1: first to come), returns cEffect*
184 case audioMasterWillReplaceOrAccumulate:
185 SHOW_CALLBACK ("amc: audioMasterWillReplaceOrAccumulate\n");
186 // returns: 0: not supported, 1: replace, 2: accumulate
189 case audioMasterGetCurrentProcessLevel:
190 SHOW_CALLBACK ("amc: audioMasterGetCurrentProcessLevel\n");
191 // returns: 0: not supported,
192 // 1: currently in user thread (gui)
193 // 2: currently in audio thread (where process is called)
194 // 3: currently in 'sequencer' thread (midi, timer etc)
195 // 4: currently offline processing and thus in user thread
196 // other: not defined, but probably pre-empting user thread.
199 case audioMasterGetAutomationState:
200 SHOW_CALLBACK ("amc: audioMasterGetAutomationState\n");
201 // returns 0: not supported, 1: off, 2:read, 3:write, 4:read/write
205 case audioMasterOfflineStart:
206 SHOW_CALLBACK ("amc: audioMasterOfflineStart\n");
207 case audioMasterOfflineRead:
208 SHOW_CALLBACK ("amc: audioMasterOfflineRead\n");
209 // ptr points to offline structure, see below. return 0: error, 1 ok
212 case audioMasterOfflineWrite:
213 SHOW_CALLBACK ("amc: audioMasterOfflineWrite\n");
217 case audioMasterOfflineGetCurrentPass:
218 SHOW_CALLBACK ("amc: audioMasterOfflineGetCurrentPass\n");
219 case audioMasterOfflineGetCurrentMetaPass:
220 SHOW_CALLBACK ("amc: audioMasterOfflineGetCurrentMetaPass\n");
223 case audioMasterSetOutputSampleRate:
224 SHOW_CALLBACK ("amc: audioMasterSetOutputSampleRate\n");
225 // for variable i/o, sample rate in <opt>
228 case audioMasterGetSpeakerArrangement:
229 SHOW_CALLBACK ("amc: audioMasterGetSpeakerArrangement\n");
230 // (long)input in <value>, output in <ptr>
233 case audioMasterGetVendorString:
234 SHOW_CALLBACK ("amc: audioMasterGetVendorString\n");
235 // fills <ptr> with a string identifying the vendor (max 64 char)
236 strcpy ((char*) ptr, "Linux Audio Systems");
239 case audioMasterGetProductString:
240 SHOW_CALLBACK ("amc: audioMasterGetProductString\n");
241 // fills <ptr> with a string with product name (max 64 char)
242 strcpy ((char*) ptr, "Ardour");
245 case audioMasterGetVendorVersion:
246 SHOW_CALLBACK ("amc: audioMasterGetVendorVersion\n");
247 // returns vendor-specific version
250 case audioMasterVendorSpecific:
251 SHOW_CALLBACK ("amc: audioMasterVendorSpecific\n");
252 // no definition, vendor specific handling
255 case audioMasterSetIcon:
256 SHOW_CALLBACK ("amc: audioMasterSetIcon\n");
257 // void* in <ptr>, format not defined yet
260 case audioMasterCanDo:
261 SHOW_CALLBACK ("amc: audioMasterCanDo\n");
262 // string in ptr, see below
265 case audioMasterGetLanguage:
266 SHOW_CALLBACK ("amc: audioMasterGetLanguage\n");
270 case audioMasterOpenWindow:
271 SHOW_CALLBACK ("amc: audioMasterOpenWindow\n");
272 // returns platform specific ptr
275 case audioMasterCloseWindow:
276 SHOW_CALLBACK ("amc: audioMasterCloseWindow\n");
277 // close window, platform specific handle in <ptr>
280 case audioMasterGetDirectory:
281 SHOW_CALLBACK ("amc: audioMasterGetDirectory\n");
282 // get plug directory, FSSpec on MAC, else char*
285 case audioMasterUpdateDisplay:
286 SHOW_CALLBACK ("amc: audioMasterUpdateDisplay\n");
287 // something has changed, update 'multi-fx' display
289 effect->dispatcher(effect, effEditIdle, 0, 0, NULL, 0.0f);
293 case audioMasterBeginEdit:
294 SHOW_CALLBACK ("amc: audioMasterBeginEdit\n");
295 // begin of automation session (when mouse down), parameter index in <index>
298 case audioMasterEndEdit:
299 SHOW_CALLBACK ("amc: audioMasterEndEdit\n");
300 // end of automation session (when mouse up), parameter index in <index>
303 case audioMasterOpenFileSelector:
304 SHOW_CALLBACK ("amc: audioMasterOpenFileSelector\n");
305 // open a fileselector window with VstFileSelect* in <ptr>
309 SHOW_CALLBACK ("VST master dispatcher: undefed: %d, %d\n", opcode, effKeysRequired);