Decrease threshold for delay test

This commit is contained in:
Flamefire committed 2014-04-29 22:19:12 +02:00
1 parent 6913a1f7b9
commit c31050926d
1 file changed
+24 -10
+24 -10
View File
@@ -15,6 +15,7 @@
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>. // along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
#endregion #endregion
using System;
using System.Diagnostics; using System.Diagnostics;
using Vocaluxe.Base; using Vocaluxe.Base;
@@ -26,6 +27,7 @@ namespace Vocaluxe.Lib.Sound.Record
{ {
public int Channel; public int Channel;
public bool Finished; public bool Finished;
public float OrigThreshold;
} }
private const float _MaxDelayTime = 1000; private const float _MaxDelayTime = 1000;
@@ -51,24 +53,39 @@ namespace Vocaluxe.Lib.Sound.Record
Reset(); Reset();
for (int i = 0; i < _DelaysChannel.Length; i++) 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].Finished = false;
_DelaysChannel[i].Channel = channels[i]; _DelaysChannel[i].Channel = channels[i];
_DelaysChannel[i].OrigThreshold = CRecord.GetVolumeThreshold(channels[i]);
CRecord.SetVolumeThreshold(channels[i], _DelaysChannel[i].OrigThreshold / 3);
} }
else else
_DelaysChannel[i].Finished = true; _DelaysChannel[i].Channel = -1;
} }
_Stream = CSound.PlaySound(ESounds.T440, false); _Stream = CSound.PlaySound(ESounds.T440, false);
Running = true; 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() public void Reset()
{ {
Running = false; _Stop();
for (int i = 0; i < _DelaysChannel.Length; i++) for (int i = 0; i < _DelaysChannel.Length; i++)
Delays[i] = 0; Delays[i] = 0;
_CloseStream();
} }
private void _CloseStream() private void _CloseStream()
@@ -99,21 +116,18 @@ namespace Vocaluxe.Lib.Sound.Record
{ {
if (_DelaysChannel[i].Channel < 0 || _DelaysChannel[i].Finished) if (_DelaysChannel[i].Channel < 0 || _DelaysChannel[i].Finished)
continue; 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; Delays[i] = (int)_Timer.ElapsedMilliseconds;
_DelaysChannel[i].Finished = true; _DelaysChannel[i].Finished = true;
} }
else else
isActive = true; isActive = true;
Console.WriteLine(CRecord.GetMaxVolume(_DelaysChannel[i].Channel));
} }
} }
if (!isActive) if (!isActive)
{ _Stop();
Running = false;
_CloseStream();
_Timer.Stop();
}
} }
} }
} }