-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
61 lines (49 loc) · 1.36 KB
/
main.c
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
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <pthread.h>
#include <semaphore.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include "sample_pcm.h"
#include "get_features.h"
int sample_flag = 0;
int get_sample_offset = 0;
/*Thread function : Get PCM data*/
void *get_sample_audio(void *arg){
get_sample_pcm(&sample_flag);
}
/*Thread function : Compare the raw audio and sample audio*/
void *process_audio(void *arg){
char *raw_audio_path = "./voice-8000hz-16bit-mono.pcm";
char *sample_audio_path = "./sample_test.pcm";
int fd;
FTUS raw_features;
FTUS sample_features;
get_audio_features(raw_audio_path, &raw_features, 0, 0);
while(1){
if(sample_flag == 1){
get_audio_features(sample_audio_path, &sample_features, &get_sample_offset, &sample_flag);
sample_flag = 0;
printf("result : %d \n", compare_raw_sample(&raw_features, &sample_features));
}
}
}
int main(int argc,char *argv[])
{
pthread_t ntid_get_sample, ntid_process_audio;
int net = -1;
net = pthread_create(&ntid_get_sample, NULL, get_sample_audio, NULL);
if(net < 0){
printf("Can't create thread: %s!\r\n", strerror(net));
}
net = pthread_create(&ntid_process_audio, NULL, process_audio, NULL);
if(net < 0){
printf("Can't create thread: %s!\r\n", strerror(net));
}
while(1) ;
return 0;
}