1 /*
2 mediastreamer2 library - modular sound and video processing and streaming
3 Copyright (C) 2014  Belledonne Communications SARL
4 
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18 */
19 
20 #ifndef msutils_h
21 #define msutils_h
22 
23 #include "mediastreamer2/mscommon.h"
24 
25 
26 #ifdef __cplusplus
27 extern "C"{
28 #endif
29 
30 typedef void (*MSAudioDiffProgressNotify)(void* user_data, int percentage);
31 
32 typedef struct _MSAudioDiffParams{
33 	int max_shift_percent; /*percentage of overlap between the two signals, used to restrict the cross correlation around t=0 in range [1 ; 100].*/
34 	int chunk_size_ms; /*chunk size in milliseconds, if chunked cross correlation is to be used. Use 0 otherwise.*/
35 }MSAudioDiffParams;
36 
37 
38 /**
39  * Utility that compares two PCM 16 bits audio files and returns a similarity factor between 0 and 1.
40  * @param ref_file path to a wav file contaning the reference audio segment
41  * @param matched_file path to a wav file contaning the audio segment where the reference file is to be matched.
42  * @param ret the similarity factor, set in return
43  * @param max_shift_percent percentage of overlap between the two signals, used to restrict the cross correlation around t=0 in range [1 ; 100].
44  * @param func a callback called to show progress of the operation
45  * @param user_data a user data passed to the callback when invoked.
46  * @return -1 on error, 0 if succesful.
47 **/
48 MS2_PUBLIC int ms_audio_diff(const char *ref_file, const char *matched_file, double *ret, const MSAudioDiffParams *params, MSAudioDiffProgressNotify func, void *user_data);
49 
50 #ifdef __cplusplus
51 }
52 #endif
53 
54 #endif
55 
56