Edinburgh Speech Tools  2.1-release
EST_pitchmark.h
Go to the documentation of this file.
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 /** @defgroup PitchmarkingFunctions Pitchmarking Functions
54  @ingroup FunctionsForGeneratingTracks
55 
56 Pitchmarking involves finding some pre-defined pitch related instant
57 for every pitch period in the speech. At present, only functions for
58 analysing laryngograph waveforms are available - the much harder
59 problem of doing this on actual speech has not been attempted.
60 
61  */
62 ///@{
63 
64 /** Find pitchmarks in Laryngograph (lx) signal.
65 
66 This high level function places a pitchmark on each positive peak in
67 the voiced portions of the lx signal. Pitchmarks are stored in the
68 time component of a EST_Track object and returned. The function works
69 by high and low pass filtering the signal using forward and backward
70 filtering to remove phase shift. The negative going points in the
71 smoothed differentiated signal, corresponding to peaks in the original
72 are then chosen.
73 
74 @param lx laryngograph waveform
75 @param op {options, mainly for filter control:
76  - **lx_low_frequency** low pass cut off for lx filtering : typical value `400`
77  - **lx_low_order** order of low pass lx filter: typical value 19
78  - **lx_high_frequency** high pass cut off for lx filtering: typical value 40
79  - **lx_high_order** order of high pass lx filter: typical value 19
80  - **median_order** order of high pass lx filter: typical value 19
81  }
82 */
84 
85 /** Find pitchmarks in Laryngograph (lx) signal. The function is the
86 same as \ref pitchmark but with more explicit control over
87 the parameters.
88 
89 @param lx laryngograph waveform
90 @param lx_lf low pass cut off for lx filtering : typical value 400
91 @param lx_fo order of low pass lx filter : typical value 19
92 @param lx_hf high pass cut off for lx filtering : typical value 40
93 @param lx_ho : typical value 19
94 @param mo order of median smoother used to smoother differentiated lx : typical value 19
95 
96 */
97 EST_Track pitchmark(EST_Wave &lx, int lx_lf, int lx_lo, int lx_hf,
98  int lx_ho, int df_lf, int df_lo, int mo, int debug=0);
99 
100 
101 /** Find times where waveform cross zero axis in negative direction.
102 
103 @param sig waveform
104 @param pm pitchmark track which stores time positions of negative crossings
105 */
106 void neg_zero_cross_pick(EST_Wave &lx, EST_Track &pm);
107 
108 /** Produce a set of sensible pitchmarks.
109 
110 Given a set of raw pitchmarks, this function makes sure no pitch
111 period is shorter that `min` seconds and no longer than `max`
112 seconds. Periods that are too short are eliminated. If a period is too
113 long, extra pitchmarks are inserted whose period is {\it
114 approximately} `def` seconds in duration. The approximation is to
115 ensure that the pitch period in the interval, D, is constant, and so
116 the actual pitch period is given by \f[T = D / floor(D/def)\f] */
117 void pm_fill(EST_Track &pm, float new_end, float max, float min, float def);
118 
119 /** Remove pitchmarks which are too close together.
120 
121 This doesn't work in a particularly sophisticated way, in that it
122 removes a sequence of too close pitchmarks left to right, and doesn't
123 attempt to find which ones in the sequence are actually spurious. */
124 void pm_min_check(EST_Track &pm, float min);
125 
126 
127 void pm_to_f0(EST_Track &pm, EST_Track &f0);
128 
129 // for constant shift pitchmarks
130 void pm_to_f0(EST_Track &pm, EST_Track &fz, float shift);
131 
132 
133 ///@}
134 
135 #endif /* __EST_PITCHMARK_H__ */
A class for storing digital waveforms. The waveform is stored as an array of 16 bit shorts...
Definition: EST_Wave.h:64
void pm_fill(EST_Track &pm, float new_end, float max, float min, float def)
Definition: pitchmark.cc:154
void pm_min_check(EST_Track &pm, float min)
Definition: pitchmark.cc:138
float max(float a, float b)
Definition: EST_cluster.cc:143
void pm_to_f0(EST_Track &pm, EST_Track &f0)
Definition: pitchmark.cc:261
float min(float a, float b)
Definition: EST_cluster.cc:138
EST_Track pitchmark(EST_Wave &lx, EST_Features &op)
Definition: pitchmark.cc:105
void neg_zero_cross_pick(EST_Wave &lx, EST_Track &pm)
Definition: pitchmark.cc:233