annotate xtract/xtract_stateful.h @ 214:f28f66faa016

Add "stateful" feature type with initial feature "last n" Stateful feature extraction functions are functions that require state to be maintained between successive calls. This is necessary, for example when an accumulation of values is required, or changes need to be measured over time. The initial xtract_last_n() function accumulates the last N (single) values from *data and writes them to *result
author Jamie Bullock <jamie@jamiebullock.com>
date Tue, 03 Jun 2014 21:17:07 +0100
parents
children d13189c1005c
rev   line source
jamie@214 1 /*
jamie@214 2 * Copyright (C) 2012 Jamie Bullock
jamie@214 3 *
jamie@214 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
jamie@214 5 * of this software and associated documentation files (the "Software"), to
jamie@214 6 * deal in the Software without restriction, including without limitation the
jamie@214 7 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
jamie@214 8 * sell copies of the Software, and to permit persons to whom the Software is
jamie@214 9 * furnished to do so, subject to the following conditions:
jamie@214 10 *
jamie@214 11 * The above copyright notice and this permission notice shall be included in
jamie@214 12 * all copies or substantial portions of the Software.
jamie@214 13 *
jamie@214 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
jamie@214 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
jamie@214 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
jamie@214 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
jamie@214 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
jamie@214 19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
jamie@214 20 * IN THE SOFTWARE.
jamie@214 21 *
jamie@214 22 */
jamie@214 23
jamie@214 24 /** \file xtract_stateful.h: declares functions that extract features that require stateful data to be retained between frames */
jamie@214 25 #ifndef XTRACT_STATEFUL_H
jamie@214 26 #define XTRACT_STATEFUL_H
jamie@214 27
jamie@214 28 #ifdef __cplusplus
jamie@214 29 extern "C" {
jamie@214 30 #endif
jamie@214 31
jamie@214 32 /**
jamie@214 33 * \defgroup stateful feature extraction functions and data structures
jamie@214 34 *
jamie@214 35 * Functions that extract a feature over multiple frames
jamie@214 36 *
jamie@214 37 * @{
jamie@214 38 */
jamie@214 39
jamie@214 40
jamie@214 41 #include <stdint.h>
jamie@214 42 #include <string.h>
jamie@214 43
jamie@214 44 struct ringbuf_t;
jamie@214 45 typedef struct ringbuf_t *ringbuf_t;
jamie@214 46 typedef struct xtract_last_n_state_ xtract_last_n_state;
jamie@214 47
jamie@214 48 xtract_last_n_state *xtract_last_n_state_new(size_t capacity);
jamie@214 49 void xtract_last_n_state_delete(xtract_last_n_state *last_n_state);
jamie@214 50
jamie@214 51
jamie@214 52 /**
jamie@214 53 * Write a vector of the last N input values to `result`
jamie@214 54 *
jamie@214 55 * @param state a pointer to an xtract_peak_picker_state struct as allocated by xtract_peak_picker_state_new()
jamie@214 56 * @param data a pointer to a double representing the current input value
jamie@214 57 * @param N an integer representing 'N' the number of values to be written to *result
jamie@214 58 * @param argv a pointer to NULL
jamie@214 59 * @param result a pointer to an array of doubles representing the last N values, where the nth value is the current one. The array must have been allocated to size N elements and initialised by the caller
jamie@214 60 *
jamie@214 61 */
jamie@214 62 int xtract_last_n(const xtract_last_n_state *state, const double *data, const int N, const void *argv, double *result);
jamie@214 63
jamie@214 64
jamie@214 65
jamie@214 66
jamie@214 67 #endif