public static SteinbergCompressor ToSteinbergCompressor(this AbletonCompressor comp)
        {
            var compressor = new SteinbergCompressor();

            compressor.Parameters["threshold"].Number = 20 * Math.Log10(comp.Threshold); // 0.454823315 = -6.84dB, 0.0150452089 = -36.5dB, 0.110704564 = -19.1dB, 1 = 0.0dB, 0.151618019 = -16.4dB

            if (comp.Ratio == AbletonCompressor.MaxFloatMinusEpsilon)
            {
                compressor.Parameters["ratio"].Number = 2.0f;
                compressor.Parameters["limit"].Number = 1.0f;
            }
            else
            {
                compressor.Parameters["ratio"].Number = comp.Ratio;
                compressor.Parameters["limit"].Number = 0.0f;
            }

            compressor.Parameters["attack"].Number      = comp.Attack;
            compressor.Parameters["release"].Number     = comp.Release;
            compressor.Parameters["autorelease"].Number = comp.AutoReleaseControlOnOff == true ? 1.00 : 0.00;
            compressor.Parameters["hold"].Number        = 0.00;
            compressor.Parameters["makeUp"].Number      = comp.Gain;
            compressor.Parameters["automakeup"].Number  = comp.GainCompensation == true ? 1.00 : 0.00;
            compressor.Parameters["softknee"].Number    = comp.Knee > 6.00 ? 1.00 : 0.00;   // Knee value of 0.00 is hard knee, up to 18.00 dB (default 6.00 dB)
            compressor.Parameters["rms"].Number         = comp.Model == 1 ? 100.00 : 00.00; // 0.00 - 100.00 - Model: 0 = Peak, 1 = RMS, 2 = Expand
            compressor.Parameters["drymix"].Number      = (1 - comp.DryWet) * 100;          // 0.00 - 100.00

            Log.Debug(comp.ToString());

            return(compressor);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initialize a VstPreset using a byte array and guid
        /// </summary>
        /// <param name="presetBytes">preset bytes</param>
        /// <param name="guid">plugin guid</param>
        /// <param name="pluginName">optional plugin name (only used for error messages)</param>
        /// <returns>a VstPreset object</returns>
        public static T GetVstPreset <T>(byte[] presetBytes, string guid, string pluginName = null) where T : VstPreset
        {
            VstPreset preset = null;

            switch (guid)
            {
            case VstPreset.VstIDs.SteinbergCompressor:
                preset = new SteinbergCompressor();
                break;

            case VstPreset.VstIDs.SteinbergFrequency:
                preset = new SteinbergFrequency();
                break;

            case VstPreset.VstIDs.SteinbergREVerence:
                preset = new SteinbergREVerence();
                break;

            case VstPreset.VstIDs.FabFilterProQ:
            case VstPreset.VstIDs.FabFilterProQx64:
                preset        = new FabfilterProQ();
                preset.Vst3ID = guid;
                break;

            case VstPreset.VstIDs.FabFilterProQ2:
            case VstPreset.VstIDs.FabFilterProQ2x64:
                preset        = new FabfilterProQ2();
                preset.Vst3ID = guid;
                break;

            case VstPreset.VstIDs.NIKontakt5:
                preset = new NIKontakt5();
                break;

            case VstPreset.VstIDs.NIKontakt6:
                preset = new NIKontakt6();
                break;

            case VstPreset.VstIDs.NIKontakt6_64out:
                preset = new NIKontakt6_64out();
                break;

            case VstPreset.VstIDs.EastWestPlay:
                preset = new EastWestPlay();
                break;

            default:
                preset        = new SteinbergVstPreset();
                preset.Vst3ID = guid;
                break;
            }

            preset.Parameters.Clear();
            preset.CompDataStartPos  = 0;
            preset.CompDataChunkSize = presetBytes.Length;
            preset.ContDataStartPos  = presetBytes.Length;
            preset.ContDataChunkSize = 0;
            preset.InfoXmlStartPos   = presetBytes.Length;

            try
            {
                preset.ReadData(new BinaryFile(presetBytes, BinaryFile.ByteOrder.LittleEndian, Encoding.ASCII), (UInt32)presetBytes.Length, false);

                if (preset.Vst3ID == VstPreset.VstIDs.SteinbergREVerence)
                {
                    // init wave paths and images from the parameters
                    var reverence = preset as SteinbergREVerence;
                    reverence.InitFromParameters();
                }

                else if (preset.Vst3ID == VstPreset.VstIDs.FabFilterProQ ||
                         preset.Vst3ID == VstPreset.VstIDs.FabFilterProQx64)
                {
                    // init variables from the parameters or FXP object
                    var fabFilterProQ = preset as FabfilterProQ;
                    fabFilterProQ.InitFromParameters();
                }

                else if (preset.Vst3ID == VstPreset.VstIDs.FabFilterProQ2 ||
                         preset.Vst3ID == VstPreset.VstIDs.FabFilterProQ2x64)
                {
                    // init variables from the parameters or FXP object
                    var fabFilterProQ2 = preset as FabfilterProQ2;
                    fabFilterProQ2.InitFromParameters();
                }

                else if (preset.Vst3ID == VstPreset.VstIDs.FabFilterProQ3)
                {
                    // init variables from the parameters or FXP object
                    var fabFilterProQ3 = preset as FabfilterProQ3;
                    fabFilterProQ3.InitFromParameters();
                }
            }
            catch (System.Exception e)
            {
                Log.Error("Failed initializing VstPreset using guid: {0}{1}. (Hex dump: {2}) {3}", guid, pluginName != null ? " and name " + pluginName : "", StringUtils.ToHexEditorString(presetBytes), e.Message);
            }

            return(preset as T);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initialize a VstPreset using a file
        /// </summary>
        /// <param name="file">filename</param>
        /// <returns>a VstPreset object</returns>
        public static T GetVstPreset <T>(string file) where T : VstPreset
        {
            VstPreset vstPreset = new SteinbergVstPreset(file);

            VstPreset preset = null;

            switch (vstPreset.Vst3ID)
            {
            case VstPreset.VstIDs.SteinbergCompressor:
                preset            = new SteinbergCompressor();
                preset.Parameters = vstPreset.Parameters;
                preset.FXP        = vstPreset.FXP;
                break;

            case VstPreset.VstIDs.SteinbergFrequency:
                preset            = new SteinbergFrequency();
                preset.Parameters = vstPreset.Parameters;
                preset.FXP        = vstPreset.FXP;
                break;

            case VstPreset.VstIDs.SteinbergREVerence:
                preset            = new SteinbergREVerence();
                preset.Parameters = vstPreset.Parameters;
                preset.FXP        = vstPreset.FXP;

                // init wave paths and images from the parameters
                var reverence = preset as SteinbergREVerence;
                reverence.InitFromParameters();
                break;

            case VstPreset.VstIDs.FabFilterProQ:
            case VstPreset.VstIDs.FabFilterProQx64:
                preset            = new FabfilterProQ();
                preset.Parameters = vstPreset.Parameters;
                preset.FXP        = vstPreset.FXP;

                // init variables from the parameters or FXP object
                var fabFilterProQ = preset as FabfilterProQ;
                fabFilterProQ.InitFromParameters();
                break;

            case VstPreset.VstIDs.FabFilterProQ2:
            case VstPreset.VstIDs.FabFilterProQ2x64:
                preset            = new FabfilterProQ2();
                preset.Parameters = vstPreset.Parameters;
                preset.FXP        = vstPreset.FXP;

                // init variables from the parameters or FXP object
                var fabFilterProQ2 = preset as FabfilterProQ2;
                fabFilterProQ2.InitFromParameters();

                break;

            case VstPreset.VstIDs.FabFilterProQ3:
                preset            = new FabfilterProQ3();
                preset.Parameters = vstPreset.Parameters;
                preset.FXP        = vstPreset.FXP;

                // init variables from the parameters or FXP object
                var fabFilterProQ3 = preset as FabfilterProQ3;
                fabFilterProQ3.InitFromParameters();

                break;

            case VstPreset.VstIDs.WavesSSLChannelStereo:
                VstPreset.Parameter sslChannelXml = null;
                vstPreset.Parameters.TryGetValue("XmlContent", out sslChannelXml);
                if (sslChannelXml != null && sslChannelXml.String != null)
                {
                    List <WavesSSLChannel> channelPresetList = WavesPreset.ParseXml <WavesSSLChannel>(sslChannelXml.String);

                    // a single vstpreset likely (?) only contain one waves ssl preset, use the first
                    preset            = channelPresetList.FirstOrDefault();
                    preset.Parameters = vstPreset.Parameters;
                    preset.FXP        = vstPreset.FXP;
                }
                break;

            case VstPreset.VstIDs.WavesSSLCompStereo:
                VstPreset.Parameter sslCompXml = null;
                vstPreset.Parameters.TryGetValue("XmlContent", out sslCompXml);
                if (sslCompXml != null && sslCompXml.String != null)
                {
                    List <WavesSSLComp> channelPresetList = WavesPreset.ParseXml <WavesSSLComp>(sslCompXml.String);

                    // a single vstpreset likely (?) only contain one waves ssl preset, use the first
                    preset            = channelPresetList.FirstOrDefault();
                    preset.Parameters = vstPreset.Parameters;
                    preset.FXP        = vstPreset.FXP;
                }
                break;

            case VstPreset.VstIDs.NIKontakt5:
                preset            = new NIKontakt5();
                preset.Parameters = vstPreset.Parameters;
                preset.FXP        = vstPreset.FXP;
                break;

            case VstPreset.VstIDs.EastWestPlay:
                preset            = new EastWestPlay();
                preset.Parameters = vstPreset.Parameters;
                preset.FXP        = vstPreset.FXP;
                break;

            default:
                preset = vstPreset;
                break;
            }

            preset.Vst3ID = vstPreset.Vst3ID;

            return(preset as T);
        }