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.
25 #include <vst/aeffectx.h>
27 #include <ardour/session.h>
28 #include <ardour/vst_plugin.h>
32 // #define DEBUG_CALLBACKS
34 #ifdef DEBUG_CALLBACKS
35 #define SHOW_CALLBACK printf
37 #define SHOW_CALLBACK(...)
40 using namespace ARDOUR;
42 long Session::vst_callback (AEffect* effect,
49 static VstTimeInfo _timeInfo;
53 SHOW_CALLBACK ("am callback, opcode = %d", opcode);
55 if (effect && effect->user) {
56 plug = static_cast<VSTPlugin*> (effect->user);
57 session = &plug->session();
65 case audioMasterAutomate:
66 SHOW_CALLBACK ("amc: audioMasterAutomate\n");
67 // index, value, returns 0
69 effect->setParameter (effect, index, opt);
73 case audioMasterVersion:
74 SHOW_CALLBACK ("amc: audioMasterVersion\n");
75 // vst version, currently 2 (0 for older)
78 case audioMasterCurrentId:
79 SHOW_CALLBACK ("amc: audioMasterCurrentId\n");
80 // returns the unique id of a plug that's currently
85 SHOW_CALLBACK ("amc: audioMasterIdle\n");
86 // call application idle routine (this will
87 // call effEditIdle for all open editors too)
89 effect->dispatcher(effect, effEditIdle, 0, 0, NULL, 0.0f);
93 case audioMasterPinConnected:
94 SHOW_CALLBACK ("amc: audioMasterPinConnected\n");
95 // inquire if an input or output is beeing connected;
96 // index enumerates input or output counting from zero:
97 // value is 0 for input and != 0 otherwise. note: the
98 // return value is 0 for <true> such that older versions
99 // will always return true.
102 case audioMasterWantMidi:
103 SHOW_CALLBACK ("amc: audioMasterWantMidi\n");
104 // <value> is a filter which is currently ignored
107 case audioMasterGetTime:
108 SHOW_CALLBACK ("amc: audioMasterGetTime\n");
109 // returns const VstTimeInfo* (or 0 if not supported)
110 // <value> should contain a mask indicating which fields are required
111 // (see valid masks above), as some items may require extensive
113 memset(&_timeInfo, 0, sizeof(_timeInfo));
115 _timeInfo.samplePos = session->transport_frame();
116 _timeInfo.sampleRate = session->frame_rate();
118 return (long)&_timeInfo;
120 case audioMasterProcessEvents:
121 SHOW_CALLBACK ("amc: audioMasterProcessEvents\n");
122 // VstEvents* in <ptr>
125 case audioMasterSetTime:
126 SHOW_CALLBACK ("amc: audioMasterSetTime\n");
127 // VstTimenfo* in <ptr>, filter in <value>, not supported
129 case audioMasterTempoAt:
130 SHOW_CALLBACK ("amc: audioMasterTempoAt\n");
131 // returns tempo (in bpm * 10000) at sample frame location passed in <value>
134 case audioMasterGetNumAutomatableParameters:
135 SHOW_CALLBACK ("amc: audioMasterGetNumAutomatableParameters\n");
138 case audioMasterGetParameterQuantization:
139 SHOW_CALLBACK ("amc: audioMasterGetParameterQuantization\n");
140 // returns the integer value for +1.0 representation,
141 // or 1 if full single float precision is maintained
142 // in automation. parameter index in <value> (-1: all, any)
145 case audioMasterIOChanged:
146 SHOW_CALLBACK ("amc: audioMasterIOChanged\n");
147 // numInputs and/or numOutputs has changed
150 case audioMasterNeedIdle:
151 SHOW_CALLBACK ("amc: audioMasterNeedIdle\n");
152 // plug needs idle calls (outside its editor window)
155 case audioMasterSizeWindow:
156 SHOW_CALLBACK ("amc: audioMasterSizeWindow\n");
157 // index: width, value: height
160 case audioMasterGetSampleRate:
161 SHOW_CALLBACK ("amc: audioMasterGetSampleRate\n");
164 case audioMasterGetBlockSize:
165 SHOW_CALLBACK ("amc: audioMasterGetBlockSize\n");
168 case audioMasterGetInputLatency:
169 SHOW_CALLBACK ("amc: audioMasterGetInputLatency\n");
172 case audioMasterGetOutputLatency:
173 SHOW_CALLBACK ("amc: audioMasterGetOutputLatency\n");
176 case audioMasterGetPreviousPlug:
177 SHOW_CALLBACK ("amc: audioMasterGetPreviousPlug\n");
178 // input pin in <value> (-1: first to come), returns cEffect*
181 case audioMasterGetNextPlug:
182 SHOW_CALLBACK ("amc: audioMasterGetNextPlug\n");
183 // output pin in <value> (-1: first to come), returns cEffect*
185 case audioMasterWillReplaceOrAccumulate:
186 SHOW_CALLBACK ("amc: audioMasterWillReplaceOrAccumulate\n");
187 // returns: 0: not supported, 1: replace, 2: accumulate
190 case audioMasterGetCurrentProcessLevel:
191 SHOW_CALLBACK ("amc: audioMasterGetCurrentProcessLevel\n");
192 // returns: 0: not supported,
193 // 1: currently in user thread (gui)
194 // 2: currently in audio thread (where process is called)
195 // 3: currently in 'sequencer' thread (midi, timer etc)
196 // 4: currently offline processing and thus in user thread
197 // other: not defined, but probably pre-empting user thread.
200 case audioMasterGetAutomationState:
201 SHOW_CALLBACK ("amc: audioMasterGetAutomationState\n");
202 // returns 0: not supported, 1: off, 2:read, 3:write, 4:read/write
206 case audioMasterOfflineStart:
207 SHOW_CALLBACK ("amc: audioMasterOfflineStart\n");
208 case audioMasterOfflineRead:
209 SHOW_CALLBACK ("amc: audioMasterOfflineRead\n");
210 // ptr points to offline structure, see below. return 0: error, 1 ok
213 case audioMasterOfflineWrite:
214 SHOW_CALLBACK ("amc: audioMasterOfflineWrite\n");
218 case audioMasterOfflineGetCurrentPass:
219 SHOW_CALLBACK ("amc: audioMasterOfflineGetCurrentPass\n");
220 case audioMasterOfflineGetCurrentMetaPass:
221 SHOW_CALLBACK ("amc: audioMasterOfflineGetCurrentMetaPass\n");
224 case audioMasterSetOutputSampleRate:
225 SHOW_CALLBACK ("amc: audioMasterSetOutputSampleRate\n");
226 // for variable i/o, sample rate in <opt>
229 case audioMasterGetSpeakerArrangement:
230 SHOW_CALLBACK ("amc: audioMasterGetSpeakerArrangement\n");
231 // (long)input in <value>, output in <ptr>
234 case audioMasterGetVendorString:
235 SHOW_CALLBACK ("amc: audioMasterGetVendorString\n");
236 // fills <ptr> with a string identifying the vendor (max 64 char)
237 strcpy ((char*) ptr, "Linux Audio Systems");
240 case audioMasterGetProductString:
241 SHOW_CALLBACK ("amc: audioMasterGetProductString\n");
242 // fills <ptr> with a string with product name (max 64 char)
243 strcpy ((char*) ptr, "Ardour");
246 case audioMasterGetVendorVersion:
247 SHOW_CALLBACK ("amc: audioMasterGetVendorVersion\n");
248 // returns vendor-specific version
251 case audioMasterVendorSpecific:
252 SHOW_CALLBACK ("amc: audioMasterVendorSpecific\n");
253 // no definition, vendor specific handling
256 case audioMasterSetIcon:
257 SHOW_CALLBACK ("amc: audioMasterSetIcon\n");
258 // void* in <ptr>, format not defined yet
261 case audioMasterCanDo:
262 SHOW_CALLBACK ("amc: audioMasterCanDo\n");
263 // string in ptr, see below
266 case audioMasterGetLanguage:
267 SHOW_CALLBACK ("amc: audioMasterGetLanguage\n");
271 case audioMasterOpenWindow:
272 SHOW_CALLBACK ("amc: audioMasterOpenWindow\n");
273 // returns platform specific ptr
276 case audioMasterCloseWindow:
277 SHOW_CALLBACK ("amc: audioMasterCloseWindow\n");
278 // close window, platform specific handle in <ptr>
281 case audioMasterGetDirectory:
282 SHOW_CALLBACK ("amc: audioMasterGetDirectory\n");
283 // get plug directory, FSSpec on MAC, else char*
286 case audioMasterUpdateDisplay:
287 SHOW_CALLBACK ("amc: audioMasterUpdateDisplay\n");
288 // something has changed, update 'multi-fx' display
290 effect->dispatcher(effect, effEditIdle, 0, 0, NULL, 0.0f);
294 case audioMasterBeginEdit:
295 SHOW_CALLBACK ("amc: audioMasterBeginEdit\n");
296 // begin of automation session (when mouse down), parameter index in <index>
299 case audioMasterEndEdit:
300 SHOW_CALLBACK ("amc: audioMasterEndEdit\n");
301 // end of automation session (when mouse up), parameter index in <index>
304 case audioMasterOpenFileSelector:
305 SHOW_CALLBACK ("amc: audioMasterOpenFileSelector\n");
306 // open a fileselector window with VstFileSelect* in <ptr>
310 SHOW_CALLBACK ("VST master dispatcher: undefed: %d, %d\n", opcode, effKeysRequired);