//waits a set time before immediately increasing the volume private void OnTimedEventAttack(object sender, ElapsedEventArgs e) { volLowered = !volLowered; VolumeMixer.SetVol(Convert.ToInt32(defaultVol * attenuation)); if (hold) { myTimer.Interval = holdTime; } myTimer.Enabled = true; }
//recieve changes from advanced controls when second window is closed private void advancedControls_SubmitClicked(object sender, EventArgs e) { DownThresh = advancedControls.aDownThresh / 100; UpThresh = advancedControls.aUpThresh / 100; attackVal = advancedControls.aattackVal; samples = advancedControls.asamples; trueGain = advancedControls.trueGain; releaseVal = advancedControls.areleaseVal; timerInterval = advancedControls.atimerInterval; myVolumeMixer = new VolumeMixer(samples); VolumeMixer.SetVol(defaultVol); }
/* * private double dBtoPeakVolume(double db) * { * double val; * return val = Math.Pow(10, (db / 10)); * } * * private double peakVolumeToDB(double peakVolume) * { * double val; * return val = 10 * Math.Log10(peakVolume / 1); * } */ //checks or changes the volume private void checkVolume(float val) { //reset timer interval myTimer.Interval = timerInterval; //in case the user clicks stop while calculation is taking place if (!myTimer.Enabled) { return; } //true gain mode if (trueGain) { try { //apply upper attenuation if (val > UpThresh) { curSetVol = Convert.ToInt32(defaultVol * (1 - ((val - UpThresh) * (1 - attenuation)))); //Debug.WriteLine("Signal attenuated to " + i.ToString()); VolumeMixer.SetVol(curSetVol); } //apply lower attenuation else if (val < DownThresh) { curSetVol = Convert.ToInt32(defaultVol * (1 + ((DownThresh - val) * (1 - attenuation)))); //Debug.WriteLine("Signal amplified to " + i.ToString()); VolumeMixer.SetVol(curSetVol); } //keep original signal as is else { if (curSetVol == defaultVol) { return; } curSetVol = defaultVol; VolumeMixer.SetVol(Convert.ToInt32(curSetVol)); } } catch { Debug.WriteLine("TRUE GAIN: Threading issue"); } } //original mode else if (((!volLowered) && (val >= UpThresh)) || ((volLowered) && (val <= DownThresh))) { myTimer.Enabled = false; if (volLowered) { //raise volume, need to check after delay releaseTimer.Interval = releaseVal; releaseTimer.Enabled = true; } else { //lower volume, need to check after delay attackTimer.Interval = attackVal; attackTimer.Enabled = true; } } }
private void vol_changed_slider(object sender, RoutedPropertyChangedEventArgs <double> e) { DV.Text = Math.Floor(preamp.Value).ToString(); defaultVol = Convert.ToInt32(Convert.ToDouble(DV.Text)); VolumeMixer.SetVol(defaultVol); }
private void SetVolumeMixer() { samples = Convert.ToInt32(advancedControls.samps.Text); myVolumeMixer = new VolumeMixer(samples); VolumeMixer.SetVol(defaultVol); }