- Notifications
You must be signed in to change notification settings - Fork1
C# implementation of the Goertzel algorithm for DTMF tone (a.k.a. Touch-Tone) detection and localization in audio data. Includes wrappers and extensions for NAudio.
License
Resgrid/DtmfDetection
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Simple C# implementation of the Goertzel algorithm for DTMF tone (a.k.a. Touch-Tone) detection and localization in audio data. Includes wrappers and extensions for NAudio.
https://www.nuget.org/packages/DtmfDetection/
https://www.nuget.org/packages/DtmfDetection.NAudio/
How to print all DTMF tones in a WAV file:
usingSystem;usingNAudio.Wave;usingDtmfDetection.NAudio;publicstaticclassProgram{publicstaticvoidMain(){using(varwaveFile=newWaveFileReader("dtmftest.wav")){foreach(varoccurenceinwaveFile.DtmfTones()){Console.WriteLine($"{occurence.Position.TotalSeconds:00.000} s: "+$"{occurence.DtmfTone.Key} key "+$"(duration:{occurence.Duration.TotalSeconds:00.000} s)");}}}}
How to print all DTMF tones in an MP3 file, but with each audio channel analyzed separately:
usingSystem;usingNAudio.Wave;usingDtmfDetection.NAudio;publicstaticclassProgram{publicstaticvoidMain(){using(varmp3File=newMp3FileReader("dtmftest.mp3")){foreach(varoccurenceinmp3File.DtmfTones(forceMono:false)){Console.WriteLine($"{occurence.Position.TotalSeconds:00.000} s "+$"({occurence.Channel}): "+$"{occurence.DtmfTone.Key} key "+$"(duration:{occurence.Duration.TotalSeconds:00.000} s)");}}}}
How to detect DTMF tones in the current audio output:
usingSystem;usingNAudio.CoreAudioApi;usingNAudio.Wave;usingDtmfDetection.NAudio;publicstaticclassProgram{publicstaticvoidMain(){using(varloopback=newWasapiLoopbackCapture{ShareMode=AudioClientShareMode.Shared}){varanalyzer=newLiveAudioDtmfAnalyzer(loopback);analyzer.DtmfToneStarted+= start=>Console.WriteLine($"{start.DtmfTone.Key} key started on{start.Position.TimeOfDay}");analyzer.DtmfToneStopped+= end=>Console.WriteLine($"{end.DtmfTone.Key} key stopped after{end.Duration.TotalSeconds} s");analyzer.StartCapturing();Console.ReadKey(true);analyzer.StopCapturing();}}}
How to detect DTMF tones through mic in, but with each audio channel analyzed separately:
usingSystem;usingNAudio.Wave;usingDtmfDetection.NAudio;publicstaticclassProgram{publicstaticvoidMain(){using(varmicIn=newWaveInEvent{WaveFormat=newWaveFormat(8000,32,1)}){varanalyzer=newLiveAudioDtmfAnalyzer(micIn,forceMono:false);analyzer.DtmfToneStarted+= start=>Console.WriteLine($"{start.DtmfTone.Key} key started on{start.Position.TimeOfDay} (channel{start.Channel})");analyzer.DtmfToneStopped+= end=>Console.WriteLine($"{end.DtmfTone.Key} key stopped after{end.Duration.TotalSeconds} s (channel{end.Channel})");analyzer.StartCapturing();Console.ReadKey(true);analyzer.StopCapturing();}}}
About
C# implementation of the Goertzel algorithm for DTMF tone (a.k.a. Touch-Tone) detection and localization in audio data. Includes wrappers and extensions for NAudio.
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Languages
- C#100.0%