Ejemplo n.º 1
0
        private static FairlightAudioState.InputSourceState BuildSource(IBMDSwitcherFairlightAudioSource props, AudioSource inputId, Dictionary <Tuple <AudioSource, long>, bool> tally)
        {
            var state = new FairlightAudioState.InputSourceState();

            props.IsActive(out int active);
            if (active == 0)
            {
                return(null);
            }

            props.GetId(out long id);
            state.SourceId = id;
            props.GetSupportedMixOptions(out _BMDSwitcherFairlightAudioMixOption supportedMixOptions);
            state.SupportedMixOptions = (FairlightAudioMixOption)supportedMixOptions;
            props.GetSourceType(out _BMDSwitcherFairlightAudioSourceType sourceType);
            state.SourceType = AtemEnumMaps.FairlightAudioSourceTypeMap.FindByValue(sourceType);

            props.GetMaxDelayFrames(out ushort maxDelay);
            state.MaxFramesDelay = maxDelay;
            props.GetDelayFrames(out ushort delay);
            state.FramesDelay = delay;

            props.GetInputGain(out double inputGain);
            state.Gain = inputGain;
            props.GetPan(out double pan);
            state.Balance = pan;
            props.GetFaderGain(out double faderGain);
            state.FaderGain = faderGain;
            props.GetMixOption(out _BMDSwitcherFairlightAudioMixOption mixOption);
            state.MixOption = AtemEnumMaps.FairlightAudioMixOptionMap.FindByValue(mixOption);
            props.HasStereoSimulation(out int hasStereoSimulation);
            state.HasStereoSimulation = hasStereoSimulation != 0;
            props.GetStereoSimulationIntensity(out double stereoSimulation);
            state.StereoSimulation = stereoSimulation;

            props.IsMixedIn(out int mixedIn);
            tally[Tuple.Create(inputId, id)] = mixedIn != 0;

            var dynamics = AtemSDKConverter.CastSdk <IBMDSwitcherFairlightAudioDynamicsProcessor>(props.GetEffect);

            dynamics.GetMakeupGain(out double makeupGain);
            state.Dynamics.MakeUpGain = makeupGain;

            var compressor = AtemSDKConverter.CastSdk <IBMDSwitcherFairlightAudioCompressor>(dynamics.GetProcessor);

            FairlightAudioBuilderCommon.ApplyCompressor(compressor, state.Dynamics.Compressor = new FairlightAudioState.CompressorState());
            var limiter = AtemSDKConverter.CastSdk <IBMDSwitcherFairlightAudioLimiter>(dynamics.GetProcessor);

            FairlightAudioBuilderCommon.ApplyLimiter(limiter, state.Dynamics.Limiter = new FairlightAudioState.LimiterState());
            var expander = AtemSDKConverter.CastSdk <IBMDSwitcherFairlightAudioExpander>(dynamics.GetProcessor);

            FairlightAudioBuilderCommon.ApplyExpander(expander, state.Dynamics.Expander = new FairlightAudioState.ExpanderState());

            var eq = AtemSDKConverter.CastSdk <IBMDSwitcherFairlightAudioEqualizer>(props.GetEffect);

            FairlightAudioBuilderCommon.ApplyEqualizer(eq, state.Equalizer);

            return(state);
        }
        public static FairlightAudioState Build(IBMDSwitcherFairlightAudioMixer props)
        {
            var state = new FairlightAudioState();

            props.GetMasterOutFaderGain(out double faderGain);
            state.ProgramOut.Gain = faderGain;
            props.GetMasterOutFollowFadeToBlack(out int followFTB);
            state.ProgramOut.FollowFadeToBlack = followFTB != 0;
            props.GetAudioFollowVideoCrossfadeTransition(out int followTransition);
            state.ProgramOut.AudioFollowVideoCrossfadeTransitionEnabled = followTransition != 0;

            // Effects
            var dynamics = AtemSDKConverter.CastSdk <IBMDSwitcherFairlightAudioDynamicsProcessor>(props.GetMasterOutEffect);

            dynamics.GetMakeupGain(out double makeupGain);
            state.ProgramOut.Dynamics.MakeUpGain = makeupGain;

            var compressor = AtemSDKConverter.CastSdk <IBMDSwitcherFairlightAudioCompressor>(dynamics.GetProcessor);

            FairlightAudioBuilderCommon.ApplyCompressor(compressor, state.ProgramOut.Dynamics.Compressor = new FairlightAudioState.CompressorState());
            var limiter = AtemSDKConverter.CastSdk <IBMDSwitcherFairlightAudioLimiter>(dynamics.GetProcessor);

            FairlightAudioBuilderCommon.ApplyLimiter(limiter, state.ProgramOut.Dynamics.Limiter = new FairlightAudioState.LimiterState());
            // MasterOut appears to never have an expander
            //var expander = AtemSDKConverter.CastSdk<IBMDSwitcherFairlightAudioExpander>(dynamics.GetProcessor);
            //FairlightAudioBuilderCommon.ApplyExpander(expander, state.ProgramOut.Dynamics.Expander = new FairlightAudioState.ExpanderState());

            // Equalizer
            var equalizer = AtemSDKConverter.CastSdk <IBMDSwitcherFairlightAudioEqualizer>(props.GetMasterOutEffect);

            FairlightAudioBuilderCommon.ApplyEqualizer(equalizer, state.ProgramOut.Equalizer);

            // Inputs
            state.Tally = new Dictionary <Tuple <AudioSource, long>, bool>();
            var iterator = AtemSDKConverter.CastSdk <IBMDSwitcherFairlightAudioInputIterator>(props.CreateIterator);

            for (iterator.Next(out IBMDSwitcherFairlightAudioInput input); input != null; iterator.Next(out input))
            {
                input.GetId(out long id);
                state.Inputs[id] = FairlightAudioInputStateBuilder.Build(input, (AudioSource)id, state.Tally);
            }

            var monIter = AtemSDKConverter.CastSdk <IBMDSwitcherFairlightAudioHeadphoneOutputIterator>(props.CreateIterator);

            state.Monitors = AtemSDKConverter.IterateList <IBMDSwitcherFairlightAudioHeadphoneOutput, FairlightAudioState.MonitorOutputState>(monIter.Next, (mon, id) => BuildMonitor(mon));

            return(state);
        }