annotate xtract/xtract_helper.h @ 211:ef80f7c52c6d

add VC2012 project to compile static and dynamic lib, also fix some C issues
author Q <andrea@nocte.co.uk>
date Thu, 27 Mar 2014 09:48:26 +0000
parents baaa9d8b4d10
children 8c768f32a6a8
rev   line source
jamie@141 1 /*
jamie@141 2 * Copyright (C) 2012 Jamie Bullock
jamie@107 3 *
jamie@141 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
jamie@141 5 * of this software and associated documentation files (the "Software"), to
jamie@141 6 * deal in the Software without restriction, including without limitation the
jamie@141 7 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
jamie@141 8 * sell copies of the Software, and to permit persons to whom the Software is
jamie@141 9 * furnished to do so, subject to the following conditions:
jamie@107 10 *
jamie@141 11 * The above copyright notice and this permission notice shall be included in
jamie@141 12 * all copies or substantial portions of the Software.
jamie@107 13 *
jamie@141 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
jamie@141 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
jamie@141 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
jamie@141 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
jamie@141 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
jamie@141 19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
jamie@141 20 * IN THE SOFTWARE.
jamie@141 21 *
jamie@107 22 */
jamie@107 23
jamie@107 24 /** \file xtract_helper.h: helper functions for making life with libxtract a bit more bearable */
jamie@107 25
jamie@107 26 #ifndef XTRACT_HELPER_H
jamie@107 27 #define XTRACT_HELPER_H
jamie@107 28
jamie@107 29 #ifdef __cplusplus
jamie@107 30 extern "C" {
jamie@107 31 #endif
jamie@107 32
andrea@211 33 #ifdef _MSC_VER
andrea@211 34 #ifndef __cplusplus
andrea@211 35 typedef int bool;
andrea@211 36 #define false 0
andrea@211 37 #define true 1
andrea@211 38 #endif
andrea@211 39 #else
andrea@211 40 #include <stdbool.h>
andrea@211 41 #endif
andrea@211 42
jamie@140 43
jamie@107 44 /**
jamie@107 45 * \defgroup helper helper functions
jamie@107 46 *
jamie@107 47 * Declares helper functions, and their parameters.
jamie@107 48 *
jamie@107 49 * \note These functions don't necessarily conform to the prototype used in xtract_scalar.h and xtract_vector.h etc, and as such are intended to be called 'directly' rather than via the xtract[] function pointer array (libxtract.h)
jamie@107 50 *
jamie@107 51 * @{
jamie@107 52 */
jamie@107 53
jamie@107 54 /** \brief Apply a window function to an array of length N
jamie@107 55 *
jamie@146 56 * \param *data a pointer to an array of doubles
jamie@107 57 * \param N the number of elements in the array pointed to by *data
jamie@107 58 * \param *argv a pointer to a window function as returned by xtract_make_window()
jamie@107 59 * \param *result a pointer to the first element an array containing the windowed data
jamie@107 60 *
jamie@107 61 * It is up to the caller to generate and free the array containing the window, and to allocate and free memory of size N to hold the data pointed to by *result
jamie@107 62 *
jamie@107 63 */
jamie@146 64 int xtract_windowed(const double *data, const int N, const void *argv, double *result);
jamie@107 65
jamie@107 66 /** \brief Divides the array pointed to by *data into two subframes, and applies a given feature to each subframe, returning them in a single array pointed to by result
jamie@107 67 *
jamie@146 68 * \param *data an array of doubles
jamie@107 69 * \param N the number of elements in the array pointed by *data
jamie@107 70 * \param feature an integer representing the feature to be applied to each subframe in data. This will be a value as given in the enumeration xtract_features_ (libxtract.h)
jamie@107 71 * \param *argv a pointer to the argument vector to be passed to the feature extraction function as determined by feature
jamie@107 72 * \param *result a pointer to the 'packed' results of the feature calculation. This may be passed in as *data to xtract_features_from_subframes() to calculate further features on the subframes, or xtract_difference_vector(), to get the difference between the subframes.
jamie@107 73 *
jamie@108 74 *
jamie@108 75 * It is important to ensure that any _init_*() functions that are called in preparation for functions that are called on subframes are given the subframe size as 'N', and not the frame size. i.e. if xtract_features_from_subframes() is called with N=64, and feature=XTRACT_SPECTRUM, then xtract_init_fft() should be called with N=32.
jamie@108 76 *
jamie@107 77 */
jamie@146 78 int xtract_features_from_subframes(const double *data, const int N, const int feature, const void *argv, double *result);
jamie@107 79
jamie@113 80 /** \brief Test whether a number is denormal */
jamie@120 81 int xtract_is_denormal(double const d);
jamie@113 82
jamie@140 83 /** \brief Test whether a number is a power of two */
jamie@140 84 bool xtract_is_poweroftwo(unsigned int x);
jamie@140 85
jamie@107 86 /** @} */
jamie@107 87
jamie@107 88 #ifdef __cplusplus
jamie@107 89 }
jamie@107 90 #endif
jamie@107 91
jamie@107 92 #endif
jamie@107 93
jamie@107 94
jamie@107 95