Edinburgh Speech Tools  2.4-release
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Pages
EST_pitchmark.h
1 /*************************************************************************/
2 /* */
3 /* Centre for Speech Technology Research */
4 /* University of Edinburgh, UK */
5 /* Copyright (c) 1995,1996 */
6 /* All Rights Reserved. */
7 /* */
8 /* Permission is hereby granted, free of charge, to use and distribute */
9 /* this software and its documentation without restriction, including */
10 /* without limitation the rights to use, copy, modify, merge, publish, */
11 /* distribute, sublicense, and/or sell copies of this work, and to */
12 /* permit persons to whom this work is furnished to do so, subject to */
13 /* the following conditions: */
14 /* 1. The code must retain the above copyright notice, this list of */
15 /* conditions and the following disclaimer. */
16 /* 2. Any modifications must be clearly marked as such. */
17 /* 3. Original authors' names are not deleted. */
18 /* 4. The authors' names are not used to endorse or promote products */
19 /* derived from this software without specific prior written */
20 /* permission. */
21 /* */
22 /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
23 /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
24 /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
25 /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
26 /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
27 /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
28 /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
29 /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
30 /* THIS SOFTWARE. */
31 /* */
32 /*************************************************************************/
33 
34 #ifndef __EST_PITCHMARK_H__
35 #define __EST_PITCHMARK_H__
36 
37 #include "EST_Wave.h"
38 #include "EST_Option.h"
39 #include "EST_Track.h"
40 #include "EST_TBuffer.h"
41 
42 #define LX_LOW_FREQUENCY 400
43 #define LX_LOW_ORDER 19
44 #define LX_HIGH_FREQUENCY 40
45 #define LX_HIGH_ORDER 19
46 #define DF_LOW_FREQUENCY 1000
47 #define DF_LOW_ORDER 19
48 #define MIN_PERIOD 0.003
49 #define MAX_PERIOD 0.02
50 #define DEF_PERIOD 0.01
51 #define PM_END -1.0
52 
53 /** @name Pitchmarking Functions
54 
55 Pitchmarking involves finding some pre-defined pitch related instant
56 for every pitch period in the speech. At present, only functions for
57 analysing laryngograph waveforms are available - the much harder
58 problem of doing this on actual speech has not been attempted.
59 
60  */
61 //@{
62 
63 /** Find pitchmarks in Laryngograph (lx) signal.
64 
65 This high level function places a pitchmark on each positive peak in
66 the voiced portions of the lx signal. Pitchmarks are stored in the
67 time component of a EST_Track object and returned. The function works
68 by high and low pass filtering the signal using forward and backward
69 filtering to remove phase shift. The negative going points in the
70 smoothed differentiated signal, corresponding to peaks in the original
71 are then chosen.
72 
73 @param lx laryngograph waveform
74 @param op options, mainly for filter control:
75 \begin{itemize}
76 \item {\bf lx_low_frequency} low pass cut off for lx filtering : typical value {\tt 400}
77 \item {\bf lx_low_order} order of low pass lx filter: typical value 19
78 \item {\bf lx_high_frequency} high pass cut off for lx filtering: typical value 40
79 \item {\bf lx_high_order} order of high pass lx filter: typical value 19
80 \item {\bf median_order} order of high pass lx filter: typical value 19
81 \end{itemize}
82 */
83 
84 EST_Track pitchmark(EST_Wave &lx, EST_Features &op);
85 
86 /** Find pitchmarks in Laryngograph (lx) signal. The function is the
87 same as \Ref{pitchmark} but with more explicit control over
88 the parameters.
89 
90 @param lx laryngograph waveform
91 @param lx_lf low pass cut off for lx filtering : typical value 400
92 @param lx_fo order of low pass lx filter : typical value 19
93 @param lx_hf high pass cut off for lx filtering : typical value 40
94 @param lx_ho : typical value 19
95 @param mo order of median smoother used to smoother differentiated lx : typical value 19
96 
97 */
98 
99 EST_Track pitchmark(EST_Wave &lx, int lx_lf, int lx_lo, int lx_hf,
100  int lx_ho, int df_lf, int df_lo, int mo, int debug=0);
101 
102 
103 /** Find times where waveform cross zero axis in negative direction.
104 
105 @param sig waveform
106 @param pm pitchmark track which stores time positions of negative crossings
107 */
108 
109 void neg_zero_cross_pick(EST_Wave &lx, EST_Track &pm);
110 
111 /** Produce a set of sensible pitchmarks.
112 
113 Given a set of raw pitchmarks, this function makes sure no pitch
114 period is shorter that {\tt min} seconds and no longer than {\tt max}
115 seconds. Periods that are too short are eliminated. If a period is too
116 long, extra pitchmarks are inserted whose period is {\it
117 approximately} {\tt def} seconds in duration. The approximation is to
118 ensure that the pitch period in the interval, D, is constant, and so
119 the actual pitch period is given by \[T = D / floor(D/def)\] */
120 
121 void pm_fill(EST_Track &pm, float new_end, float max, float min, float def);
122 
123 /** Remove pitchmarks which are too close together.
124 
125 This doesn't work in a particularly sophisticated way, in that it
126 removes a sequence of too close pitchmarks left to right, and doesn't
127 attempt to find which ones in the sequence are actually spurious. */
128 
129 void pm_min_check(EST_Track &pm, float min);
130 
131 
132 void pm_to_f0(EST_Track &pm, EST_Track &f0);
133 
134 // for constant shift pitchmarks
135 void pm_to_f0(EST_Track &pm, EST_Track &fz, float shift);
136 
137 
138 //@}
139 
140 #endif /* __EST_PITCHMARK_H__ */
141 
142 
143 //@}