comparison src/scalar.c @ 161:246c203cc733

Add wavelet-based pitch tracker
author Jamie Bullock <jamie@jamiebullock.com>
date Fri, 31 May 2013 22:44:03 +0100
parents 71870680f7c1
children 5c20a9a34f0c
comparison
equal deleted inserted replaced
160:f7d0b6607193 161:246c203cc733
26 #include <stdlib.h> 26 #include <stdlib.h>
27 #include <string.h> 27 #include <string.h>
28 #include <stdio.h> 28 #include <stdio.h>
29 #include <math.h> 29 #include <math.h>
30 30
31 #include "../xtract/libxtract.h" 31 #include "dywapitchtrack/dywapitchtrack.h"
32 #include "../xtract/xtract_helper.h" 32
33 #include "xtract/libxtract.h"
34 #include "xtract/xtract_helper.h"
33 #include "xtract_macros_private.h" 35 #include "xtract_macros_private.h"
36 #include "xtract_globals_private.h"
34 37
35 int xtract_mean(const double *data, const int N, const void *argv, double *result) 38 int xtract_mean(const double *data, const int N, const void *argv, double *result)
36 { 39 {
37 40
38 int n = N; 41 int n = N;
951 954
952 return_code = xtract_f0(data, N, argv, result); 955 return_code = xtract_f0(data, N, argv, result);
953 956
954 if(return_code == XTRACT_NO_RESULT) 957 if(return_code == XTRACT_NO_RESULT)
955 { 958 {
956
957 sr = *(double *)argv; 959 sr = *(double *)argv;
958 if(sr == 0) 960 if(sr == 0)
959 sr = 44100.0; 961 sr = 44100.0;
960 spectrum = (double *)malloc(N * sizeof(double)); 962 spectrum = (double *)malloc(N * sizeof(double));
961 peaks = (double *)malloc(N * sizeof(double)); 963 peaks = (double *)malloc(N * sizeof(double));
973 975
974 return XTRACT_SUCCESS; 976 return XTRACT_SUCCESS;
975 977
976 } 978 }
977 979
980 int xtract_wavelet_f0(const double *data, const int N, const void *argv, double *result)
981 {
982 double sr = *(double *)argv;
983
984 *result = dywapitch_computepitch(&wavelet_f0_state, data, 0, N);
985
986 if (*result == 0.0)
987 {
988 return XTRACT_NO_RESULT;
989 }
990
991 return XTRACT_SUCCESS;
992 }
993
994