Пример #1
0
        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);

            switch (m.Msg)
            {
            case 0x1:     //WM_CREATE
                SetTimer(m.HWnd, 1, 20, IntPtr.Zero);
                effect.dispatcher(ref effect, (int)AEffectOpcodes.effEditOpen, 0, 0, m.HWnd, 0);
                ERect rect = new ERect
                {
                    left   = 0,
                    top    = 0,
                    right  = 0,
                    bottom = 0
                };
                IntPtr rectIntPtr  = IntPtr.Zero;
                IntPtr rectIntPtr2 = IntPtr.Zero;
                rectIntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(rect));
                Marshal.StructureToPtr(rect, rectIntPtr, true);
                rectIntPtr2 = Marshal.AllocHGlobal(Marshal.SizeOf(rectIntPtr));
                Marshal.StructureToPtr(rectIntPtr, rectIntPtr2, true);
                effect.dispatcher(ref effect, (int)AEffectOpcodes.effEditGetRect, 0, 0, rectIntPtr2, 0);
                IntPtr rectIntPtr3 = (IntPtr)Marshal.PtrToStructure(rectIntPtr2, typeof(IntPtr));
                rect = (ERect)Marshal.PtrToStructure(rectIntPtr3, typeof(ERect));
                Marshal.FreeHGlobal(rectIntPtr);
                Marshal.FreeHGlobal(rectIntPtr2);
                int width  = rect.right - rect.left;
                int height = rect.bottom - rect.top;
                if (width < 100)
                {
                    width = 100;
                }
                if (height < 100)
                {
                    height = 100;
                }
                this.ClientSize = new Size(width, height);
                break;

            case 0x113:     //WM_TIMER
                effect.dispatcher(ref effect, (int)AEffectOpcodes.effEditIdle, 0, 0, IntPtr.Zero, 0);
                break;

            case 0x10:     //WM_CLOSE
                KillTimer(m.HWnd, 1);
                effect.dispatcher(ref effect, (int)AEffectOpcodes.effEditClose, 0, 0, IntPtr.Zero, 0);
                vst.IsOpenEditor = false;
                break;
            }
        }
Пример #2
0
        public bool InitVST()
        {
            hostCallBack = new audioMasterCallbackDelegate(hostcallback);
            IntPtr eff = mainEntry(hostCallBack);

            effect = (AEffect)Marshal.PtrToStructure(eff, typeof(AEffect));

            effect.dispatcher(ref effect, (int)AEffectOpcodes.effOpen, 0, 0, IntPtr.Zero, 0);
            effect.dispatcher(ref effect, (int)AEffectOpcodes.effSetSampleRate, 0, 0, IntPtr.Zero, 44100.0F); //kSampleRate);
            effect.dispatcher(ref effect, (int)AEffectOpcodes.effSetBlockSize, 0, 512, IntPtr.Zero, 0);       //kBlockSize

            //checkEffectProperties(effect);
            IntPtr prop = Marshal.AllocHGlobal(256);

            effect.dispatcher(ref effect, (int)AEffectXOpcodes.effGetEffectName, 0, 0, prop, 0);
            _effectName = Marshal.PtrToStringAnsi(prop);
            effect.dispatcher(ref effect, (int)AEffectXOpcodes.effGetVendorString, 0, 0, prop, 0);
            _vendor = Marshal.PtrToStringAnsi(prop);
            effect.dispatcher(ref effect, (int)AEffectXOpcodes.effGetProductString, 0, 0, prop, 0);
            _product = Marshal.PtrToStringAnsi(prop);
            Marshal.FreeHGlobal(prop);

            // alloc buffer memory
            if (effect.numInputs != 2)
            {
                return(false);
            }
            if (effect.numOutputs != 2)
            {
                return(false);
            }

            bufInputs = new float[2 * 512];
            inputsPtr = Marshal.AllocCoTaskMem(sizeof(float) * 3 * 512);
            //            bufInputs = new float[2][] { new float[512], new float[512] };
            //            inputsPtr = Marshal.AllocCoTaskMem(sizeof(float) * 2 * 512 + sizeof(int) * 30);
            //            inputsPtrs[0] = Marshal.AllocCoTaskMem(sizeof(int));
            //            inputsPtrs[1] = Marshal.AllocCoTaskMem(sizeof(int));
            bufOutputs = new float[2 * 512];
            outputsPtr = Marshal.AllocCoTaskMem(sizeof(float) * 3 * 512);
            //            bufOutputs = new float[2][] { new float[512], new float[512] };
            //            outputsPtr = Marshal.AllocCoTaskMem(sizeof(float) * 2 * 512 + sizeof(int) * 30);
            //            outputsPtrs[0] = Marshal.AllocCoTaskMem(sizeof(int));
            //            outputsPtrs[1] = Marshal.AllocCoTaskMem(sizeof(int));

            return(true);
        }
Пример #3
0
 public void effectResume()
 {
     Console.WriteLine("HOST> Resume effect...\n");
     effect.dispatcher(ref effect, (int)AEffectOpcodes.effMainsChanged, 0, 1, IntPtr.Zero, 0);
 }