When we are calling someone from our mobile phone we dial their numbers, each digit of the number sounds different your goal is to identify the key pressed based on the sound.

8 次查看(过去 30 天)
When we are calling someone from our mobile phone we dial their numbers, each digit of the number sounds different your goal is to identify the key pressed based on the sound which you hear.
  4 个评论

请先登录,再进行评论。

回答(1 个)

Shreshth
Shreshth 2024-1-3
Hello Saamraaj,
I understand that you are trying to come up with a program that is capable of discerning which digit is being dialled on a phone based on the distinct tone that each number produces.
The problem you've described is related to Dual-Tone Multi-Frequency (DTMF) signalling, which is used for telecommunication signalling over analog telephone lines. When you press a key on a touch-tone telephone, it generates a sound that is a combination of two frequencies: one from a low-frequency group and one from a high-frequency group.
To identify the key pressed based on the sound, you would typically perform the following steps:
  1. Recording or acquiring the sound: Get the audio signal that contains the DTMF tones.
  2. Pre-processing: Filter and normalize the signal if necessary.
  3. Tone detection: Use a method such as the Fast Fourier Transform (FFT) to determine the frequencies present in the sound.
  4. Decoding: Compare the detected frequencies to a known set of DTMF frequencies to determine the key pressed.
Here's an example of how you might implement a simple DTMF decoder in MATLAB:
function key = decode_dtmf(signal, fs)
% Define the DTMF frequencies for each key
dtmfFrequencies = {
% Low frequencies
[697, 770, 852, 941],
% High frequencies
[1209, 1336, 1477, 1633]
};
% Define the corresponding keys for each frequency pair
dtmfKeys = [
'1', '2', '3', 'A';
'4', '5', '6', 'B';
'7', '8', '9', 'C';
'*', '0', '#', 'D'
];
% Perform FFT on the signal
N = length(signal);
Y = fft(signal);
P2 = abs(Y/N);
P1 = P2(1:N/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = fs*(0:(N/2))/N;
% Find the two highest peaks in the FFT
[peaks, locs] = findpeaks(P1, f, 'SortStr', 'descend', 'NPeaks', 2);
% Extract the two frequencies
freqs = sort(locs(1:2)); % Sort to ensure low frequency comes first
% Find the closest DTMF frequencies
[~, lowFreqIdx] = min(abs(dtmfFrequencies{1} - freqs(1)));
[~, highFreqIdx] = min(abs(dtmfFrequencies{2} - freqs(2)));
% Get the corresponding key
key = dtmfKeys(lowFreqIdx, highFreqIdx);
end
To use this function, you would call it with the audio signal and the sampling frequency as inputs. For example:
% Load or record a DTMF signal
[signal, fs] = audioread('dtmf_tone.wav');
% Decode the DTMF signal to find the key pressed
keyPressed = decode_dtmf(signal, fs);
disp(['The key pressed is: ', keyPressed]);
For more references you can visit the below links provided my MathWorks around DTMF examples and programs.
Thank you,
Shubham Shreshth.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by