public void TestBalance()
        {
            var  handler = CreateAutoCommandHandler("Balance");
            bool tested  = false;

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.ClassicAudioMain, helper =>
            {
                IEnumerable <long> useIds = helper.Helper.BuildLibState().Audio.Inputs.Keys.ToList();
                foreach (long id in useIds)
                {
                    AtemState stateBefore = helper.Helper.BuildLibState();
                    var inputState        = stateBefore.Audio.Inputs[id].Properties;

                    IBMDSwitcherAudioInput input = GetInput(helper, id);
                    tested = true;

                    for (int i = 0; i < 5; i++)
                    {
                        var target         = Randomiser.Range(-50, 50);
                        inputState.Balance = target;
                        helper.SendAndWaitForChange(stateBefore, () => { input.SetBalance(target / 50); });
                    }
                }
            });
            Assert.True(tested);
        }
Exemple #2
0
        private static AudioState.InputState BuildInput(IBMDSwitcherAudioInput props)
        {
            var state = new AudioState.InputState();

            props.GetType(out _BMDSwitcherAudioInputType type);
            state.Properties.SourceType = AtemEnumMaps.AudioSourceTypeMap.FindByValue(type);

            props.GetCurrentExternalPortType(out _BMDSwitcherExternalPortType externalType);
            state.Properties.PortType = AtemEnumMaps.AudioPortTypeMap.FindByValue(externalType);
            props.GetMixOption(out _BMDSwitcherAudioMixOption mixOption);
            state.Properties.MixOption = AtemEnumMaps.AudioMixOptionMap.FindByValue(mixOption);
            props.GetGain(out double gain);
            state.Properties.Gain = gain;
            props.GetBalance(out double balance);
            state.Properties.Balance = balance * 50;

            if (props is IBMDSwitcherAudioInputXLR xlrProps)
            {
                xlrProps.HasRCAToXLR(out int supportsXlr);
                if (supportsXlr != 0)
                {
                    xlrProps.GetRCAToXLREnabled(out int xlrEnabled);
                    state.Analog = new AudioState.InputState.AnalogState
                    {
                        RcaToXlr = xlrEnabled != 0
                    };
                }
            }

            return(state);
        }
        public void TestResetPeakLevels()
        {
            bool tested   = false;
            var  expected = new AudioMixerResetPeaksCommand {
                Mask = AudioMixerResetPeaksCommand.MaskFlags.Input
            };
            var handler = CommandGenerator.MatchCommand(expected);

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.ClassicAudioMain, helper =>
            {
                IEnumerable <long> useIds = helper.Helper.BuildLibState().Audio.Inputs.Keys.ToList();
                foreach (long id in useIds)
                {
                    tested          = true;
                    uint timeBefore = helper.Server.CurrentTime;

                    expected.Input = (AudioSource)id;

                    IBMDSwitcherAudioInput input = GetInput(helper, id);
                    helper.SendAndWaitForChange(null, () => { input.ResetLevelNotificationPeaks(); });

                    // It should have sent a response, but we dont expect any comparable data
                    Assert.NotEqual(timeBefore, helper.Server.CurrentTime);
                }
            });
            Assert.True(tested);
        }
        public void TestMixOption()
        {
            var  handler = CreateAutoCommandHandler("MixOption");
            bool tested  = false;

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.ClassicAudioMain, helper =>
            {
                IEnumerable <long> useIds = helper.Helper.BuildLibState().Audio.Inputs.Where(i =>
                                                                                             i.Value.Properties.PortType == AudioPortType.SDI ||
                                                                                             i.Value.Properties.PortType == AudioPortType.HDMI).Select(i => i.Key).ToList();
                foreach (long id in useIds)
                {
                    AtemState stateBefore = helper.Helper.BuildLibState();
                    var inputState        = stateBefore.Audio.Inputs[id].Properties;

                    IBMDSwitcherAudioInput input = GetInput(helper, id);
                    tested = true;

                    for (int i = 0; i < 5; i++)
                    {
                        AudioMixOption target = Randomiser.EnumValue <AudioMixOption>();
                        if (id >= 2000 && target == AudioMixOption.On)
                        {
                            // Not supported
                            continue;
                        }

                        _BMDSwitcherAudioMixOption target2 = AtemEnumMaps.AudioMixOptionMap[target];
                        inputState.MixOption = target;
                        helper.SendAndWaitForChange(stateBefore, () => { input.SetMixOption(target2); });
                    }
                }
            });
            Assert.True(tested);
        }
Exemple #5
0
        private void SwitcherDisconnected()
        {
            try
            {
                this.Text = "";
                deactivatebuttons();
                btn_reconnect.Enabled = true;
                btnKey1Air.Enabled = false;
                if (m_audioInput != null)
                {
                    m_audioInput.RemoveCallback(m_audioInputMonitor);
                    m_audioInput = null;
                }

                if (m_audioMonitorOutput != null)
                {
                    m_audioMonitorOutput.RemoveCallback(m_audioOutputMonitor);
                    m_audioMonitorOutput = null;
                }

                if (m_audiomixer != null)
                {
                    m_audiomixer.RemoveCallback(m_audioMixerMonitor);
                    m_audiomixer = null;
                }

                if (me1_dkey1 != null)
                {
                    // Remove callback
                    me1_dkey1.RemoveCallback(m_dkeyMonitor);

                    // Release reference
                    me1_dkey1 = null;
                }

                if (me1_dkey2 != null)
                {
                    // Remove callback
                    me1_dkey2.RemoveCallback(m_dkeyMonitor);

                    // Release reference
                    me1_dkey2 = null;
                }

                if (m_AUX1 != null)
                {
                    // Remove callback
                    m_AUX1.RemoveCallback(m_auxMonitor);

                    // Release reference
                    m_AUX1 = null;
                }

                if (m_AUX2 != null)
                {
                    // Remove callback
                    m_AUX2.RemoveCallback(m_auxMonitor);

                    // Release reference
                    m_AUX2 = null;
                }

                if (m_AUX3 != null)
                {
                    // Remove callback
                    m_AUX3.RemoveCallback(m_auxMonitor);

                    // Release reference
                    m_AUX3 = null;
                }

                if (me1_key1 != null)
                {
                    // Remove callback
                    me1_key1.RemoveCallback(m_keyMonitor);

                    // Release reference
                    me1_key1 = null;
                }
                if (me1_key2 != null)
                {
                    // Remove callback
                    me1_key2.RemoveCallback(m_keyMonitor);

                    // Release reference
                    me1_key2 = null;
                }
                if (me1_key3 != null)
                {
                    // Remove callback
                    me1_key3.RemoveCallback(m_keyMonitor);

                    // Release reference
                    me1_key3 = null;
                }
                if (me1_key4 != null)
                {
                    // Remove callback
                    me1_key4.RemoveCallback(m_keyMonitor);

                    // Release reference
                    me1_key4 = null;
                }

                if (m_transition != null)
                {
                    // Remove callback
                    m_transition.RemoveCallback(m_transitionMonitor);

                    // Release reference
                    m_transition = null;
                }

                // Remove all input monitors, remove callbacks
                foreach (InputMonitor inputMon in m_inputMonitors)
                {
                    inputMon.Input.RemoveCallback(inputMon);
                }
                m_inputMonitors.Clear();

                if (m_mixEffectBlock1 != null)
                {
                    // Remove callback
                    m_mixEffectBlock1.RemoveCallback(m_mixEffectBlockMonitor);

                    // Release reference
                    m_mixEffectBlock1 = null;
                }

                if (m_switcher != null)
                {
                    // Remove callback:
                    m_switcher.RemoveCallback(m_switcherMonitor);

                    // release reference:
                    m_switcher = null;
                }
            }
            catch (ArgumentException)
            {
                SwitcherDisconnected();
            }
        }
Exemple #6
0
 internal SwitcherAudioInputCallback(IBMDSwitcherAudioInput audioInput, int index)
 {
     this._indexnr   = index;
     this.AudioInput = audioInput;
 }
        public void TestLevelsAndPeaks()
        {
            bool tested = false;

            AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.ClassicAudioMain, helper =>
            {
                using var items = new DisposableList();

                IReadOnlyList <long> useIds = helper.Helper.BuildLibState().Audio.Inputs.Keys.ToList();
                var callbacks = new Dictionary <AudioSource, LevelCallback>(useIds.Count);
                // Setup callbacks
                foreach (long id in useIds)
                {
                    IBMDSwitcherAudioInput input = GetInput(helper, id);
                    var cb = new LevelCallback();
                    cb.Reset();
                    items.Items.Add(new UseCallback <LevelCallback>(cb, input.AddCallback, input.RemoveCallback));
                    callbacks[(AudioSource)id] = cb;
                }

                // Now run the tests
                for (int i = 0; i < 5; i++)
                {
                    tested = true;

                    AtemState stateBefore = helper.Helper.BuildLibState();
                    stateBefore.Audio.ProgramOut.Levels = null;
                    var inputsState = stateBefore.Audio.Inputs;

                    var testCmd = new AudioMixerLevelsCommand();
                    foreach (long tmpId in useIds)
                    {
                        var levels = new AudioMixerLevelInput((AudioSource)tmpId)
                        {
                            LeftLevel  = Randomiser.Range(-100, 0),
                            RightLevel = Randomiser.Range(-100, 0),
                            LeftPeak   = Randomiser.Range(-100, 0),
                            RightPeak  = Randomiser.Range(-100, 0),
                        };
                        testCmd.Inputs.Add(levels);

                        inputsState[tmpId].Levels = new AudioState.LevelsState
                        {
                            Levels = new[] { levels.LeftLevel, levels.RightLevel },
                            Peaks  = new[] { levels.LeftPeak, levels.RightPeak },
                        };
                    }

                    helper.SendAndWaitForChange(stateBefore, () => { helper.Server.SendCommands(testCmd); }, -1,
                                                (sdkState, libState) =>
                    {
                        libState.Audio.ProgramOut.Levels = null;

                        foreach (KeyValuePair <AudioSource, LevelCallback> i in callbacks)
                        {
                            sdkState.Audio.Inputs[(long)i.Key].Levels = new AudioState.LevelsState
                            {
                                Levels = i.Value.Levels,
                                Peaks  = i.Value.Peaks,
                            };
                        }
                    });
                }
            });
            Assert.True(tested);
        }
Exemple #8
0
        private void SwitcherDisconnected()
        {
            buttonConnect.Enabled = true;
            textBoxSwitcherName.Text = "";

            if (m_audioInput != null)
            {
                m_audioInput.RemoveCallback(m_audioInputMonitor);
                m_audioInput = null;
            }

            if (m_audioMonitorOutput != null)
            {
                m_audioMonitorOutput.RemoveCallback(m_audioOutputMonitor);
                m_audioMonitorOutput = null;
            }

            if (m_audiomixer != null)
            {
                 m_audiomixer.RemoveCallback(m_audioMixerMonitor);
                 m_audiomixer = null;
            }

            if (me1_dkey1 != null)
            {
                // Remove callback
                me1_dkey1.RemoveCallback(m_dkeyMonitor);

                // Release reference
                me1_dkey1 = null;
            }

            if (me1_dkey2 != null)
            {
                // Remove callback
                me1_dkey2.RemoveCallback(m_dkeyMonitor);

                // Release reference
                me1_dkey2 = null;
            }

            if (m_AUX1 != null)
            {
                // Remove callback
                m_AUX1.RemoveCallback(m_auxMonitor);

                // Release reference
                m_AUX1 = null;
            }

            if (m_AUX2 != null)
            {
                // Remove callback
                m_AUX2.RemoveCallback(m_auxMonitor);

                // Release reference
                m_AUX2 = null;
            }

            if (m_AUX3 != null)
            {
                // Remove callback
                m_AUX3.RemoveCallback(m_auxMonitor);

                // Release reference
                m_AUX3 = null;
            }

            if (m_inputAux != null)
            {
                // Remove callback
                m_inputAux.RemoveCallback(m_auxMonitor);

                // Release reference
                m_inputAux = null;
            }

            if (me1_key1 != null)
            {
                // Remove callback
                me1_key1.RemoveCallback(m_keyMonitor);

                // Release reference
                me1_key1 = null;
            }
            if (me1_key2 != null)
            {
                // Remove callback
                me1_key2.RemoveCallback(m_keyMonitor);

                // Release reference
                me1_key2 = null;
            }
            if (me1_key3 != null)
            {
                // Remove callback
                me1_key3.RemoveCallback(m_keyMonitor);

                // Release reference
                me1_key3 = null;
            }
            if (me1_key4 != null)
            {
                // Remove callback
                me1_key4.RemoveCallback(m_keyMonitor);

                // Release reference
                me1_key4 = null;
            }

            if (m_transition != null)
            {
                // Remove callback
                m_transition.RemoveCallback(m_transitionMonitor);

                // Release reference
                m_transition = null;
            }
            
            // Remove all input monitors, remove callbacks
            foreach (InputMonitor inputMon in m_inputMonitors)
            {
                inputMon.Input.RemoveCallback(inputMon);
            }
            m_inputMonitors.Clear();

            if (m_mixEffectBlock1 != null)
            {
                // Remove callback
                m_mixEffectBlock1.RemoveCallback(m_mixEffectBlockMonitor);

                // Release reference
                m_mixEffectBlock1 = null;
            }

            if (m_switcher != null)
            {
                // Remove callback:
                m_switcher.RemoveCallback(m_switcherMonitor);

                // release reference:
                m_switcher = null;
            }
        }