CrazyEngineers
  • MATLAB DTMF Decoding code

    Updated: Oct 26, 2024
    Views: 1.5K
    hi,

    This is my DTMF decoding code for 7 number random dtmf signal.

    What is Dtmf?
    Dual-tone multi-frequency (DTMF) signaling is used for <a href="https://en.wikipedia.org/wiki/Signalling_(telecommunications)" target="_blank" rel="nofollow noopener noreferrer">Signalling (Telecommunications)</a> over analog telephone lines in the voice-frequency band between <a href="https://en.wikipedia.org/wiki/Telephone" target="_blank" rel="nofollow noopener noreferrer">Telephone</a> handsets and other communications devices and the <a href="https://en.wikipedia.org/wiki/Automatic_telephone_exchange" target="_blank" rel="nofollow noopener noreferrer">Automatic Telephone Exchange</a>. The version of DTMF used for telephone tone dialing is known by the trademarked term Touch-Tone (canceled March 13, 1984), and is standardized by <a href="https://en.wikipedia.org/wiki/ITU-T" target="_blank" rel="nofollow noopener noreferrer">Itu T</a> Recommendation #-Link-Snipped-#. It is also known in the UK as MF4. Other <a href="https://en.wikipedia.org/wiki/Multi-frequency" target="_blank" rel="nofollow noopener noreferrer">Multi Frequency</a> systems are used for signaling internal to the telephone network.
    (source:Wiki)

    Code:
     
    function [testout] = ttdecode2(x)
    d = [0.7217 1.0247; 0.5346 0.9273; 0.5346  1.0247;0.5346 1.1328; 0.5906 0.9273;0.5906 1.0247; 0.5906 1.1328; 0.6535 0.9273;0.6535 1.0247; 0.6535 1.1328];
     
     aras = find(x==0);
    
     n = 1;
     for i = 1:size(aras,2)-2
    if(aras(i+1)-aras(i) > 100)
    if(aras(i+2)-aras(i+1) > 100)
    abas(n,1)=aras(i);   
    abas(n,2)=aras(i+2);
    n = n + 1;    
    aras(i+1)=aras(i+2);
    i = i -1;
    end
    if(aras(i+2)-aras(i+1) < 100)
    abas(n,1)=aras(i);
    abas(n,2)=aras(i+1);
     n = n +1;
    end
    end
     end
    
    x11 = x(abas(1,1):abas(1,2));
    x12 = x(abas(2,1):abas(2,2));
    x13 = x(abas(3,1):abas(3,2));
    x14 = x(abas(4,1):abas(4,2));
    x15 = x(abas(5,1):abas(5,2));
    x16 = x(abas(6,1):abas(6,2));
    x17 = x(aras(size(aras,2)):size(x,2));
    
    bak1 = (abs(fft(x11,2048))).^2;
    bak2 = (abs(fft(x12,2048))).^2;
    bak3 = (abs(fft(x13,2048))).^2;
    bak4 = (abs(fft(x14,2048))).^2;
    bak5 = (abs(fft(x15,2048))).^2;
    bak6 = (abs(fft(x16,2048))).^2;
    bak7 = (abs(fft(x17,2048))).^2;
    bak1(1000:2048)=0;
    bak2(1000:2048)=0;
    bak3(1000:2048)=0;
    bak4(1000:2048)=0;
    bak5(1000:2048)=0;
    bak6(1000:2048)=0;
    bak7(1000:2048)=0;
    k = 0:2047;
    omega = (2*pi*k)/2048;
    
    frek(1,1)=omega(find(bak1==max(bak1)));
    bak1(find(bak1==max(bak1)))=0;
    frek(1,2)=omega(find(bak1==max(bak1)));
    if(frek(1,1)>frek(1,2))
        c = frek(1,2);
    frek(1,2)=frek(1,1);
    frek(1,1) = c;
    end
    
    frek(2,1)=omega(find(bak2==max(bak2)));
    bak2(find(bak2==max(bak2)))=0;
    frek(2,2)=omega(find(bak2==max(bak2)));
    if(frek(2,1)>frek(2,2))
        c = frek(2,2);
    frek(2,2)=frek(2,1);
    frek(2,1) = c;
    end
    
    this code takes the signal you give and after decode it, output the numbers.

    This code is kuul because it can detect numbers from every 7 number dtmf signal.Tone and silence times are not important.

    Totally my work.

    enjoy it 😀

    (Ps:If you want to test the code, you can download test tones directly from #-Link-Snipped-# then just write
    load touch
    thats all, tones are ready to use at your enviroment)

    😁
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Kaustubh Katdare

    AdministratorJul 16, 2009

    Wow, this is awesome 😀
    Are you sure? This action cannot be undone.
    Cancel
  • Jojolucci

    MemberApr 26, 2014

    Hi,

    This code is very interesting. Can you tell me how you load your signal in the code? Also some explanations about it?
    😀
    Are you sure? This action cannot be undone.
    Cancel
  • Jojolucci

    MemberApr 26, 2014

    (My signal to add is a phone number sound.wav)
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register