VstSdk.AEffectWrapper.Dispatch C# (CSharp) Method

Dispatch() public method

Host to Plug-in dispatcher @see AudioEffect::dispatcher
public Dispatch ( VstInt32 opcode, VstInt32 index, VstIntPtr value, IntPtr ptr, float opt ) : VstIntPtr
opcode VstInt32
index VstInt32
value VstIntPtr
ptr System.IntPtr
opt float
return VstIntPtr
        public VstIntPtr Dispatch( VstInt32 opcode, VstInt32 index, VstIntPtr value, IntPtr ptr, float opt ) {
            if ( dispatcherProc == null && aeffect.dispatcher != IntPtr.Zero ) {
                dispatcherProc = (AEffectDispatcherProc)Marshal.GetDelegateForFunctionPointer( aeffect.dispatcher, typeof( AEffectDispatcherProc ) );
            }
            VstIntPtr ret = 0;
            try {
                if ( dispatcherProc != null ) {
                    ret = dispatcherProc( ref aeffect, opcode, index, value, ptr, opt );
                }
            } catch ( Exception ex ) {
                Console.Error.WriteLine( "AEffectWrapper#Dispatch; ex=" + ex );
            }
            return ret;
        }

Usage Example

Example #1
0
        public virtual bool open( int block_size, int sample_rate )
        {
            dllHandle = win32.LoadLibraryExW( path, IntPtr.Zero, win32.LOAD_WITH_ALTERED_SEARCH_PATH );
            if ( dllHandle == IntPtr.Zero ) {
                serr.println( "vstidrv#open; dllHandle is null" );
                return false;
            }

            mainProcPointer = win32.GetProcAddress( dllHandle, "main" );
            mainDelegate = (PVSTMAIN)Marshal.GetDelegateForFunctionPointer( mainProcPointer,
                                                                            typeof( PVSTMAIN ) );
            if ( mainDelegate == null ) {
                serr.println( "vstidrv#open; mainDelegate is null" );
                return false;
            }

            audioMaster = new audioMasterCallback( AudioMaster );
            if ( audioMaster == null ) {
                serr.println( "vstidrv#open; audioMaster is null" );
                return false;
            }

            aEffectPointer = IntPtr.Zero;
            try {
                aEffectPointer = mainDelegate( audioMaster );
            } catch ( Exception ex ) {
                serr.println( "vstidrv#open; ex=" + ex );
                return false;
            }
            if ( aEffectPointer == IntPtr.Zero ) {
                serr.println( "vstidrv#open; aEffectPointer is null" );
                return false;
            }
            blockSize = block_size;
            sampleRate = sample_rate;
            aEffect = new AEffectWrapper();
            aEffect.aeffect = (AEffect)Marshal.PtrToStructure( aEffectPointer, typeof( AEffect ) );
            aEffect.Dispatch( AEffectOpcodes.effOpen, 0, 0, IntPtr.Zero, 0 );
            int ret = aEffect.Dispatch( AEffectOpcodes.effSetSampleRate, 0, 0, IntPtr.Zero, (float)sampleRate );
#if DEBUG
            sout.println( "vstidrv#open; dll_path=" + path + "; ret for effSetSampleRate=" + ret );
#endif

            aEffect.Dispatch( AEffectOpcodes.effSetBlockSize, 0, blockSize, IntPtr.Zero, 0 );

            // デフォルトのパラメータ値を取得
            int num = aEffect.aeffect.numParams;
            paramDefaults = new float[num];
            for ( int i = 0; i < num; i++ ) {
                paramDefaults[i] = aEffect.GetParameter( i );
            }

            return true;
        }