goertzel_dtmf.c

Using the Goertzel algorithm to analyze DTMF signals.This program performs generating of 16 DTMF signals. Then there is performed calculating of DFT spectrum samples which correspond to DTMF tone frequencies by means of the Goertzel algorithm.

DTMF signals and amplitude values of DFT spectrum samples are saved as text files to plot charts.

As a result of running the program, 16 files of DTMF signal in time domain and 16 files which hold spectrum sample amplitudes corresponding to DTMF frequencies will be created in the 'dat' directory.

File of DTMF signal in time | File of spectrum sample amplitudes | symbol |
---|---|---|

`sym_0_time.txt` | `sym_0_freq.txt` | `[0]` |

`sym_1_time.txt` | `sym_1_freq.txt` | `[1]` |

`sym_2_time.txt` | `sym_2_freq.txt` | `[2]` |

`sym_3_time.txt` | `sym_3_freq.txt` | `[3]` |

`sym_4_time.txt` | `sym_4_freq.txt` | `[4]` |

`sym_5_time.txt` | `sym_5_freq.txt` | `[5]` |

`sym_6_time.txt` | `sym_6_freq.txt` | `[6]` |

`sym_7_time.txt` | `sym_7_freq.txt` | `[7]` |

`sym_8_time.txt` | `sym_8_freq.txt` | `[8]` |

`sym_9_time.txt` | `sym_9_freq.txt` | `[9]` |

`sym_a_time.txt` | `sym_a_freq.txt` | `[a]` |

`sym_b_time.txt` | `sym_b_freq.txt` | `[b]` |

`sym_c_time.txt` | `sym_c_freq.txt` | `[c]` |

`sym_d_time.txt` | `sym_d_freq.txt` | `[d]` |

`sym_s_time.txt` | `sym_s_freq.txt` | `[*]` |

`sym_r_time.txt` | `sym_r_freq.txt` | `[\#]` |

DTMF signals kn time domainan and spectrum sample amplitudes corresponding to DTMF frequencies got as a result of the program operation can be plotted in charts:

#include <stdio.h>

#include <stdlib.h>

#include <windows.h>

#include "dspl.h"

/* DFT size */

#define N 205

/* sample rate */

#define FS 8000

int main()

{

HINSTANCE hDSPL; /* dspl handle */

/* DTMF frequency vector */

double frq[8] = {697, 770, 852, 941, 1209, 1336, 1477, 1633};

/* DTMF DFT indexes (N = 205) */

int ind[8] = {18, 20, 22, 24, 31, 34, 38, 42};

char sym[16] = "123a456b789cs0rd";

char fn[24];

double t[N]; /* time */

double s[N]; /* DTMF signal */

double SR[8]; /* DFT image part */

double SI[8];

double S[8]; /* Spectrum magnitude */

int n, m, k;

/* Load dspl.dll */

hDSPL = dspl_load();

if(!hDSPL)

{

printf("dspl.dll loading ERROR!\n");

return 0;

}

for(n = 0; n < N; n++)

t[n] = (double)n/FS;

for(k = 0; k < 4; k++)

{

for(m = 0; m < 4; m++)

{

for(n = 0; n < N; n++)

s[n] = sin(M_2PI * frq[k] * t[n]) +

sin(M_2PI * frq[m+4] * t[n]);

dspl_goertzel(s, NULL, N, ind, 8, SR, SI);

for(n = 0; n < 8; n++)

S[n] = sqrt(SR[n]*SR[n] + SI[n]*SI[n]);

sprintf(fn, "dat/dtmf_sym_%c_time.txt", sym[k*4+m]);

dspl_writetxt(t, s, 201, fn);

sprintf(fn, "dat/dtmf_sym_%c_freq.txt", sym[k*4+m]);

dspl_writetxt(frq, S, 8, fn);

}

}

/* clear dspl handle */

FreeLibrary(hDSPL);

return 0;

}

Generated on Sat Mar 11 2017 12:37:50 for DSPL - Digital signal processing library by 1.8.13