Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WaveFileReaderExtensions.cs suggestion #1

Closed
emdadgar2 opened this issue Jun 4, 2016 · 1 comment
Closed

WaveFileReaderExtensions.cs suggestion #1

emdadgar2 opened this issue Jun 4, 2016 · 1 comment
Assignees

Comments

@emdadgar2
Copy link

emdadgar2 commented Jun 4, 2016

To support detect DTMF from all NAudio supported file types, change "WaveFileReaderExtensions.cs" like this:

namespace DtmfDetection.NAudio
{
    using System.Collections.Generic;

    using global::NAudio.Wave;

    public static class WaveFileReaderExtensions
    {
        public static IEnumerable<DtmfOccurence> DtmfTones(this WaveStream waveFile)
        {
            var dtmfAudio = new DtmfAudio(new StaticSampleSource(waveFile));

            while (dtmfAudio.WaitForDtmfTone() != DtmfTone.None)
            {
                var start = waveFile.CurrentTime;
                dtmfAudio.WaitForEndOfLastDtmfTone();
                var duration = waveFile.CurrentTime - start;

                yield return new DtmfOccurence(dtmfAudio.LastDtmfTone, start, duration);
            }
        }


    }
}

Thanks.

@bert2 bert2 self-assigned this Jun 8, 2016
@bert2
Copy link
Owner

bert2 commented Jun 8, 2016

I just comitted the fix suggested by you.
Thanks for your input!

@bert2 bert2 closed this as completed Jun 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants