andrew@0: /* andrew@0: Copyright (C) 2006 Paul Brossier andrew@0: andrew@0: This program is free software; you can redistribute it and/or modify andrew@0: it under the terms of the GNU General Public License as published by andrew@0: the Free Software Foundation; either version 2 of the License, or andrew@0: (at your option) any later version. andrew@0: andrew@0: This program is distributed in the hope that it will be useful, andrew@0: but WITHOUT ANY WARRANTY; without even the implied warranty of andrew@0: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the andrew@0: GNU General Public License for more details. andrew@0: andrew@0: You should have received a copy of the GNU General Public License andrew@0: along with this program; if not, write to the Free Software andrew@0: Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. andrew@0: andrew@0: */ andrew@0: andrew@0: /** \file andrew@0: andrew@0: Onset detection driver andrew@0: andrew@0: The following routines compute the onset detection function and detect peaks andrew@0: in these functions. When onsets are found above a given silence threshold, andrew@0: and after a minimum inter-onset interval, the output vector returned by andrew@0: aubio_onset is filled with 1. Otherwise, the output vector remains 0. andrew@0: andrew@0: The peak-picking threshold, the silence threshold, and the minimum andrew@0: inter-onset interval can be adjusted during the execution of the aubio_onset andrew@0: routine using the corresponding functions. andrew@0: andrew@0: */ andrew@0: andrew@0: andrew@0: #ifndef ONSET_H andrew@0: #define ONSET_H andrew@0: andrew@0: #ifdef __cplusplus andrew@0: extern "C" { andrew@0: #endif andrew@0: andrew@0: /** onset detection object */ andrew@0: typedef struct _aubio_onset_t aubio_onset_t; andrew@0: andrew@0: /** create onset detection object andrew@0: andrew@0: \param type_onset onset detection type as specified in onsetdetection.h andrew@0: \param buf_size buffer size for phase vocoder andrew@0: \param hop_size hop size for phase vocoder andrew@0: \param channels number of channels andrew@0: andrew@0: */ andrew@0: aubio_onset_t * new_aubio_onset (aubio_onsetdetection_type type_onset, andrew@0: ba_uint_t buf_size, ba_uint_t hop_size, ba_uint_t channels); andrew@0: andrew@0: /** execute onset detection andrew@0: andrew@0: \param o onset detection object as returned by new_aubio_onset andrew@0: \param input new audio vector of length hop_size andrew@0: \param onset output vector, 1 if onset is found, 0 otherwise andrew@0: andrew@0: */ andrew@0: void aubio_onset(aubio_onset_t *o, fvec_t * input, fvec_t * onset); andrew@0: andrew@0: /** set onset detection silence threshold andrew@0: andrew@0: \param o onset detection object as returned by new_aubio_onset andrew@0: \param silence new silence detection threshold andrew@0: andrew@0: */ andrew@0: void aubio_onset_set_silence(aubio_onset_t * o, smpl_t silence); andrew@0: andrew@0: /** set onset detection peak picking threshold andrew@0: andrew@0: \param o onset detection object as returned by new_aubio_onset andrew@0: \param threshold new peak-picking threshold andrew@0: andrew@0: */ andrew@0: void aubio_onset_set_threshold(aubio_onset_t * o, smpl_t threshold); andrew@0: andrew@0: /** set minimum inter onset interval andrew@0: andrew@0: \param o onset detection object as returned by new_aubio_onset andrew@0: \param minioi minimum number of frames between onsets (in multiple of andrew@0: hop_size/samplerare) andrew@0: andrew@0: */ andrew@0: void aubio_onset_set_minioi(aubio_onset_t * o, ba_uint_t minioi); andrew@0: andrew@0: /** delete onset detection object andrew@0: andrew@0: \param o onset detection object to delete andrew@0: andrew@0: */ andrew@0: void del_aubio_onset(aubio_onset_t * o); andrew@0: andrew@0: #ifdef __cplusplus andrew@0: } andrew@0: #endif andrew@0: andrew@0: #endif /* ONSET_H */