How to combine signals for each digit in telephone number (dtmf) to form one continuous signal?
Mostrar comentarios más antiguos
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
Respuesta aceptada
Más respuestas (1)
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 comentarios
JAFARU IBRAHIM
el 8 de Nov. de 2017
Editada: Stephen23
el 9 de Nov. de 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
"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.
Categorías
Más información sobre DTMF en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!