annotate src/delta.c @ 108:e6354b0137d3

- PD example brought in line with new delta features and subframe function - subframe-test.pd added - fix to a_blockswap~.pd
author Jamie Bullock <jamie@postlude.co.uk>
date Sat, 29 Dec 2007 17:33:17 +0000
parents 3e648eec95cb
children c7e1fe63eedb
rev   line source
jamie@1 1 /* libxtract feature extraction library
jamie@1 2 *
jamie@1 3 * Copyright (C) 2006 Jamie Bullock
jamie@1 4 *
jamie@1 5 * This program is free software; you can redistribute it and/or modify
jamie@1 6 * it under the terms of the GNU General Public License as published by
jamie@1 7 * the Free Software Foundation; either version 2 of the License, or
jamie@1 8 * (at your option) any later version.
jamie@1 9 *
jamie@1 10 * This program is distributed in the hope that it will be useful,
jamie@1 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
jamie@1 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
jamie@1 13 * GNU General Public License for more details.
jamie@1 14 *
jamie@1 15 * You should have received a copy of the GNU General Public License
jamie@1 16 * along with this program; if not, write to the Free Software
jamie@1 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
jamie@1 18 * USA.
jamie@1 19 */
jamie@1 20
jamie@1 21 /* xtract_delta.c: defines functions that extract a feature as a single value from more than one input vector */
jamie@1 22
jamie@106 23 #include <math.h>
jamie@106 24
jamie@38 25 #include "xtract/libxtract.h"
jamie@1 26
jamie@43 27 int xtract_flux(const float *data, const int N, const void *argv , float *result){
jamie@1 28
jamie@106 29 return xtract_lnorm(data, N, argv, result);
jamie@105 30
jamie@106 31 }
jamie@106 32
jamie@106 33 int xtract_lnorm(const float *data, const int N, const void *argv , float *result){
jamie@106 34
jamie@107 35 int n,
jamie@106 36 type;
jamie@106 37
jamie@106 38 float order,
jamie@106 39 temp = 0.f;
jamie@106 40
jamie@106 41 order = *(float *)argv;
jamie@106 42 type = (int)*(float *)argv+1;
jamie@106 43
jamie@108 44 order = order > 0 ? order : 2.f;
jamie@106 45
jamie@106 46 switch(type){
jamie@106 47
jamie@106 48 case XTRACT_POSITIVE_SLOPE:
jamie@106 49 for(n = 0; n < N; n++){
jamie@106 50 temp = powf(data[n], order);
jamie@106 51 if(data[n] > 0)
jamie@106 52 *result += temp;
jamie@106 53 }
jamie@106 54 break;
jamie@106 55 default:
jamie@106 56 for(n = 0; n < N; n++)
jamie@106 57 *result += powf(data[n], order);
jamie@106 58 break;
jamie@106 59
jamie@106 60 }
jamie@106 61
jamie@106 62 *result = powf(*result, 1.f / order);
jamie@106 63
jamie@106 64 return XTRACT_SUCCESS;
jamie@1 65
jamie@1 66 }
jamie@1 67
jamie@43 68 int xtract_attack_time(const float *data, const int N, const void *argv , float *result){
jamie@1 69
jamie@56 70 return XTRACT_FEATURE_NOT_IMPLEMENTED;
jamie@1 71
jamie@1 72 }
jamie@1 73
jamie@43 74 int xtract_decay_time(const float *data, const int N, const void *argv, float *result){
jamie@1 75
jamie@56 76 return XTRACT_FEATURE_NOT_IMPLEMENTED;
jamie@1 77
jamie@1 78 }
jamie@1 79
jamie@106 80 int xtract_difference_vector(const float *data, const int N, const void *argv, float *result){
jamie@1 81
jamie@107 82 const float *frame1,
jamie@106 83 *frame2;
jamie@106 84
jamie@106 85 int n;
jamie@106 86
jamie@106 87 n = N >> 1;
jamie@106 88
jamie@106 89 frame1 = data;
jamie@106 90 frame2 = data + n;
jamie@106 91
jamie@106 92 while(n--)
jamie@106 93 result[n] = frame1[n] - frame2[n];
jamie@106 94
jamie@106 95 return XTRACT_SUCCESS;
jamie@1 96
jamie@1 97 }