public ISfGenericPreset GetNormPreset(IScriptableApp appl, int level, bool rms) { //takes in a integer level and a bool for rms and creates a norm preset //----Example call: ISfGenericPreset normNeg4 = GetNormPreset(app, -4, false);----- ISfGenericEffect fx = appl.FindEffect("Normalize"); ISfGenericPreset preset0 = fx.GetPreset(0); byte[] abData = preset0.Bytes; string levelString = level.ToString(); ISfGenericPreset normPreset = new SoundForge.SfGenericPreset(levelString, fx, abData); Fields_Normalize field1 = Fields_Normalize.FromPreset(normPreset); //If 0dB or a positive dB was requested, set the NormTo field as 0. if (level >= 0) { field1.NormalizeTo = 0; } else field1.NormalizeTo = SfHelpers.dBToRatio(level); field1.RMS = rms; if (rms) { field1.IfClip = Fields_Normalize.ClipAction.Compress; } field1.ToPreset(normPreset); return normPreset; }
private void updatePresets() { fadeInPresetComboBox.Items.Clear(); fadeOutPresetComboBox.Items.Clear(); ISfGenericEffect effect = forgeApp.FindEffect(EffectName); if (effect == null) { MessageBox.Show(string.Format("Effect '{0}' not found.", EffectName), "error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } foreach (ISfGenericPreset preset in effect.Presets) { fadeInPresetComboBox.Items.Add(preset.Name); fadeOutPresetComboBox.Items.Add(preset.Name); } fadeInPresetComboBox.SelectedIndex = 0; fadeOutPresetComboBox.SelectedIndex = 0; }
public void ApplyEffectPreset(IScriptableApp app, SfAudioSelection selection, string effectName, string presetName, EffectOptions effectOption, OutputHelper.MessageLogger logger) { if (effectOption == EffectOptions.ReturnPreset || effectOption == EffectOptions.WaitForDoneOrCancel) { throw new ScriptAbortedException("Invalid EffectOptions option: " + effectOption); } ISfGenericEffect effect = app.FindEffect(effectName); if (effect == null) { throw new ScriptAbortedException(String.Format("Effect '{0}' was not found.", effectName)); } ISfGenericPreset preset = effect.GetPreset(presetName); if (preset == null) { throw new ScriptAbortedException(String.Format("Preset '{0}' was not found for effect '{1}'.", presetName, effectName)); } if (logger != null) { logger("Applying Effect '{0}', Preset '{1}'...", effect.Name, preset.Name); } _file.DoEffect(effectName, presetName, selection, effectOption | EffectOptions.WaitForDoneOrCancel | EffectOptions.ReturnPreset); }