public void TestRcaToXlrEnabled()
        {
            var  handler = CommandGenerator.CreateAutoCommandHandler <FairlightMixerInputSetCommand, FairlightMixerInputGetCommand>("RcaToXlrEnabled");
            bool tested  = false;

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.FairlightXLR, helper =>
            {
                IEnumerable <long> useIds = helper.Helper.BuildLibState().Fairlight.Inputs.Keys.ToList();
                foreach (long id in useIds)
                {
                    IBMDSwitcherFairlightAudioInput input = GetInput(helper, id);
                    if (input is IBMDSwitcherFairlightAudioInputXLR xlrInput)
                    {
                        AtemState stateBefore = helper.Helper.BuildLibState();
                        FairlightAudioState.InputState inputState = stateBefore.Fairlight.Inputs[id];

                        xlrInput.HasRCAToXLR(out int isAvailable);
                        Assert.Equal(1, isAvailable);
                        tested = true;

                        for (int i = 0; i < 5; i++)
                        {
                            inputState.Analog.InputLevel = i % 2 != 0
                                ? FairlightAnalogInputLevel.ConsumerLine
                                : FairlightAnalogInputLevel.ProLine;
                            helper.SendAndWaitForChange(stateBefore, () => { xlrInput.SetRCAToXLREnabled(i % 2); });
                        }
                    }
                }
            });
            Assert.True(tested);
        }
        public void TestActiveConfiguration()
        {
            var  handler = CommandGenerator.CreateAutoCommandHandler <FairlightMixerInputSetCommand, FairlightMixerInputGetCommand>("ActiveConfiguration");
            bool tested  = false;

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.FairlightMain, helper =>
            {
                IEnumerable <long> useIds = Randomiser.SelectionOfGroup(helper.Helper.BuildLibState().Fairlight.Inputs.Keys.ToList());
                foreach (long id in useIds)
                {
                    IBMDSwitcherFairlightAudioInput input = GetInput(helper, id);

                    AtemState stateBefore = helper.Helper.BuildLibState();
                    FairlightAudioState.InputState inputState = stateBefore.Fairlight.Inputs[id];

                    var testConfigs = AtemSDKConverter.GetFlagsValues(input.GetSupportedConfigurations,
                                                                      AtemEnumMaps.FairlightInputConfigurationMap);
                    // Need more than 1 config to allow for switching around
                    if (1 == testConfigs.Count)
                    {
                        continue;
                    }
                    tested = true;

                    for (int i = 0; i < 5; i++)
                    {
                        var target = testConfigs[i % testConfigs.Count];
                        inputState.ActiveConfiguration = target.Item2;
                        helper.SendAndWaitForChange(stateBefore, () => { input.SetConfiguration(target.Item1); });
                    }
                }
            });
            Assert.True(tested);
        }
        public FairlightAudioMixerInput(IBMDSwitcherFairlightAudioInput input, IMediator mediator)
        {
            _input    = input;
            _mediator = mediator;

            Init();
        }
        public void TestAddRemoveSources()
        {
            AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.FairlightMain, helper =>
            {
                IEnumerable <long> useIds = Randomiser.SelectionOfGroup(helper.Helper.BuildLibState().Fairlight.Inputs.Keys.ToList());
                foreach (long id in useIds)
                {
                    helper.Helper.SyncStates();

                    IBMDSwitcherFairlightAudioInput input = GetInput(helper, id);

                    AtemState stateBefore = helper.Helper.BuildLibState();
                    FairlightAudioState.InputState inputState = stateBefore.Fairlight.Inputs[id];
                    inputState.Sources.Add(new FairlightAudioState.InputSourceState
                    {
                        SourceId  = 944,
                        MixOption = FairlightAudioMixOption.Off,
                        Gain      = -23.7,
                    });

                    int sourceId = 944;
                    void mangleState(AtemState sdkState, AtemState libState)
                    {
                        FairlightAudioState.InputSourceState srcState = sdkState.Fairlight.Inputs[id].Sources.Single(s => s.SourceId == sourceId);
                        srcState.Dynamics.Limiter    = null;
                        srcState.Dynamics.Compressor = null;
                        srcState.Dynamics.Expander   = null;
                    }

                    helper.SendAndWaitForChange(stateBefore, () => {
                        helper.Server.SendCommands(new FairlightMixerSourceGetCommand
                        {
                            Index     = (AudioSource)id,
                            SourceId  = sourceId,
                            MixOption = FairlightAudioMixOption.Off,
                            Gain      = -23.7,
                        });
                    }, -1, mangleState);

                    var removeSourceId = inputState.Sources[0].SourceId;
                    inputState.Sources.RemoveAt(0);

                    helper.SendAndWaitForChange(stateBefore, () => {
                        helper.Server.SendCommands(new FairlightMixerSourceDeleteCommand
                        {
                            Index    = (AudioSource)id,
                            SourceId = removeSourceId,
                        });
                    }, -1, mangleState);
                }
            });
        }
Esempio n. 5
0
        private static IBMDSwitcherFairlightAudioSource GetSource(IBMDSwitcherFairlightAudioInput input, long?targetId = null)
        {
            var iterator = AtemSDKConverter.CastSdk <IBMDSwitcherFairlightAudioSourceIterator>(input.CreateIterator);

            if (targetId.HasValue)
            {
                iterator.GetById(targetId.Value, out IBMDSwitcherFairlightAudioSource src);
                return(src);
            }
            else
            {
                iterator.Next(out IBMDSwitcherFairlightAudioSource src);
                return(src);
            }
        }
        public void TestHasAnalogInputLevel()
        {
            bool tested = false;

            AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.FairlightAnalog, helper =>
            {
                var rawCommands = helper.Server.GetParsedDataDump();

                IEnumerable <long> useIds = helper.Helper.BuildLibState().Fairlight.Inputs.Keys.ToList();
                foreach (long id in useIds)
                {
                    IBMDSwitcherFairlightAudioInput input = GetInput(helper, id);
                    if (input is IBMDSwitcherFairlightAnalogAudioInput analog)
                    {
                        AtemState stateBefore = helper.Helper.BuildLibState();
                        FairlightAudioState.InputState inputState = stateBefore.Fairlight.Inputs[id];

                        analog.GetSupportedInputLevels(out _BMDSwitcherFairlightAudioAnalogInputLevel supportedLevels);
                        Assert.NotEqual(0, (int)supportedLevels);
                        Assert.NotNull(inputState.Analog);
                        tested = true;

                        var srcCommand = rawCommands.OfType <FairlightMixerInputGetV811Command>().Single(c => c.Index == (AudioSource)id);
                        var useLevels  = inputState.Analog.SupportedInputLevel.FindFlagComponents();

                        for (int i = 0; i < 5; i++)
                        {
                            inputState.Analog.SupportedInputLevel = srcCommand.SupportedInputLevels =
                                useLevels[i % useLevels.Count];

                            helper.SendAndWaitForChange(stateBefore, () => { helper.Server.SendCommands(srcCommand); });
                        }
                    }
                }
            });
            Assert.True(tested);
        }
        public void TestAnalogInputLevel()
        {
            var  handler = CommandGenerator.CreateAutoCommandHandler <FairlightMixerAnalogAudioSetCommand, FairlightMixerAnalogAudioGetCommand>("InputLevel", true);
            bool tested  = false;

            AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.FairlightAnalog, helper =>
            {
                IEnumerable <long> useIds = helper.Helper.BuildLibState().Fairlight.Inputs.Keys.ToList();
                foreach (long id in useIds)
                {
                    IBMDSwitcherFairlightAudioInput input = GetInput(helper, id);
                    if (input is IBMDSwitcherFairlightAnalogAudioInput analogInput)
                    {
                        AtemState stateBefore = helper.Helper.BuildLibState();
                        FairlightAudioState.AnalogState inputState = stateBefore.Fairlight.Inputs[id].Analog;

                        var testConfigs = AtemSDKConverter.GetFlagsValues(analogInput.GetSupportedInputLevels,
                                                                          AtemEnumMaps.FairlightAnalogInputLevelMap);
                        // Need more than 1 config to allow for switching around
                        if (1 == testConfigs.Count)
                        {
                            continue;
                        }
                        tested = true;

                        for (int i = 0; i < 5; i++)
                        {
                            var target            = testConfigs[i % testConfigs.Count];
                            inputState.InputLevel = target.Item2;
                            helper.SendAndWaitForChange(stateBefore, () => { analogInput.SetInputLevel(target.Item1); });
                        }
                    }
                }
            });
            Assert.True(tested);
        }
Esempio n. 8
0
        public static FairlightAudioState.InputState Build(IBMDSwitcherFairlightAudioInput props, AudioSource inputId, Dictionary <Tuple <AudioSource, long>, bool> tally)
        {
            var state = new FairlightAudioState.InputState();

            // Input basics
            props.GetCurrentExternalPortType(out _BMDSwitcherExternalPortType portType);
            state.ExternalPortType = AtemEnumMaps.AudioPortTypeMap.FindByValue(portType);
            props.GetConfiguration(out _BMDSwitcherFairlightAudioInputConfiguration configuration);
            state.ActiveConfiguration = AtemEnumMaps.FairlightInputConfigurationMap.FindByValue(configuration);
            props.GetSupportedConfigurations(out _BMDSwitcherFairlightAudioInputConfiguration supportedConfigurations);
            state.SupportedConfigurations = (FairlightInputConfiguration)supportedConfigurations;
            props.GetType(out _BMDSwitcherFairlightAudioInputType type);
            state.InputType = AtemEnumMaps.FairlightInputTypeMap.FindByValue(type);

            // Analog
            if (props is IBMDSwitcherFairlightAnalogAudioInput analog)
            {
                state.Analog = new FairlightAudioState.AnalogState();
                analog.GetInputLevel(out _BMDSwitcherFairlightAudioAnalogInputLevel level);
                state.Analog.InputLevel = AtemEnumMaps.FairlightAnalogInputLevelMap.FindByValue(level);

                analog.GetSupportedInputLevels(out _BMDSwitcherFairlightAudioAnalogInputLevel supportedLevels);
                state.Analog.SupportedInputLevel = (FairlightAnalogInputLevel)supportedLevels;
            }

#if ATEM_v8_1
            // XLR
            if (props is IBMDSwitcherFairlightAudioInputXLR xlr)
            {
                xlr.HasRCAToXLR(out int hasRcaToXlr);
                if (hasRcaToXlr != 0)
                {
                    if (state.Analog == null)
                    {
                        state.Analog = new FairlightAudioState.AnalogState();
                    }

                    state.Analog.SupportedInputLevel =
                        FairlightAnalogInputLevel.ConsumerLine | FairlightAnalogInputLevel.ProLine;
                    xlr.GetRCAToXLREnabled(out int rcaToXlrEnabled);
                    state.Analog.InputLevel = rcaToXlrEnabled != 0
                        ? FairlightAnalogInputLevel.ConsumerLine
                        : FairlightAnalogInputLevel.ProLine;
                }
            }
#else
            // TODO
#endif

            // Sources
            var iterator = AtemSDKConverter.CastSdk <IBMDSwitcherFairlightAudioSourceIterator>(props.CreateIterator);
            AtemSDKConverter.Iterate <IBMDSwitcherFairlightAudioSource>(
                iterator.Next,
                (src, id) =>
            {
                var val = BuildSource(src, inputId, tally);
                if (val != null)
                {
                    state.Sources.Add(val);
                }
            });

            return(state);
        }
        public static IEnumerable <IBMDSwitcherFairlightAudioSource> GetFairlightAudioMixerInputSources(this IBMDSwitcherFairlightAudioInput o)
        {
            var result = new List <IBMDSwitcherFairlightAudioSource>();

            if (o == null)
            {
                return(result);
            }

            Guid g = typeof(IBMDSwitcherFairlightAudioSourceIterator).GUID;

            o.CreateIterator(ref g, out IntPtr ptr);
            var iterator = (IBMDSwitcherFairlightAudioSourceIterator)Marshal.GetObjectForIUnknown(ptr);

            iterator.Next(out IBMDSwitcherFairlightAudioSource input);
            while (input != null)
            {
                result.Add(input);
                iterator.Next(out input);
            }
            return(result);
        }