Ejemplo n.º 1
0
        internal DssiDescriptor(LadspaLibraryContext library, uint index, IntPtr dataPtr)
        {
            DssiDescriptorStruct data = (DssiDescriptorStruct)Marshal.PtrToStructure(dataPtr, typeof(DssiDescriptorStruct));

            Library          = library;
            DataHandle       = dataPtr;
            LadspaDescriptor = new LadspaDescriptor(library, index, data.LadspaDescriptor);
            if (data.Configure != IntPtr.Zero)
            {
                Configure = (DssiDescriptorConfigureCallback)Marshal.GetDelegateForFunctionPointer(data.Configure, typeof(DssiDescriptorConfigureCallback));
            }
            if (data.GetProgram != IntPtr.Zero)
            {
                GetProgram = (DssiDescriptorGetProgramCallback)Marshal.GetDelegateForFunctionPointer(data.GetProgram, typeof(DssiDescriptorGetProgramCallback));
            }
            if (data.SelectProgram != IntPtr.Zero)
            {
                SelectProgram = (DssiDescriptorSelectProgramCallback)Marshal.GetDelegateForFunctionPointer(data.SelectProgram, typeof(DssiDescriptorSelectProgramCallback));
            }
            if (data.GetMidiControllerForPort != IntPtr.Zero)
            {
                GetMidiControllerForPort = (DssiDescriptorGetMidiControllerForPortCallback)Marshal.GetDelegateForFunctionPointer(data.GetMidiControllerForPort, typeof(DssiDescriptorGetMidiControllerForPortCallback));
            }
            if (data.RunSynth != IntPtr.Zero)
            {
                RunSynth = (DssiDescriptorRunSynthCallback)Marshal.GetDelegateForFunctionPointer(data.RunSynth, typeof(DssiDescriptorRunSynthCallback));
            }
            if (data.RunSynthAdding != IntPtr.Zero)
            {
                RunSynthAdding = (DssiDescriptorRunSynthCallback)Marshal.GetDelegateForFunctionPointer(data.RunSynthAdding, typeof(DssiDescriptorRunSynthCallback));
            }
            if (data.RunMultiSynth != IntPtr.Zero)
            {
                RunMultiSynth = (DssiDescriptorRunMultiSynthCallback)Marshal.GetDelegateForFunctionPointer(data.RunMultiSynth, typeof(DssiDescriptorRunMultiSynthCallback));
            }
            if (data.RunMultiSynthAdding != IntPtr.Zero)
            {
                RunMultiSynthAdding = (DssiDescriptorRunMultiSynthCallback)Marshal.GetDelegateForFunctionPointer(data.RunMultiSynthAdding, typeof(DssiDescriptorRunMultiSynthCallback));
            }
            IsSynth = data.RunSynth != null;
        }
Ejemplo n.º 2
0
        internal LadspaDescriptor(LadspaLibraryContext library, uint index, IntPtr dataPtr)
        {
            LadspaDescriptorStruct data = (LadspaDescriptorStruct)Marshal.PtrToStructure(dataPtr, typeof(LadspaDescriptorStruct));

            Library    = library;
            DataHandle = dataPtr;
            Index      = index;
            UniqueID   = data.UniqueID;
            Properties = data.Properties;
            Label      = data.Label;
            Name       = data.Name;
            Maker      = data.Maker;
            Copyright  = data.Copyright;
            Ports      = new LadspaPort[data.PortCount];
            int hintsSize = Marshal.SizeOf(typeof(LadspaPortRangeHintsStruct));

            int[]    types = new int[data.PortCount];
            IntPtr[] names = new IntPtr[data.PortCount];
            if (data.PortDescriptors != IntPtr.Zero)
            {
                Marshal.Copy(data.PortDescriptors, types, 0, types.Length);
            }
            if (data.PortNames != IntPtr.Zero)
            {
                Marshal.Copy(data.PortNames, names, 0, names.Length);
            }
            for (int i = 0; i < data.PortCount; i++)
            {
                string name = names[i] != IntPtr.Zero ? Marshal.PtrToStringAnsi(names[i]) : null;
                LadspaPortRangeHintsStruct hints = data.PortRangeHints == IntPtr.Zero ? new LadspaPortRangeHintsStruct() :
                                                   (LadspaPortRangeHintsStruct)Marshal.PtrToStructure(IntPtr.Add(data.PortRangeHints, hintsSize * (int)i), typeof(LadspaPortRangeHintsStruct));
                Ports[i] = new LadspaPort(this, i, (LadspaPortDescriptorEnum)types[i], hints.Hints, name, hints.LowerBound, hints.UpperBound);
            }
            if (data.Instantiate != IntPtr.Zero)
            {
                Instantiate = (LadspaDescriptorInstantiateCallback)Marshal.GetDelegateForFunctionPointer(data.Instantiate, typeof(LadspaDescriptorInstantiateCallback));
            }
            if (data.ConnectPort != IntPtr.Zero)
            {
                ConnectPort = (LadspaDescriptorConnectPortCallback)Marshal.GetDelegateForFunctionPointer(data.ConnectPort, typeof(LadspaDescriptorConnectPortCallback));
            }
            if (data.Activate != IntPtr.Zero)
            {
                Activate = (LadspaDescriptorCallback)Marshal.GetDelegateForFunctionPointer(data.Activate, typeof(LadspaDescriptorCallback));
            }
            if (data.Run != IntPtr.Zero)
            {
                Run = (LadspaDescriptorRunCallback)Marshal.GetDelegateForFunctionPointer(data.Run, typeof(LadspaDescriptorRunCallback));
            }
            if (data.RunAdding != IntPtr.Zero)
            {
                RunAdding = (LadspaDescriptorRunCallback)Marshal.GetDelegateForFunctionPointer(data.RunAdding, typeof(LadspaDescriptorRunCallback));
            }
            if (data.SetRunAddingGain != IntPtr.Zero)
            {
                SetRunAddingGain = (LadspaDescriptorSetRunGainCallback)Marshal.GetDelegateForFunctionPointer(data.SetRunAddingGain, typeof(LadspaDescriptorSetRunGainCallback));
            }
            if (data.Deactivate != IntPtr.Zero)
            {
                Deactivate = (LadspaDescriptorCallback)Marshal.GetDelegateForFunctionPointer(data.Deactivate, typeof(LadspaDescriptorCallback));
            }
            if (data.Cleanup != IntPtr.Zero)
            {
                Cleanup = (LadspaDescriptorCallback)Marshal.GetDelegateForFunctionPointer(data.Cleanup, typeof(LadspaDescriptorCallback));
            }
        }