Beispiel #1
0
        void GetInputs()
        {
            IBMDSwitcherInputIterator inputIterator = null;
            IntPtr inputIteratorPtr;
            Guid   inputIteratorIID = typeof(IBMDSwitcherInputIterator).GUID;

            m_switcher.CreateIterator(ref inputIteratorIID, out inputIteratorPtr);
            if (inputIteratorPtr != null)
            {
                inputIterator = (IBMDSwitcherInputIterator)Marshal.GetObjectForIUnknown(inputIteratorPtr);
            }

            if (inputIterator != null)
            {
                IBMDSwitcherInput input;
                inputIterator.Next(out input);
                while (input != null)
                {
                    InputMonitor newInputMonitor = new InputMonitor(input);
                    input.AddCallback(newInputMonitor);
                    newInputMonitor.LongNameChanged += new SwitcherEventHandler(OnInputLongNameChanged);

                    m_inputMonitors.Add(newInputMonitor);

                    inputIterator.Next(out input);
                }
            }
        }
Beispiel #2
0
        public static void IterateInput(this IBMDSwitcher switcher, Action <IBMDSwitcherInput> action)
        {
            // We create input monitors for each input. To do this we iterate over all inputs:
            // This will allow us to update the combo boxes when input names change:

            IntPtr inputIteratorPtr;
            Guid   inputIteratorIID = typeof(IBMDSwitcherInputIterator).GUID;

            switcher.CreateIterator(ref inputIteratorIID, out inputIteratorPtr);

            IBMDSwitcherInputIterator inputIterator = null;

            if (inputIteratorPtr != null)
            {
                inputIterator = (IBMDSwitcherInputIterator)Marshal.GetObjectForIUnknown(inputIteratorPtr);
            }

            if (inputIterator != null)
            {
                IBMDSwitcherInput input;
                inputIterator.Next(out input);
                while (input != null)
                {
                    action(input);

                    inputIterator.Next(out input);
                }
            }
        }
Beispiel #3
0
        public static void IterateMixEffectBlock(this IBMDSwitcher switcher, Func <IBMDSwitcherMixEffectBlock, bool> func)
        {
            // We want to get the first Mix Effect block (ME 1). We create a ME iterator,
            // and then get the first one:
            IBMDSwitcherMixEffectBlock mixEffectBlock1 = null;

            IBMDSwitcherMixEffectBlockIterator meIterator = null;
            IntPtr meIteratorPtr;
            Guid   meIteratorIID = typeof(IBMDSwitcherMixEffectBlockIterator).GUID;

            switcher.CreateIterator(ref meIteratorIID, out meIteratorPtr);
            if (meIteratorPtr != null)
            {
                meIterator = (IBMDSwitcherMixEffectBlockIterator)Marshal.GetObjectForIUnknown(meIteratorPtr);
            }

            if (meIterator != null)
            {
                meIterator.Next(out mixEffectBlock1);

                while (mixEffectBlock1 != null && func(mixEffectBlock1))
                {
                    meIterator.Next(out mixEffectBlock1);
                }
            }
        }
Beispiel #4
0
    private void GetSwitcherMixEffectBlock()
    {
        // We want to get the first Mix Effect block (ME 1). We create a ME iterator,
        // and then get the first one:
        m_mixEffectBlock = null;

        IBMDSwitcherMixEffectBlockIterator meIterator = null;
        IntPtr meIteratorPtr;
        Guid   meIteratorIID = typeof(IBMDSwitcherMixEffectBlockIterator).GUID;

        m_switcher.CreateIterator(ref meIteratorIID, out meIteratorPtr);
        if (meIteratorPtr != null)
        {
            meIterator = (IBMDSwitcherMixEffectBlockIterator)Marshal.GetObjectForIUnknown(meIteratorPtr);
        }
        Marshal.Release(meIteratorPtr); // Release必須?

        if (meIterator != null)
        {
            meIterator.Next(out m_mixEffectBlock);
        }
    }
Beispiel #5
0
        public static IBMDSwitcherInputIterator GetInputIterator(this IBMDSwitcher switcher)
        {
            IBMDSwitcherInputIterator inputIterator = null;
            IntPtr inputIteratorPtr;
            Guid   inputIteratorIID = typeof(IBMDSwitcherInputIterator).GUID;

            switcher.CreateIterator(ref inputIteratorIID, out inputIteratorPtr);
            if (inputIteratorPtr != IntPtr.Zero)
            {
                inputIterator = (IBMDSwitcherInputIterator)Marshal.GetObjectForIUnknown(inputIteratorPtr);
            }
            return(inputIterator);
        }
Beispiel #6
0
        public static IBMDSwitcherMixEffectBlockIterator GetMixEffectBlockIterator(this IBMDSwitcher switcher)
        {
            IBMDSwitcherMixEffectBlockIterator meIterator = null;
            IntPtr meIteratorPtr;
            Guid   meIteratorIID = typeof(IBMDSwitcherMixEffectBlockIterator).GUID;

            switcher.CreateIterator(ref meIteratorIID, out meIteratorPtr);
            if (meIteratorPtr != IntPtr.Zero)
            {
                meIterator = (IBMDSwitcherMixEffectBlockIterator)Marshal.GetObjectForIUnknown(meIteratorPtr);
            }
            return(meIterator);
        }
Beispiel #7
0
        internal IEnumerable <IBMDSwitcherMixEffectBlock> GetMixEffectBlocks()
        {
            // Create a mix effect block iterator
            IntPtr meIteratorPtr;

            switcher.CreateIterator(typeof(IBMDSwitcherMixEffectBlockIterator).GUID, out meIteratorPtr);
            IBMDSwitcherMixEffectBlockIterator meIterator = Marshal.GetObjectForIUnknown(meIteratorPtr) as IBMDSwitcherMixEffectBlockIterator;

            if (meIterator == null)
            {
                yield break;
            }

            try
            {
                // Iterate through all mix effect blocks
                while (true)
                {
                    IBMDSwitcherMixEffectBlock me;
                    meIterator.Next(out me);

                    if (me != null)
                    {
                        yield return(me);
                    }
                    else
                    {
                        break;
                    }
                }
            }
            finally
            {
                Marshal.ReleaseComObject(meIterator);
            }
        }
        public MainWindow()
        {
            InitializeComponent();
            _BMDSwitcherConnectToFailure failReason = 0;

            switcherDiscovery = new CBMDSwitcherDiscovery();
            try
            {
                switcherDiscovery.ConnectTo("10.11.12.21", out switcher, out failReason);
            }
            catch (COMException)
            {
                // An exception will be thrown if ConnectTo fails. For more information, see failReason.
                switch (failReason)
                {
                case _BMDSwitcherConnectToFailure.bmdSwitcherConnectToFailureNoResponse:
                    MessageBox.Show("No response from Switcher", "Error");
                    break;

                case _BMDSwitcherConnectToFailure.bmdSwitcherConnectToFailureIncompatibleFirmware:
                    MessageBox.Show("Switcher has incompatible firmware", "Error");
                    break;

                default:
                    MessageBox.Show("Connection failed for unknown reason", "Error");
                    break;
                }
            }

            mixEffectBlock1 = null;

            IBMDSwitcherMixEffectBlockIterator meIterator = null;
            IntPtr meIteratorPtr;
            Guid   meIteratorIID = typeof(IBMDSwitcherMixEffectBlockIterator).GUID;

            switcher.CreateIterator(ref meIteratorIID, out meIteratorPtr);
            if (meIteratorPtr != null)
            {
                meIterator = (IBMDSwitcherMixEffectBlockIterator)Marshal.GetObjectForIUnknown(meIteratorPtr);
            }

            if (meIterator != null)
            {
                meIterator.Next(out mixEffectBlock1);
            }

            if (mixEffectBlock1 == null)
            {
                MessageBox.Show("Unexpected: Could not get first mix effect block", "Error");
            }

            IBMDSwitcherInput         currentInput  = null;
            IBMDSwitcherInputIterator inputIterator = null;
            IntPtr inputIteratorPtr;
            Guid   inputIteratorIID = typeof(IBMDSwitcherInputIterator).GUID;

            switcher.CreateIterator(ref inputIteratorIID, out inputIteratorPtr);
            if (inputIteratorPtr != null)
            {
                inputIterator = (IBMDSwitcherInputIterator)Marshal.GetObjectForIUnknown(inputIteratorPtr);
            }

            if (inputIterator != null)
            {
                inputIterator.Next(out currentInput);
                while (currentInput != null)
                {
                    MixerInput input = new MixerInput(currentInput);
                    inputList.Add(input);
                    inputIterator.Next(out currentInput);
                }
            }

            mixEffectBlock1.AddCallback(monitor);
            monitor.InTransitionChanged += new MixerMonitorEventHandler((s, a) => this.Dispatcher.Invoke((Action)(() => InTransitionChanged(s, a))));

            indev = new Sanford.Multimedia.Midi.InputDevice(3);
            indev.ChannelMessageReceived += Indev_ChannelMessageReceived;
            indev.StartRecording();

            mappingList.ItemsSource = inputList;
        }
Beispiel #9
0
        private void SwitcherConnected()
        {
            //buttonConnect.Enabled = false;

            // Get the switcher name:
            string switcherName;

            m_switcher.GetProductName(out switcherName);
            //textBoxSwitcherName.Text = switcherName;

            // Install SwitcherMonitor callbacks:
            m_switcher.AddCallback(m_switcherMonitor);

            // We create input monitors for each input. To do this we iterate over all inputs:
            // This will allow us to update the combo boxes when input names change:
            IBMDSwitcherInputIterator inputIterator = null;
            IntPtr inputIteratorPtr;
            Guid   inputIteratorIID = typeof(IBMDSwitcherInputIterator).GUID;

            m_switcher.CreateIterator(ref inputIteratorIID, out inputIteratorPtr);
            if (inputIteratorPtr != null)
            {
                inputIterator = (IBMDSwitcherInputIterator)Marshal.GetObjectForIUnknown(inputIteratorPtr);
            }

            if (inputIterator != null)
            {
                IBMDSwitcherInput input;
                inputIterator.Next(out input);
                while (input != null)
                {
                    InputMonitor newInputMonitor = new InputMonitor(input);
                    input.AddCallback(newInputMonitor);
                    newInputMonitor.LongNameChanged += new SwitcherEventHandler(OnInputLongNameChanged);

                    m_inputMonitors.Add(newInputMonitor);

                    inputIterator.Next(out input);
                }
            }

            // We want to get the first Mix Effect block (ME 1). We create a ME iterator,
            // and then get the first one:
            m_mixEffectBlock1 = null;

            IBMDSwitcherMixEffectBlockIterator meIterator = null;
            IntPtr meIteratorPtr;
            Guid   meIteratorIID = typeof(IBMDSwitcherMixEffectBlockIterator).GUID;

            m_switcher.CreateIterator(ref meIteratorIID, out meIteratorPtr);
            if (meIteratorPtr != null)
            {
                meIterator = (IBMDSwitcherMixEffectBlockIterator)Marshal.GetObjectForIUnknown(meIteratorPtr);
            }

            if (meIterator == null)
            {
                return;
            }

            if (meIterator != null)
            {
                meIterator.Next(out m_mixEffectBlock1);
            }

            if (m_mixEffectBlock1 == null)
            {
                MessageBox.Show("Unexpected: Could not get first mix effect block", "Error");
                return;
            }

            // Install MixEffectBlockMonitor callbacks:
            m_mixEffectBlock1.AddCallback(m_mixEffectBlockMonitor);
            //MixEffectBlockSetEnable(true);
            getInputNames();
            addAUXCallback();



            //setCurrent preview ID
            m_mixEffectBlock1.GetInt(_BMDSwitcherMixEffectBlockPropertyId.bmdSwitcherMixEffectBlockPropertyIdPreviewInput, out currentPreview);
            currentKey = -1;
            //setCurrent Program ID
            m_mixEffectBlock1.GetInt(_BMDSwitcherMixEffectBlockPropertyId.bmdSwitcherMixEffectBlockPropertyIdProgramInput, out currentProgram);
            updateProgPrevUI(currentPreview, false);
            updateProgPrevUI(currentProgram, true);
            UpdateAuxSourceCombos();

            MidiListener midi = new MidiListener();

            midi.StartListening(this);
        }