void Set(ConditionVariables cv) { SoundEffectSettings ap = new SoundEffectSettings(cv); // we have no control over values, user could have messed them up, and it excepts if out of range trackBarEM.Enabled = trackBarEF.Enabled = trackBarED.Enabled = checkBoxE.Checked = ap.echoenabled; try { trackBarEM.Value = ap.echomix; trackBarEF.Value = ap.echofeedback; trackBarED.Value = ap.echodelay; } catch { } trackBarCM.Enabled = trackBarCF.Enabled = trackBarCD.Enabled = trackBarCDp.Enabled = checkBoxC.Checked = ap.chorusenabled; try { trackBarCM.Value = ap.chorusmix; trackBarCF.Value = ap.chorusfeedback; trackBarCD.Value = ap.chorusdelay; trackBarCDp.Value = ap.chorusdepth; } catch { } trackBarRM.Enabled = trackBarRT.Enabled = trackBarRH.Enabled = checkBoxR.Checked = ap.reverbenabled; try { trackBarRM.Value = ap.reverbmix; trackBarRT.Value = ap.reverbtime; trackBarRH.Value = ap.reverbhfratio; } catch { } trackBarDG.Enabled = trackBarDE.Enabled = trackBarDC.Enabled = trackBarDW.Enabled = checkBoxD.Checked = ap.distortionenabled; try { trackBarDG.Value = ap.distortiongain; trackBarDE.Value = ap.distortionedge; trackBarDC.Value = ap.distortioncentrefreq; trackBarDW.Value = ap.distortionfreqwidth; } catch { } trackBarGF.Enabled = checkBoxG.Checked = ap.gargleenabled; try { trackBarGF.Value = ap.garglefreq; } catch { } trackBarPitch.Enabled = checkBoxP.Checked = ap.pitchshiftenabled; try { trackBarPitch.Value = ap.pitchshift; } catch { } checkBoxCustomNone.Checked = ap.OverrideNone; BaseUtils.ThemeAbleFormsInstance.Instance.ApplyToForm(this, System.Drawing.SystemFonts.DefaultFont); }
// FROM audio stream public AudioData Generate(System.IO.Stream audioms, SoundEffectSettings effects, bool ensureaudio) { try { audioms.Position = 0; IWaveSource s; if (audioms.Length == 0) { if (ensureaudio) { s = new NullWaveSource(50); } else { return(null); } } else { s = new CSCore.Codecs.WAV.WaveFileReader(audioms); //System.Diagnostics.Debug.WriteLine("oRIGINAL length " + s.Length); if (ensureaudio) { s = s.AppendSource(x => new ExtendWaveSource(x, 100)); // SEEMS to help the click at end.. } } //System.Diagnostics.Debug.WriteLine("Sample length " + s.Length); System.Diagnostics.Debug.Assert(s != null); ApplyEffects(ref s, effects); //System.Diagnostics.Debug.WriteLine(".. to length " + s.Length); System.Diagnostics.Debug.Assert(s != null); return(new AudioData(s)); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Exception " + ex.Message); if (ensureaudio) { IWaveSource s = new NullWaveSource(100); System.Diagnostics.Debug.Assert(s != null); return(new AudioData(s)); } else { return(null); } } }
public ConditionVariables GetEffects() { SoundEffectSettings ap = new SoundEffectSettings(); if (checkBoxE.Checked) { ap.echomix = trackBarEM.Value; ap.echofeedback = trackBarEF.Value; ap.echodelay = trackBarED.Value; } if (checkBoxC.Checked) { ap.chorusmix = trackBarCM.Value; ap.chorusfeedback = trackBarCF.Value; ap.chorusdelay = trackBarCD.Value; ap.chorusdepth = trackBarCDp.Value; } if (checkBoxR.Checked) { ap.reverbmix = trackBarRM.Value; ap.reverbtime = trackBarRT.Value; ap.reverbhfratio = trackBarRH.Value; } if (checkBoxD.Checked) { ap.distortiongain = trackBarDG.Value; ap.distortionedge = trackBarDE.Value; ap.distortioncentrefreq = trackBarDC.Value; ap.distortionfreqwidth = trackBarDW.Value; } if (checkBoxG.Checked) { ap.garglefreq = trackBarGF.Value; } if (checkBoxP.Checked) { ap.pitchshift = trackBarPitch.Value; } if (checkBoxCustomNone.Checked) { ap.OverrideNone = true; } return(ap.values); }
// FROM file public AudioData Generate(string file, SoundEffectSettings effects) { try { IWaveSource s = CSCore.Codecs.CodecFactory.Instance.GetCodec(file); System.Diagnostics.Debug.Assert(s != null); ApplyEffects(ref s, effects); System.Diagnostics.Debug.Assert(s != null); return(new AudioData(s)); } catch { return(null); } }
public AudioSample Generate(string file, SoundEffectSettings effects = null) // from a file (you get a AS back so you have the chance to add events) { AudioData audio = ad.Generate(file, effects); if (audio != null) { AudioSample a = new AudioSample() { audiodata = audio }; return(a); } else { return(null); } }
public AudioSample Generate(System.IO.Stream audioms, SoundEffectSettings effects = null, bool ensuresomeaudio = false) // from a memory stream { if (audioms != null) { AudioData audio = ad.Generate(audioms, effects, ensuresomeaudio); if (audio != null) { AudioSample a = new AudioSample() { audiodata = audio }; a.handlelist.Add(audioms); return(a); } } return(null); }
public static SoundEffectSettings Set(Variables globals, Variables local) { SoundEffectSettings ses = new SoundEffectSettings(local); // use the rest of the vars to place effects if (ses.OverrideNone) // if none { ses = null; // no speech effects } else if (ses.Merge) // merged { Variables merged = new Variables(globals, local); // add global settings (if not null) overridden by vars ses = new SoundEffectSettings(merged); } else if (!ses.Any) // if none on the command line { ses = (globals != null) ? new SoundEffectSettings(globals) : null; } return(ses); }
static private void ApplyEffects(ref IWaveSource src, SoundEffectSettings ap) // ap may be null { if (ap != null && ap.Any) { int extend = 0; if (ap.echoenabled) { extend = ap.echodelay * 2; } if (ap.chorusenabled) { extend = Math.Max(extend, 50); } if (ap.reverbenabled) { extend = Math.Max(extend, 50); } if (extend > 0) { //System.Diagnostics.Debug.WriteLine("Extend by " + extend + " ms due to effects"); src = src.AppendSource(x => new ExtendWaveSource(x, extend)); } if (ap.chorusenabled) { src = src.AppendSource(x => new DmoChorusEffect(x) { WetDryMix = ap.chorusmix, Feedback = ap.chorusfeedback, Delay = ap.chorusdelay, Depth = ap.chorusdepth }); } if (ap.reverbenabled) { src = src.AppendSource(x => new DmoWavesReverbEffect(x) { InGain = 0, ReverbMix = ap.reverbmix, ReverbTime = ((float)ap.reverbtime) / 1000.0F, HighFrequencyRTRatio = ((float)ap.reverbhfratio) / 1000.0F }); } if (ap.distortionenabled) { src = src.AppendSource(x => new DmoDistortionEffect(x) { Gain = ap.distortiongain, Edge = ap.distortionedge, PostEQCenterFrequency = ap.distortioncentrefreq, PostEQBandwidth = ap.distortionfreqwidth }); } if (ap.gargleenabled) { src = src.AppendSource(x => new DmoGargleEffect(x) { RateHz = ap.garglefreq }); } if (ap.echoenabled) { src = src.AppendSource(x => new DmoEchoEffect(x) { WetDryMix = ap.echomix, Feedback = ap.echofeedback, LeftDelay = ap.echodelay, RightDelay = ap.echodelay }); } if (ap.pitchshiftenabled) { ISampleSource srs = src.ToSampleSource(); srs = srs.AppendSource(x => new PitchShifter(x) { PitchShiftFactor = ((float)ap.pitchshift) / 100.0F }); src = srs.ToWaveSource(); } } }
public AudioData Generate(System.IO.Stream audioms, SoundEffectSettings effects, bool ensureaudio) { return(null); }
public AudioData Generate(string file, SoundEffectSettings effects) { return(null); }