Name: OP 2012-02-27 21:48
So I'm working with the bass audio library, and in learning how to use it I wrote a class that could be used to decode DTMF tones. The class works, more or less. However, I ran into an issue with one of my events pertaining to this bit of code...
At line 4 it is supposed to determine whether the current peak energy level of the channel exceeds the noise threshold. If it does, it is supposed to fire an event. There is also similar code for the opposite event that likely acts the same. Both values are of type double. The values are decibel measurements between -infinity dB and 0 dB.
What seems to happen, however, is even if the SignalLevel value is something like -0.005~ and the NoiseThreshold value is -30.0 it will never equate to true and process the code contained within the if statement. What am I doing wrong?
if (signalThresholdBroken == false)
{
// Check if overall signal level has broken the noise threshold.
if (SignalLevel >= NoiseThreshold)
{
Debug.WriteLine("[SignalListener.cs] recAnalyzer(): " +
"Detected signal above threshold.");
// Raise an event to notify.
if (SignalOn != null) _synch.Invoke(eventsDelegate, new object[]
{ SignalLevel, new EventArgs(), ListenerEventType.SignalOn });
// Set this so we don't spam events.
signalThresholdBroken = true;
}
}At line 4 it is supposed to determine whether the current peak energy level of the channel exceeds the noise threshold. If it does, it is supposed to fire an event. There is also similar code for the opposite event that likely acts the same. Both values are of type double. The values are decibel measurements between -infinity dB and 0 dB.
What seems to happen, however, is even if the SignalLevel value is something like -0.005~ and the NoiseThreshold value is -30.0 it will never equate to true and process the code contained within the if statement. What am I doing wrong?