Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

NotificationsYou must be signed in to change notification settings

Resgrid/DtmfDetection

 
 

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.

Build status

NuGet Packages

https://www.nuget.org/packages/DtmfDetection/

https://www.nuget.org/packages/DtmfDetection.NAudio/

Usage Examples (with 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

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C#100.0%

[8]ページ先頭

©2009-2025 Movatter.jp