public void ShouldDownsample48KHzCorrectly() { #region Expected tones var expectedTones = new[] { new DtmfOccurence(DtmfTone.One, 0, TimeSpan.FromSeconds(2.793), TimeSpan.FromSeconds(2.819)), new DtmfOccurence(DtmfTone.Two, 0, TimeSpan.FromSeconds(6.739), TimeSpan.FromSeconds(0.154)), new DtmfOccurence(DtmfTone.Three, 0, TimeSpan.FromSeconds(7.303), TimeSpan.FromSeconds(0.180)), new DtmfOccurence(DtmfTone.Four, 0, TimeSpan.FromSeconds(8.226), TimeSpan.FromSeconds(2.357)), new DtmfOccurence(DtmfTone.Five, 0, TimeSpan.FromSeconds(12.044), TimeSpan.FromSeconds(0.025)), new DtmfOccurence(DtmfTone.Five, 0, TimeSpan.FromSeconds(12.095), TimeSpan.FromSeconds(0.205)), new DtmfOccurence(DtmfTone.Six, 0, TimeSpan.FromSeconds(12.736), TimeSpan.FromSeconds(0.102)), new DtmfOccurence(DtmfTone.Seven, 0, TimeSpan.FromSeconds(14.529), TimeSpan.FromSeconds(0.026)), new DtmfOccurence(DtmfTone.Seven, 0, TimeSpan.FromSeconds(14.581), TimeSpan.FromSeconds(2.306)), new DtmfOccurence(DtmfTone.Eight, 0, TimeSpan.FromSeconds(17.707), TimeSpan.FromSeconds(0.102)), new DtmfOccurence(DtmfTone.Nine, 0, TimeSpan.FromSeconds(18.450), TimeSpan.FromSeconds(0.103)), new DtmfOccurence(DtmfTone.Hash, 0, TimeSpan.FromSeconds(19.142), TimeSpan.FromSeconds(0.256)), new DtmfOccurence(DtmfTone.Zero, 0, TimeSpan.FromSeconds(19.859), TimeSpan.FromSeconds(0.052)), new DtmfOccurence(DtmfTone.Star, 0, TimeSpan.FromSeconds(20.474), TimeSpan.FromSeconds(0.154)), new DtmfOccurence(DtmfTone.One, 0, TimeSpan.FromSeconds(22.038), TimeSpan.FromSeconds(1.768)) }; #endregion using (var waveFile = new WaveFileReader("TestData/long_dtmf_tones_48khz.wav")) { var actualTones = waveFile.DtmfTones().ToArray(); AssertEqual(expectedTones, actualTones); } }
public void DetectsStereoDtmfTonesCorrectly() { #region Expected tones var expectedTones = new[] { new DtmfOccurence(DtmfTone.One, 0, TimeSpan.FromSeconds(0.026), TimeSpan.FromSeconds(0.999)), new DtmfOccurence(DtmfTone.Two, 1, TimeSpan.FromSeconds(2.024), TimeSpan.FromSeconds(1.0)), new DtmfOccurence(DtmfTone.Three, 0, TimeSpan.FromSeconds(4.023), TimeSpan.FromSeconds(1.999)), new DtmfOccurence(DtmfTone.Four, 1, TimeSpan.FromSeconds(5.023), TimeSpan.FromSeconds(1.998)), new DtmfOccurence(DtmfTone.Five, 0, TimeSpan.FromSeconds(8.021), TimeSpan.FromSeconds(0.999)), new DtmfOccurence(DtmfTone.Six, 1, TimeSpan.FromSeconds(8.021), TimeSpan.FromSeconds(0.999)), new DtmfOccurence(DtmfTone.Eight, 1, TimeSpan.FromSeconds(11.019), TimeSpan.FromSeconds(0.999)), new DtmfOccurence(DtmfTone.Seven, 0, TimeSpan.FromSeconds(10.019), TimeSpan.FromSeconds(2.999)), new DtmfOccurence(DtmfTone.Nine, 0, TimeSpan.FromSeconds(14.017), TimeSpan.FromSeconds(0.999)), new DtmfOccurence(DtmfTone.Zero, 0, TimeSpan.FromSeconds(15.016), TimeSpan.FromSeconds(0.984)) }; #endregion using (var waveFile = new WaveFileReader("TestData/stereo_dtmf_tones.wav")) { var actualTones = waveFile.DtmfTones(false).ToArray(); AssertEqual(expectedTones, actualTones); } }
public void DTMF_ShouldBeAbleToReadWavFile() { var path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).Replace("file:\\", ""); using (var waveFile = new WaveFileReader(path + "\\Data\\TestAudio.wav")) { var actualTones = waveFile.DtmfTones(false).ToArray(); actualTones.Should().NotBeNullOrEmpty(); } }
public void DetectsAllStereoDtmfTonesWhenMonoIsForced() { #region Expected tones var expectedTones = new[] { new DtmfOccurence(DtmfTone.One, 0, TimeSpan.FromSeconds(0.026), TimeSpan.FromSeconds(0.999)), new DtmfOccurence(DtmfTone.Two, 0, TimeSpan.FromSeconds(2.024), TimeSpan.FromSeconds(1.0)), new DtmfOccurence(DtmfTone.Three, 0, TimeSpan.FromSeconds(4.023), TimeSpan.FromSeconds(0.977)) }; #endregion using (var waveFile = new WaveFileReader("TestData/stereo_dtmf_tones_no_overlap.wav")) { var actualTones = waveFile.DtmfTones(forceMono: true).ToArray(); AssertEqual(expectedTones, actualTones); } }
void analize_dtfm(string filename) { try { using (var waveFile = new WaveFileReader(filename)) //using (var waveFile = new WaveFileReader("dtmf_sample.wav")) { foreach (var occurence in waveFile.DtmfTones()) { string text = String.Format("TotalSeconds :{0:0.00} Key:{1} Duration:{2:0.000}", occurence.Position.TotalSeconds, occurence.DtmfTone.Key, occurence.Duration.TotalSeconds); listBox1.Items.Add(text); PhoneKey key = occurence.DtmfTone.Key; listBox1.Items.Add(key.ToString()); listBox1.Items.Add(occurence.DtmfTone.ToString()); listBox1.Items.Add(occurence.DtmfTone.LowTone.ToString()); listBox1.Items.Add(occurence.DtmfTone.HighTone.ToString()); ////listBox1.Items.Add( $"{occurence.Position.TotalSeconds:00.000} s: " //// + $"{occurence.DtmfTone.Key} key " //// + $"(duration: {occurence.Duration.TotalSeconds:00.000} s)"); ////Console.WriteLine($"{occurence.Position.TotalSeconds:00.000} s: " //// + $"{occurence.DtmfTone.Key} key " //// + $"(duration: {occurence.Duration.TotalSeconds:00.000} s)"); } } } catch (SystemException exc) { MessageBox.Show("Please select WAV file"); } }