From c31050926d7930c3f2ad6ea5eeee510a9da5ed20 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Tue, 29 Apr 2014 22:19:12 +0200 Subject: [PATCH] Decrease threshold for delay test --- Vocaluxe/Lib/Sound/Record/CDelayTest.cs | 34 +++++++++++++++++-------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/Vocaluxe/Lib/Sound/Record/CDelayTest.cs b/Vocaluxe/Lib/Sound/Record/CDelayTest.cs index 91e1472f..27865727 100644 --- a/Vocaluxe/Lib/Sound/Record/CDelayTest.cs +++ b/Vocaluxe/Lib/Sound/Record/CDelayTest.cs @@ -15,6 +15,7 @@ // along with Vocaluxe. If not, see . #endregion +using System; using System.Diagnostics; using Vocaluxe.Base; @@ -26,6 +27,7 @@ namespace Vocaluxe.Lib.Sound.Record { public int Channel; public bool Finished; + public float OrigThreshold; } private const float _MaxDelayTime = 1000; @@ -51,24 +53,39 @@ namespace Vocaluxe.Lib.Sound.Record Reset(); for (int i = 0; i < _DelaysChannel.Length; i++) { - if (i < channels.Length) + if (i < channels.Length && channels[i] >= 0) { _DelaysChannel[i].Finished = false; _DelaysChannel[i].Channel = channels[i]; + _DelaysChannel[i].OrigThreshold = CRecord.GetVolumeThreshold(channels[i]); + CRecord.SetVolumeThreshold(channels[i], _DelaysChannel[i].OrigThreshold / 3); } else - _DelaysChannel[i].Finished = true; + _DelaysChannel[i].Channel = -1; } _Stream = CSound.PlaySound(ESounds.T440, false); Running = true; } + private void _Stop() + { + if (!Running) + return; + Running = false; + _Timer.Stop(); + _CloseStream(); + foreach (SDelayChannel delay in _DelaysChannel) + { + if (delay.Channel >= 0) + CRecord.SetVolumeThreshold(delay.Channel, delay.OrigThreshold); + } + } + public void Reset() { - Running = false; + _Stop(); for (int i = 0; i < _DelaysChannel.Length; i++) Delays[i] = 0; - _CloseStream(); } private void _CloseStream() @@ -99,21 +116,18 @@ namespace Vocaluxe.Lib.Sound.Record { if (_DelaysChannel[i].Channel < 0 || _DelaysChannel[i].Finished) continue; - if (CRecord.GetMaxVolume(_DelaysChannel[i].Channel) > 0.1f && CRecord.GetTone(_DelaysChannel[i].Channel) == 9) + if (CRecord.GetTone(_DelaysChannel[i].Channel) == 9) { Delays[i] = (int)_Timer.ElapsedMilliseconds; _DelaysChannel[i].Finished = true; } else isActive = true; + Console.WriteLine(CRecord.GetMaxVolume(_DelaysChannel[i].Channel)); } } if (!isActive) - { - Running = false; - _CloseStream(); - _Timer.Stop(); - } + _Stop(); } } } \ No newline at end of file