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

I have 4 tones, but it only detects 2 tones #26

Open
billsheh opened this issue Sep 15, 2020 · 15 comments
Open

I have 4 tones, but it only detects 2 tones #26

billsheh opened this issue Sep 15, 2020 · 15 comments

Comments

@billsheh
Copy link

No description provided.

@bert2
Copy link
Owner

bert2 commented Sep 15, 2020

Could you provide the audio file in question?

@billsheh
Copy link
Author

billsheh commented Sep 16, 2020 via email

@bert2
Copy link
Owner

bert2 commented Sep 16, 2020

Hi @billsheh, unfortunately the audio file you attached to the mail didn't make its way into GitHub. I think you'll have to upload it somewhere and post the link here.

@billsheh
Copy link
Author

billsheh commented Sep 16, 2020 via email

@bert2
Copy link
Owner

bert2 commented Sep 16, 2020

That's odd. The file seems normal.
Not sure when I will have the time to investigate this. In the meantime you can try lowering the detection threshold. I was able to detect all four tones with a threshold of 25 (default is 30).

@bert2
Copy link
Owner

bert2 commented Sep 16, 2020

Disabling the normalization also helps, but I wouldn't recommend it.

Let me know when you need further assistance with the detector configuration.

@billsheh
Copy link
Author

billsheh commented Sep 16, 2020 via email

@billsheh
Copy link
Author

billsheh commented Sep 16, 2020 via email

@bert2
Copy link
Owner

bert2 commented Sep 17, 2020

You could make it work with net472, but I'm using a couple netstandard2.1 features. So it can't be done without changing the source and recompiling.

You can try one of the older versions before the 1.0.0 rewrite (e.g 0.9.2), because those still use net47.

A word of warning: back then this library had a shitty interface. You can't even change the detector config without using reflection, because I made its property setters private. I must have had a serious episode of braindeadness or something. Anyway here is the README for 0.9.2.

@billsheh
Copy link
Author

billsheh commented Sep 17, 2020 via email

@billsheh
Copy link
Author

billsheh commented Sep 18, 2020 via email

@bert2
Copy link
Owner

bert2 commented Sep 18, 2020

Hey Bill, thanks to Git it's all still here. You just have to checkout the right commit:

PS> git clone http://github.com/bert2/DtmfDetection
PS> cd DtmfDetection
PS> git checkout 0827801   # checkout last commit of 0.9.2

It's a VS 2017 solution though.

If you have a specific question, feel free to ask it here.

@bert2
Copy link
Owner

bert2 commented Nov 20, 2020

The problem is actually the Goertzel response normalization. For each DTMF tone in the sample file the high frequency is about twice as strong as the low frequency. For the first two tones (phone keys 5 and 6) the high frequency is even a little bit stronger (factor ~2.2).

The normalization simply accumulates the total signal energy including both the high and low frequencies of a DTMF tone. When one of the two is much stronger than the other then the lower one will be suppressed by the higher.

The workaround for now is to disable the normalization. For a fix I'll have to find a way to exclude the frequencies that are part of a DTMF tone from the total signal energy. If this even makes sense, I'm not sure yet.

@moving-digital
Copy link

moving-digital commented May 26, 2022

Hello @bert2

Jumping back in almost two years later. Is there a way to adjust the detection threshold when reading a wav/mp3 file?

As per your example in the readme, the below code is working

using var audioFile = new AudioFileReader("/home/dtmf-not-perfect-example.wav");
var dtmfs = audioFile.DtmfChanges();

I found that the following entry point takes an optional Config argument (defaulting to Config.Default):

List<DtmfChange> float[].DtmfChanges(int, int, Config?)

But in the above case, is it possible to use DtmfChanges in order to modify the config without having the pass the first two int?

@bert2
Copy link
Owner

bert2 commented May 26, 2022

If you provide the parameter name explicitly, other optional parameters can be skipped:

var dtmfs = audioFile.DtmfChanges(config: Config.Default.WithThreshold(42));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants