How to combine signals for each digit in telephone number (dtmf) to form one continuous signal?

5 views (last 30 days)
Hello. I have this problem: How to combine signals for each digit in telephone number (dtmf) to form one continuous signal, but each digit signal should be separated by silence period? I could manage to plot for each digit, but dont know how to combine them into one? I attached my source code. And I have to get signal like in the picture

Accepted Answer

Thorsten
Thorsten on 4 Nov 2015
Edited: Thorsten on 4 Nov 2015
Set
y = [];
silence = zeros(1,numel(time_vector);
before the for loop and then use
y = [y y_high+ y_low silence]
  1 Comment
Nursultan Bolatbayev
Nursultan Bolatbayev on 4 Nov 2015
Thank you, it works. But now Im struggling with time_vector to get complete signal, silence and complete signal should be vector. I added new file edited with your addition

Sign in to comment.

More Answers (1)

Stephen23
Stephen23 on 4 Nov 2015
Edited: Stephen23 on 4 Nov 2015
Try something like this:
Fs = 8000;
t = 0.25;
N = 1:ceil(t*Fs);
% define DTMF:
R = [697,770,852,941]; % Hz, rows
C = [1209,1336,1477]; % Hz, columns
[Ra,Ca] = meshgrid(R,C); % Hz, all
Rb = 2*pi*(Ra(:)/Fs);
Cb = 2*pi*(Ca(:)/Fs);
T = sin(Rb*N) + sin(Cb*N);
% get user input:
J = '123456789*0#'; % subplot is by row
I = input('Enter keys/s [0:9*#]: ','s');
assert(all(ismember(I,J)),'An invalid key was entered')
% plot and play:
for k = 1:numel(I)
X = strfind(J,I(k));
subplot(4,3,X);
plot(T(X,:));
xlabel(sprintf('KEY%s',I(k)))
sound(T(X,:));
pause(0.5);
end
This was an answer I gave to an earlier question, but you should be able to adapt it to your needs. In particular note how it does not repeat code unnecessarily, and it uses vectorized code.
  2 Comments
JAFARU IBRAHIM
JAFARU IBRAHIM on 8 Nov 2017
Edited: Stephen23 on 9 Nov 2017
Hi Stephen Cobeldick, You're really doing great. Thank
Please, want to know to play the resultant dialling sequence tone of a plots signals like the one below. Any help Please.
fs = 32798
t = 0:1/fs:0.25-1/fs;
x1=sin(2*pi*697*t)+sin(2*pi*1209*t);
x2=sin(2*pi*697*t)+sin(2*pi*1336*t);
x3=sin(2*pi*697*t)+sin(2*pi*1477*t);
x4=sin(2*pi*770*t)+sin(2*pi*1209*t);
x5=sin(2*pi*770*t)+sin(2*pi*1336*t);
x6=sin(2*pi*770*t)+sin(2*pi*1477*t);
x7=sin(2*pi*852*t)+sin(2*pi*1209*t);
x8=sin(2*pi*852*t)+sin(2*pi*1336*t);
x9=sin(2*pi*852*t)+sin(2*pi*1477*t);
int_of_silence = 0.25; shift = t(end)+ int_of_silence;
plot(t, x1, 'b', t+shift, x2, 'b', [t(end) t(end)+int_of_silence], [0 0], 'b', t+2*shift, x3, 'b', 2*[t(end) t(end)+int_of_silence], [0 0], 'b', t+3*shift, x4, 'b', 3*[t(end) t(end)+int_of_silence], [0 0], 'b',t+4*shift, x5, 'b', 4*[t(end) t(end)+int_of_silence], [0 0], 'b',...
t+5*shift, x6, 'b', 5*[t(end) t(end)+int_of_silence], [0 0], 'b',t+6*shift, x7, 'b', 6*[t(end) t(end)+int_of_silence], [0 0], 'b', t+7*shift, x8, 'b', 7*[t(end) t(end)+int_of_silence], [0 0], 'b',t+8*shift, x9, 'b', 8*[t(end) t(end)+int_of_silence], [0 0], 'b')
Thank your
Stephen23
Stephen23 on 9 Nov 2017
Edited: Stephen23 on 9 Nov 2017
"any help please"
  • Using lots of numbered variables indicates that you should really just use indexing. Numbered variables lead beginners to writing really slow, complex, insecure, buggy code.
  • Copy-and-pasting code with small changes is a bad idea. Better to use loops, like I showed in my answer. Use indexing to store the values on each iteration, and the plot after the loop.
  • learn to use arrays and use operators on the whole array (i.e. write vectorized code).
  • Do not write lines with so many operators, like in that plot call. This makes code hard to understand and debug.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!