1 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
3 * Copyright (c) 2008 Beyond Access, Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
17 * THIS SOFTWARE IS PROVIDED BY BEYOND ACCESS, INC. ``AS IS'' AND ANY
18 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BEYOND ACCESS, INC. NOR
21 * ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 * @brief Implementation of pitch estimation
33 * @author David Huggins-Daines <dhuggins@cs.cmu.edu>
35 * This implements part of the YIN algorithm:
37 * "YIN, a fundamental frequency estimator for speech and music".
38 * Alain de Cheveigné and Hideki Kawahara. Journal of the Acoustical
39 * Society of America, 111 (4), April 2002.
52 /* Win32/WinCE DLL gunk */
53 #include <sphinxbase/sphinxbase_export.h>
54 #include <sphinxbase/prim_type.h>
57 * Frame-based moving-window pitch estimator.
59 typedef struct yin_s yin_t;
62 * Initialize moving-window pitch estimation.
65 yin_t *yin_init(int frame_size, float search_threshold,
66 float search_range, int smooth_window);
69 * Free a moving-window pitch estimator.
72 void yin_free(yin_t *pe);
75 * Start processing an utterance.
78 void yin_start(yin_t *pe);
81 * Mark the end of an utterance.
84 void yin_end(yin_t *pe);
87 * Feed a frame of data to the pitch estimator.
89 * @param pe Pitch estimator.
90 * @param frame Frame of <code>frame_size</code> (see
91 * yin_init()) samples of audio data.
94 void yin_write(yin_t *pe, int16 const *frame);
97 * Read a raw estimated pitch value from the pitch estimator.
99 * @param pe Pitch estimator.
100 * @param out_period Output: an estimate of the period (*not* the pitch)
101 * of the signal in samples.
102 * @param out_bestdiff Output: the minimum normalized difference value
103 * associated with <code>*out_pitch</code>, in Q15
104 * format (i.e. scaled by 32768). This can be
105 * interpreted as one minus the probability of voicing.
106 * @return Non-zero if enough data was avaliable to return a pitch
107 * estimate, zero otherwise.
110 int yin_read(yin_t *pe, uint16 *out_period, uint16 *out_bestdiff);
116 #endif /* __YIN_H__ */