another unusued parameter fix
[ardour.git] / libs / ardour / session_vst.cc
index 3a158a3e73a2dd1a7ed6376386ac4ae7483bedf2..644fb19ffbd1c38a11081437d9360f237991f676 100644 (file)
 #include <stdbool.h>
 #include <cstdio>
 
-#include <fst.h>
-#include <fst/vestige/aeffectx.h>
-
 #include "ardour/session.h"
 #include "ardour/tempo.h"
-#include "ardour/vst_plugin.h"
+#include "ardour/windows_vst_plugin.h"
+#include "ardour/vestige/aeffectx.h"
+#include "ardour/vst_types.h"
 
 #include "i18n.h"
 
@@ -40,12 +39,14 @@ static int debug_callbacks = -1;
 
 using namespace ARDOUR;
 
-long Session::vst_callback (AEffect* effect,
-                           long opcode,
-                           long index,
-                           long value,
-                           void* ptr,
-                           float opt)
+intptr_t Session::vst_callback (
+       AEffect* effect,
+       int32_t opcode,
+       int32_t index,
+       intptr_t value,
+       void* ptr,
+       float opt
+       )
 {
        static VstTimeInfo _timeInfo;
        VSTPlugin* plug;
@@ -54,15 +55,15 @@ long Session::vst_callback (AEffect* effect,
        if (debug_callbacks < 0) {
                debug_callbacks = (getenv ("ARDOUR_DEBUG_VST_CALLBACKS") != 0);
        }
-       
+
        if (effect && effect->user) {
-               plug = (VSTPlugin*) (effect->user);
+               plug = (VSTPlugin *) (effect->user);
                session = &plug->session();
-               SHOW_CALLBACK ("am callback 0x%x, opcode = %ld, plugin = \"%s\" ", pthread_self(), opcode, plug->name());
+               SHOW_CALLBACK ("am callback 0x%x, opcode = %d, plugin = \"%s\" ", (int) pthread_self(), opcode, plug->name());
        } else {
                plug = 0;
                session = 0;
-               SHOW_CALLBACK ("am callback 0x%x, opcode = %ld", pthread_self(), opcode);
+               SHOW_CALLBACK ("am callback 0x%x, opcode = %d", (int) pthread_self(), opcode);
        }
 
        switch(opcode){
@@ -70,8 +71,8 @@ long Session::vst_callback (AEffect* effect,
        case audioMasterAutomate:
                SHOW_CALLBACK ("amc: audioMasterAutomate\n");
                // index, value, returns 0
-               if (effect) {
-                       effect->setParameter (effect, index, opt);
+               if (plug) {
+                       plug->set_parameter (index, opt);
                }
                return 0;
 
@@ -80,22 +81,22 @@ long Session::vst_callback (AEffect* effect,
                // vst version, currently 2 (0 for older)
                return 2;
 
-       case audioMasterCurrentId:      
+       case audioMasterCurrentId:
                SHOW_CALLBACK ("amc: audioMasterCurrentId\n");
                // returns the unique id of a plug that's currently
                // loading
                return 0;
-               
+
        case audioMasterIdle:
                SHOW_CALLBACK ("amc: audioMasterIdle\n");
                // call application idle routine (this will
-               // call effEditIdle for all open editors too) 
+               // call effEditIdle for all open editors too)
                if (effect) {
                        effect->dispatcher(effect, effEditIdle, 0, 0, NULL, 0.0f);
                }
                return 0;
 
-       case audioMasterPinConnected:           
+       case audioMasterPinConnected:
                SHOW_CALLBACK ("amc: audioMasterPinConnected\n");
                // inquire if an input or output is beeing connected;
                // index enumerates input or output counting from zero:
@@ -107,6 +108,9 @@ long Session::vst_callback (AEffect* effect,
        case audioMasterWantMidi:
                SHOW_CALLBACK ("amc: audioMasterWantMidi\n");
                // <value> is a filter which is currently ignored
+               if (plug) {
+                       plug->get_info()->n_inputs.set_midi (1);
+               }
                return 0;
 
        case audioMasterGetTime:
@@ -120,7 +124,7 @@ long Session::vst_callback (AEffect* effect,
                        _timeInfo.samplePos = session->transport_frame();
                        _timeInfo.sampleRate = session->frame_rate();
                        _timeInfo.flags = 0;
-                       
+
                        if (value & (kVstTempoValid)) {
                                const Tempo& t (session->tempo_map().tempo_at (session->transport_frame()));
                                _timeInfo.tempo = t.beats_per_minute ();
@@ -128,14 +132,14 @@ long Session::vst_callback (AEffect* effect,
                        }
                        if (value & (kVstBarsValid)) {
                                const Meter& m (session->tempo_map().meter_at (session->transport_frame()));
-                               _timeInfo.timeSigNumerator = m.beats_per_bar ();
+                               _timeInfo.timeSigNumerator = m.divisions_per_bar ();
                                _timeInfo.timeSigDenominator = m.note_divisor ();
                                _timeInfo.flags |= (kVstBarsValid);
                        }
-                       
+
                        if (session->transport_speed() != 0.0f) {
                                _timeInfo.flags |= kVstTransportPlaying;
-                       } 
+                       }
                }
 
                return (long)&_timeInfo;
@@ -164,7 +168,7 @@ long Session::vst_callback (AEffect* effect,
                SHOW_CALLBACK ("amc: audioMasterGetNumAutomatableParameters\n");
                return 0;
 
-       case audioMasterGetParameterQuantization:       
+       case audioMasterGetParameterQuantization:
                SHOW_CALLBACK ("amc: audioMasterGetParameterQuantization\n");
                // returns the integer value for +1.0 representation,
               // or 1 if full single float precision is maintained
@@ -180,7 +184,7 @@ long Session::vst_callback (AEffect* effect,
                SHOW_CALLBACK ("amc: audioMasterNeedIdle\n");
                // plug needs idle calls (outside its editor window)
                if (plug) {
-                       plug->fst()->wantIdle = 1;
+                       plug->state()->wantIdle = 1;
                }
                return 0;
 
@@ -234,7 +238,7 @@ long Session::vst_callback (AEffect* effect,
                // 4: currently offline processing and thus in user thread
                // other: not defined, but probably pre-empting user thread.
                return 0;
-               
+
        case audioMasterGetAutomationState:
                SHOW_CALLBACK ("amc: audioMasterGetAutomationState\n");
                // returns 0: not supported, 1: off, 2:read, 3:write, 4:read/write
@@ -243,6 +247,8 @@ long Session::vst_callback (AEffect* effect,
 
        case audioMasterOfflineStart:
                SHOW_CALLBACK ("amc: audioMasterOfflineStart\n");
+               return 0;
+               
        case audioMasterOfflineRead:
                SHOW_CALLBACK ("amc: audioMasterOfflineRead\n");
               // ptr points to offline structure, see below. return 0: error, 1 ok
@@ -255,6 +261,8 @@ long Session::vst_callback (AEffect* effect,
 
        case audioMasterOfflineGetCurrentPass:
                SHOW_CALLBACK ("amc: audioMasterOfflineGetCurrentPass\n");
+               return 0;
+               
        case audioMasterOfflineGetCurrentMetaPass:
                SHOW_CALLBACK ("amc: audioMasterOfflineGetCurrentMetaPass\n");
                return 0;
@@ -278,49 +286,49 @@ long Session::vst_callback (AEffect* effect,
        case audioMasterGetProductString:
                SHOW_CALLBACK ("amc: audioMasterGetProductString\n");
                // fills <ptr> with a string with product name (max 64 char)
-               strcpy ((char*) ptr, "Ardour");
+               strcpy ((char*) ptr, PROGRAM_NAME);
                return 0;
 
        case audioMasterGetVendorVersion:
                SHOW_CALLBACK ("amc: audioMasterGetVendorVersion\n");
                // returns vendor-specific version
                return 900;
-               
+
        case audioMasterVendorSpecific:
                SHOW_CALLBACK ("amc: audioMasterVendorSpecific\n");
                // no definition, vendor specific handling
                return 0;
-               
+
        case audioMasterSetIcon:
                SHOW_CALLBACK ("amc: audioMasterSetIcon\n");
                // void* in <ptr>, format not defined yet
                return 0;
-               
+
        case audioMasterCanDo:
                SHOW_CALLBACK ("amc: audioMasterCanDo\n");
                // string in ptr, see below
                return 0;
-               
+
        case audioMasterGetLanguage:
                SHOW_CALLBACK ("amc: audioMasterGetLanguage\n");
                // see enum
                return 0;
-               
+
        case audioMasterOpenWindow:
                SHOW_CALLBACK ("amc: audioMasterOpenWindow\n");
                // returns platform specific ptr
                return 0;
-               
+
        case audioMasterCloseWindow:
                SHOW_CALLBACK ("amc: audioMasterCloseWindow\n");
                // close window, platform specific handle in <ptr>
                return 0;
-               
+
        case audioMasterGetDirectory:
                SHOW_CALLBACK ("amc: audioMasterGetDirectory\n");
                // get plug directory, FSSpec on MAC, else char*
                return 0;
-               
+
        case audioMasterUpdateDisplay:
                SHOW_CALLBACK ("amc: audioMasterUpdateDisplay\n");
                // something has changed, update 'multi-fx' display
@@ -328,27 +336,27 @@ long Session::vst_callback (AEffect* effect,
                        effect->dispatcher(effect, effEditIdle, 0, 0, NULL, 0.0f);
                }
                return 0;
-               
+
        case audioMasterBeginEdit:
                SHOW_CALLBACK ("amc: audioMasterBeginEdit\n");
                // begin of automation session (when mouse down), parameter index in <index>
                return 0;
-               
+
        case audioMasterEndEdit:
                SHOW_CALLBACK ("amc: audioMasterEndEdit\n");
                // end of automation session (when mouse up),     parameter index in <index>
                return 0;
-               
+
        case audioMasterOpenFileSelector:
                SHOW_CALLBACK ("amc: audioMasterOpenFileSelector\n");
                // open a fileselector window with VstFileSelect* in <ptr>
                return 0;
-               
+
        default:
                SHOW_CALLBACK ("VST master dispatcher: undefed: %d\n", opcode);
                break;
-       }       
-       
+       }
+
        return 0;
 }