-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathexample.cpp
72 lines (61 loc) · 1.77 KB
/
example.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/** Author: Plyashkevich Viatcheslav <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* All rights reserved.
*/
#include <stdio.h>
#include "DtmfDetector.hpp"
#include "DtmfGenerator.hpp"
const unsigned FRAME_SIZE = 160;
char dialButtons[16];
short int samples[100000];
DtmfDetector dtmfDetector(FRAME_SIZE);
DtmfGenerator dtmfGenerator(FRAME_SIZE, 40, 20);
int main()
{
dialButtons[0] = '1';
dialButtons[1] = '2';
dialButtons[2] = '3';
dialButtons[3] = 'A';
dialButtons[4] = '4';
dialButtons[5] = '5';
dialButtons[6] = '6';
dialButtons[7] = 'B';
dialButtons[8] = '7';
dialButtons[9] = '8';
dialButtons[10] = '9';
dialButtons[11] = 'C';
dialButtons[12] = '*';
dialButtons[13] = '0';
dialButtons[14] = '#';
dialButtons[15] = 'D';
while(true)
{
static int framenumber = 0;
++framenumber;
dtmfGenerator.dtmfGeneratorReset();
dtmfDetector.zerosIndexDialButton();
dtmfGenerator.transmitNewDialButtonsArray(dialButtons, 16);
while(!dtmfGenerator.getReadyFlag())
{
dtmfGenerator.dtmfGenerating(samples); // Generating of a 16 bit's little-endian's pcm samples array
dtmfDetector.dtmfDetecting(samples); // Detecting from 16 bit's little-endian's pcm samples array
}
if(dtmfDetector.getIndexDialButtons() != 16)
{
printf("Error of a number of detecting buttons \n");
continue;
}
for(int ii = 0; ii < dtmfDetector.getIndexDialButtons(); ++ii)
{
if(dtmfDetector.getDialButtonsArray()[ii] != dialButtons[ii])
{
printf("Error of a detecting button \n");
continue;
}
}
printf("Success in frame: %d \n", framenumber);
}
return 0;
}