コード例 #1
0
        public bool ReadFFP(string filePath)
        {
            BinaryFile binFile = new BinaryFile(filePath, BinaryFile.ByteOrder.LittleEndian);

            string header = binFile.ReadString(4);

            if (header != "FQ2p")
            {
                return(false);
            }

            Version        = binFile.ReadInt32();
            ParameterCount = binFile.ReadInt32();

            Bands = new List <ProQ2Band>();
            for (int i = 0; i < 24; i++)
            {
                var band = new ProQ2Band();

                // 1 = Enabled, 2 = Disabled
                band.Enabled = binFile.ReadSingle() == 1 ? true : false;

                band.Frequency = FreqConvertBack(binFile.ReadSingle());
                band.Gain      = binFile.ReadSingle(); // actual gain in dB
                band.Q         = QConvertBack(binFile.ReadSingle());

                // 0 - 7
                var filterType = binFile.ReadSingle();
                switch (filterType)
                {
                case (float)ProQ2Shape.Bell:
                    band.Shape = ProQ2Shape.Bell;
                    break;

                case (float)ProQ2Shape.LowShelf:
                    band.Shape = ProQ2Shape.LowShelf;
                    break;

                case (float)ProQ2Shape.LowCut:
                    band.Shape = ProQ2Shape.LowCut;
                    break;

                case (float)ProQ2Shape.HighShelf:
                    band.Shape = ProQ2Shape.HighShelf;
                    break;

                case (float)ProQ2Shape.HighCut:
                    band.Shape = ProQ2Shape.HighCut;
                    break;

                case (float)ProQ2Shape.Notch:
                    band.Shape = ProQ2Shape.Notch;
                    break;

                case (float)ProQ2Shape.BandPass:
                    band.Shape = ProQ2Shape.BandPass;
                    break;

                case (float)ProQ2Shape.TiltShelf:
                    band.Shape = ProQ2Shape.TiltShelf;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(string.Format("Filter type is outside range: {0}", filterType));
                }

                // 0 - 8
                var filterSlope = binFile.ReadSingle();
                switch (filterSlope)
                {
                case (float)ProQSlope.Slope6dB_oct:
                    band.Slope = ProQSlope.Slope6dB_oct;
                    break;

                case (float)ProQSlope.Slope12dB_oct:
                    band.Slope = ProQSlope.Slope12dB_oct;
                    break;

                case (float)ProQSlope.Slope18dB_oct:
                    band.Slope = ProQSlope.Slope18dB_oct;
                    break;

                case (float)ProQSlope.Slope24dB_oct:
                    band.Slope = ProQSlope.Slope24dB_oct;
                    break;

                case (float)ProQSlope.Slope30dB_oct:
                    band.Slope = ProQSlope.Slope30dB_oct;
                    break;

                case (float)ProQSlope.Slope36dB_oct:
                    band.Slope = ProQSlope.Slope36dB_oct;
                    break;

                case (float)ProQSlope.Slope48dB_oct:
                    band.Slope = ProQSlope.Slope48dB_oct;
                    break;

                case (float)ProQSlope.Slope72dB_oct:
                    band.Slope = ProQSlope.Slope72dB_oct;
                    break;

                case (float)ProQSlope.Slope96dB_oct:
                    band.Slope = ProQSlope.Slope96dB_oct;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(string.Format("Filter slope is outside range: {0}", filterSlope));
                }

                // 0 = Left, 1 = Right, 2 = Stereo
                var filterStereoPlacement = binFile.ReadSingle();
                switch (filterStereoPlacement)
                {
                case (float)ProQ2StereoPlacement.LeftOrMid:
                    band.StereoPlacement = ProQ2StereoPlacement.LeftOrMid;
                    break;

                case (float)ProQ2StereoPlacement.RightOrSide:
                    band.StereoPlacement = ProQ2StereoPlacement.RightOrSide;
                    break;

                case (float)ProQ2StereoPlacement.Stereo:
                    band.StereoPlacement = ProQ2StereoPlacement.Stereo;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(string.Format("Filter stereo placement is outside range: {0}", filterStereoPlacement));
                }

                Bands.Add(band);
            }

            // read the remaining floats
            // int remainingParameterCount = ParameterCount - 7 * Bands.Count;
            try
            {
                ProcessingMode       = binFile.ReadSingle();         // Zero Latency: 0.0, Natural Phase: 1.0, Linear Phase: 2.0
                ProcessingResolution = binFile.ReadSingle();         // 0 - 4, Medium
                ChannelMode          = binFile.ReadSingle();         // 0 = Left/Right, 1 = Mid/Side
                GainScale            = binFile.ReadSingle();         // 100%
                OutputLevel          = binFile.ReadSingle();         // 0.0 dB, -1 to 1 (- Infinity to +36 dB , 0 = 0 dB)
                OutputPan            = binFile.ReadSingle();         // Left 0 dB, Right: 0 dB, -1 to 1 (0 = middle)
                ByPass                     = binFile.ReadSingle();   // Not Bypassed
                OutputInvertPhase          = binFile.ReadSingle();   // Normal
                AutoGain                   = binFile.ReadSingle();   // Off
                AnalyzerShowPreProcessing  = binFile.ReadSingle();   // Disabled - 0: Off, 1: On
                AnalyzerShowPostProcessing = binFile.ReadSingle();   // Disabled - 0: Off, 1: On
                AnalyzerShowSidechain      = binFile.ReadSingle();   // Disabled - 0: Off, 1: On
                AnalyzerRange              = binFile.ReadSingle();   // Analyzer Range in dB. 0.0: 60dB, 1.0: 90dB, 2.0: 120dB
                AnalyzerResolution         = binFile.ReadSingle();   // Analyzer Resolution. 0.0: Low, 1.0: Medium, 2.0: High, 3.00: Maximum
                AnalyzerSpeed              = binFile.ReadSingle();   // Analyzer Speed. 0.0: Very Slow, 1.0: Slow, 2.0: Medium, 3.0 Fast, 4.0: Very Fast
                AnalyzerTilt               = binFile.ReadSingle();   // Analyzer Tilt in dB/oct. 0.0: 0.0, 1.0: 1.5, 2.0: 3.0, 3.0: 4.5, 4.0: 6.0
                AnalyzerFreeze             = binFile.ReadSingle();   // 0: Off, 1: On
                SpectrumGrab               = binFile.ReadSingle();   // Enabled
                DisplayRange               = binFile.ReadSingle();   // 12dB
                ReceiveMidi                = binFile.ReadSingle();   // Enabled
                SoloBand                   = binFile.ReadSingle();   // -1
                SoloGain                   = binFile.ReadSingle();   // 0.00
            }
            catch { }

            // check if mid/side
            if (ChannelMode == 1)
            {
                Bands.ForEach(b => b.ChannelMode = ProQ2ChannelMode.MidSide);
            }

            binFile.Close();

            return(true);
        }
コード例 #2
0
        /// <summary>
        /// Initialize the class specific variables using float parameters
        /// </summary>
        public void InitFromParameters(float[] floatParameters, bool isIEEE = true)
        {
            this.Bands = new List <ProQ2Band>();

            float[] floatArray;
            if (isIEEE)
            {
                // convert the ieee float parameters to fabfilter floats
                floatArray = Convert2FabfilterProQ2Floats(floatParameters);
            }
            else
            {
                floatArray = floatParameters;
            }

            int index = 0;

            for (int i = 0; i < 24; i++)
            {
                var band = new ProQ2Band();

                // 1 = Enabled, 2 = Disabled
                band.Enabled = floatArray[index++] == 1 ? true : false;

                band.Frequency = FabfilterProQ2.FreqConvertBack(floatArray[index++]);
                band.Gain      = floatArray[index++]; // actual gain in dB
                band.Q         = FabfilterProQ2.QConvertBack(floatArray[index++]);

                // 0 - 7
                var filterType = floatArray[index++];
                switch (filterType)
                {
                case (float)ProQ2Shape.Bell:
                    band.Shape = ProQ2Shape.Bell;
                    break;

                case (float)ProQ2Shape.LowShelf:
                    band.Shape = ProQ2Shape.LowShelf;
                    break;

                case (float)ProQ2Shape.LowCut:
                    band.Shape = ProQ2Shape.LowCut;
                    break;

                case (float)ProQ2Shape.HighShelf:
                    band.Shape = ProQ2Shape.HighShelf;
                    break;

                case (float)ProQ2Shape.HighCut:
                    band.Shape = ProQ2Shape.HighCut;
                    break;

                case (float)ProQ2Shape.Notch:
                    band.Shape = ProQ2Shape.Notch;
                    break;

                case (float)ProQ2Shape.BandPass:
                    band.Shape = ProQ2Shape.BandPass;
                    break;

                case (float)ProQ2Shape.TiltShelf:
                    band.Shape = ProQ2Shape.TiltShelf;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(string.Format("Filter type is outside range: {0}", filterType));
                }

                // 0 - 8
                var filterSlope = floatArray[index++];
                switch (filterSlope)
                {
                case (float)ProQSlope.Slope6dB_oct:
                    band.Slope = ProQSlope.Slope6dB_oct;
                    break;

                case (float)ProQSlope.Slope12dB_oct:
                    band.Slope = ProQSlope.Slope12dB_oct;
                    break;

                case (float)ProQSlope.Slope18dB_oct:
                    band.Slope = ProQSlope.Slope18dB_oct;
                    break;

                case (float)ProQSlope.Slope24dB_oct:
                    band.Slope = ProQSlope.Slope24dB_oct;
                    break;

                case (float)ProQSlope.Slope30dB_oct:
                    band.Slope = ProQSlope.Slope30dB_oct;
                    break;

                case (float)ProQSlope.Slope36dB_oct:
                    band.Slope = ProQSlope.Slope36dB_oct;
                    break;

                case (float)ProQSlope.Slope48dB_oct:
                    band.Slope = ProQSlope.Slope48dB_oct;
                    break;

                case (float)ProQSlope.Slope72dB_oct:
                    band.Slope = ProQSlope.Slope72dB_oct;
                    break;

                case (float)ProQSlope.Slope96dB_oct:
                    band.Slope = ProQSlope.Slope96dB_oct;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(string.Format("Filter slope is outside range: {0}", filterSlope));
                }

                // 0 = Left, 1 = Right, 2 = Stereo
                var filterStereoPlacement = floatArray[index++];
                switch (filterStereoPlacement)
                {
                case (float)ProQ2StereoPlacement.LeftOrMid:
                    band.StereoPlacement = ProQ2StereoPlacement.LeftOrMid;
                    break;

                case (float)ProQ2StereoPlacement.RightOrSide:
                    band.StereoPlacement = ProQ2StereoPlacement.RightOrSide;
                    break;

                case (float)ProQ2StereoPlacement.Stereo:
                    band.StereoPlacement = ProQ2StereoPlacement.Stereo;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(string.Format("Filter stereo placement is outside range: {0}", filterStereoPlacement));
                }

                this.Bands.Add(band);
            }

            // read the remaining floats
            try
            {
                this.ProcessingMode       = floatArray[index++];         // Zero Latency: 0.0, Natural Phase: 1.0, Linear Phase: 2.0
                this.ProcessingResolution = floatArray[index++];         // 0 - 4, Medium
                this.ChannelMode          = floatArray[index++];         // 0 = Left/Right, 1 = Mid/Side
                this.GainScale            = floatArray[index++];         // 100%
                this.OutputLevel          = floatArray[index++];         // 0.0 dB, -1 to 1 (- Infinity to +36 dB , 0 = 0 dB)
                this.OutputPan            = floatArray[index++];         // Left 0 dB, Right: 0 dB, -1 to 1 (0 = middle)
                this.ByPass                     = floatArray[index++];   // Not Bypassed
                this.OutputInvertPhase          = floatArray[index++];   // Normal
                this.AutoGain                   = floatArray[index++];   // Off
                this.AnalyzerShowPreProcessing  = floatArray[index++];   // Disabled - 0: Off, 1: On
                this.AnalyzerShowPostProcessing = floatArray[index++];   // Disabled - 0: Off, 1: On
                this.AnalyzerShowSidechain      = floatArray[index++];   // Disabled - 0: Off, 1: On
                this.AnalyzerRange              = floatArray[index++];   // Analyzer Range in dB. 0.0: 60dB, 1.0: 90dB, 2.0: 120dB
                this.AnalyzerResolution         = floatArray[index++];   // Analyzer Resolution. 0.0: Low, 1.0: Medium, 2.0: High, 3.00: Maximum
                this.AnalyzerSpeed              = floatArray[index++];   // Analyzer Speed. 0.0: Very Slow, 1.0: Slow, 2.0: Medium, 3.0 Fast, 4.0: Very Fast
                this.AnalyzerTilt               = floatArray[index++];   // Analyzer Tilt in dB/oct. 0.0: 0.0, 1.0: 1.5, 2.0: 3.0, 3.0: 4.5, 4.0: 6.0
                this.AnalyzerFreeze             = floatArray[index++];   // 0: Off, 1: On
                this.SpectrumGrab               = floatArray[index++];   // Enabled
                this.DisplayRange               = floatArray[index++];   // 12dB
                this.ReceiveMidi                = floatArray[index++];   // Enabled
                this.SoloBand                   = floatArray[index++];   // -1, -1 to 1
                this.SoloGain                   = floatArray[index++];   // 0.00, -1 to 1
            }
            catch { }

            // check if mid/side
            if (this.ChannelMode == 1)
            {
                this.Bands.ForEach(b => b.ChannelMode = ProQ2ChannelMode.MidSide);
            }
        }
コード例 #3
0
        private static void SetBand(ProQ2Band band, int bandNumber, SteinbergFrequency frequency)
        {
            if (band != null)
            {
                frequency.Parameters[String.Format("equalizerAbandon{0}", bandNumber)].Number = band.Enabled ? 1.00 : 0.00;

                string channel = ""; // empty for main channel (channel 1). 'Ch2' for secondary channel

                // due to the way fabfilter have only one stereo placement per band (frequency has two) we need to modify both channels in frequency
                // we could have in theory instead updated both channels per band in frequency
                if (band.StereoPlacement != ProQ2StereoPlacement.Stereo)
                {
                    switch (band.StereoPlacement)
                    {
                    case ProQ2StereoPlacement.LeftOrMid:
                        frequency.Parameters[String.Format("equalizerAon{0}", bandNumber)].Number    = 1.0;
                        frequency.Parameters[String.Format("equalizerAon{0}Ch2", bandNumber)].Number = 0.0;

                        if (band.ChannelMode == ProQ2ChannelMode.LeftRight)
                        {
                            frequency.Parameters[String.Format("equalizerAeditchannel{0}", bandNumber)].Number = SteinbergFrequency.ChannelMode.LeftRightModeLeft;
                        }
                        else
                        {
                            frequency.Parameters[String.Format("equalizerAeditchannel{0}", bandNumber)].Number = SteinbergFrequency.ChannelMode.MidSideModeMid;
                        }
                        break;

                    case ProQ2StereoPlacement.RightOrSide:
                        frequency.Parameters[String.Format("equalizerAon{0}", bandNumber)].Number    = 0.0;
                        frequency.Parameters[String.Format("equalizerAon{0}Ch2", bandNumber)].Number = 1.0;
                        channel = "Ch2";

                        if (band.ChannelMode == ProQ2ChannelMode.LeftRight)
                        {
                            frequency.Parameters[String.Format("equalizerAeditchannel{0}", bandNumber)].Number = SteinbergFrequency.ChannelMode.LeftRightModeRight;
                        }
                        else
                        {
                            frequency.Parameters[String.Format("equalizerAeditchannel{0}", bandNumber)].Number = SteinbergFrequency.ChannelMode.MidSideModeSide;
                        }
                        break;

                    case ProQ2StereoPlacement.Stereo:
                        // don't change - this is the default
                        break;
                    }
                }

                frequency.Parameters[String.Format("equalizerAgain{0}{1}", bandNumber, channel)].Number = band.Gain;
                frequency.Parameters[String.Format("equalizerAfreq{0}{1}", bandNumber, channel)].Number = band.Frequency;
                frequency.Parameters[String.Format("equalizerAq{0}{1}", bandNumber, channel)].Number    = band.Q;

                switch (band.Shape)
                {
                case ProQ2Shape.BandPass:
                case ProQ2Shape.TiltShelf:
                case ProQ2Shape.Bell:
                    if (bandNumber == 1 || bandNumber == 8)
                    {
                        frequency.Parameters[String.Format("equalizerAtype{0}{1}", bandNumber, channel)].Number = SteinbergFrequency.BandMode1And8.Peak;
                    }
                    else
                    {
                        frequency.Parameters[String.Format("equalizerAtype{0}{1}", bandNumber, channel)].Number = SteinbergFrequency.BandMode2To7.Peak;
                    }
                    break;

                case ProQ2Shape.LowShelf:
                    if (bandNumber == 1 || bandNumber == 8)
                    {
                        frequency.Parameters[String.Format("equalizerAtype{0}{1}", bandNumber, channel)].Number = SteinbergFrequency.BandMode1And8.LowShelf;
                    }
                    else
                    {
                        frequency.Parameters[String.Format("equalizerAtype{0}{1}", bandNumber, channel)].Number = SteinbergFrequency.BandMode2To7.LowShelf;
                    }
                    break;

                case ProQ2Shape.LowCut:
                    switch (band.Slope)
                    {
                    case ProQSlope.Slope6dB_oct:
                        frequency.Parameters[String.Format("equalizerAtype{0}{1}", bandNumber, channel)].Number = SteinbergFrequency.BandMode1And8.Cut6;
                        break;

                    case ProQSlope.Slope12dB_oct:
                    case ProQSlope.Slope18dB_oct:
                        frequency.Parameters[String.Format("equalizerAtype{0}{1}", bandNumber, channel)].Number = SteinbergFrequency.BandMode1And8.Cut12;
                        break;

                    case ProQSlope.Slope24dB_oct:
                    case ProQSlope.Slope30dB_oct:
                        frequency.Parameters[String.Format("equalizerAtype{0}{1}", bandNumber, channel)].Number = SteinbergFrequency.BandMode1And8.Cut24;
                        break;

                    case ProQSlope.Slope36dB_oct:
                    case ProQSlope.Slope48dB_oct:
                        frequency.Parameters[String.Format("equalizerAtype{0}{1}", bandNumber, channel)].Number = SteinbergFrequency.BandMode1And8.Cut48;
                        break;

                    case ProQSlope.Slope72dB_oct:
                    case ProQSlope.Slope96dB_oct:
                        frequency.Parameters[String.Format("equalizerAtype{0}{1}", bandNumber, channel)].Number = SteinbergFrequency.BandMode1And8.Cut96;
                        break;
                    }
                    break;

                case ProQ2Shape.HighShelf:
                    if (bandNumber == 1 || bandNumber == 8)
                    {
                        frequency.Parameters[String.Format("equalizerAtype{0}{1}", bandNumber, channel)].Number = SteinbergFrequency.BandMode1And8.HighShelf;
                    }
                    else
                    {
                        frequency.Parameters[String.Format("equalizerAtype{0}{1}", bandNumber, channel)].Number = SteinbergFrequency.BandMode2To7.HighShelf;
                    }
                    break;

                case ProQ2Shape.HighCut:
                    switch (band.Slope)
                    {
                    case ProQSlope.Slope6dB_oct:
                        frequency.Parameters[String.Format("equalizerAtype{0}{1}", bandNumber, channel)].Number = SteinbergFrequency.BandMode1And8.Cut6;
                        break;

                    case ProQSlope.Slope12dB_oct:
                    case ProQSlope.Slope18dB_oct:
                        frequency.Parameters[String.Format("equalizerAtype{0}{1}", bandNumber, channel)].Number = SteinbergFrequency.BandMode1And8.Cut12;
                        break;

                    case ProQSlope.Slope24dB_oct:
                    case ProQSlope.Slope30dB_oct:
                        frequency.Parameters[String.Format("equalizerAtype{0}{1}", bandNumber, channel)].Number = SteinbergFrequency.BandMode1And8.Cut24;
                        break;

                    case ProQSlope.Slope36dB_oct:
                    case ProQSlope.Slope48dB_oct:
                        frequency.Parameters[String.Format("equalizerAtype{0}{1}", bandNumber, channel)].Number = SteinbergFrequency.BandMode1And8.Cut48;
                        break;

                    case ProQSlope.Slope72dB_oct:
                    case ProQSlope.Slope96dB_oct:
                        frequency.Parameters[String.Format("equalizerAtype{0}{1}", bandNumber, channel)].Number = SteinbergFrequency.BandMode1And8.Cut96;
                        break;
                    }
                    break;

                case ProQ2Shape.Notch:
                    if (bandNumber == 1 || bandNumber == 8)
                    {
                        frequency.Parameters[String.Format("equalizerAtype{0}{1}", bandNumber, channel)].Number = SteinbergFrequency.BandMode1And8.Notch;
                    }
                    else
                    {
                        frequency.Parameters[String.Format("equalizerAtype{0}{1}", bandNumber, channel)].Number = SteinbergFrequency.BandMode2To7.Notch;
                    }
                    break;
                }

                Log.Debug(band.ToString());
            }
            else
            {
                // disable band
                frequency.Parameters[String.Format("equalizerAbandon{0}", bandNumber)].Number = 0.00;
            }
        }