1 /*************************************************************************/
2 /*                                                                       */
3 /*                  Language Technologies Institute                      */
4 /*                     Carnegie Mellon University                        */
5 /*                        Copyright (c) 2001                             */
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 /*  CARNEGIE MELLON UNIVERSITY 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 CARNEGIE MELLON UNIVERSITY 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 /*             Author:  Alan W Black (awb@cs.cmu.edu)                    */
34 /*               Date:  August 2000                                      */
35 /*************************************************************************/
36 /*                                                                       */
37 /*  Waveforms                                                            */
38 /*                                                                       */
39 /*************************************************************************/
40 #include "cst_string.h"
41 #include "cst_val.h"
42 #include "cst_sts.h"
43 
CST_VAL_REGISTER_TYPE(lpcres,cst_lpcres)44 CST_VAL_REGISTER_TYPE(lpcres,cst_lpcres)
45 
46 cst_lpcres *new_lpcres()
47 {
48     cst_lpcres *l = cst_alloc(struct cst_lpcres_struct,1);
49     return l;
50 }
51 
delete_lpcres(cst_lpcres * l)52 void delete_lpcres(cst_lpcres *l)
53 {
54     if (l)
55     {
56 	cst_free(l->times);
57 	cst_free((unsigned short **)l->frames);
58 	cst_free(l->residual);
59 	cst_free(l->sizes);
60         if (l->delayed_decoding)
61             cst_free(l->packed_residuals);
62 	cst_free(l);
63     }
64     return;
65 }
66 
lpcres_frame_shift(cst_lpcres * t,int frame)67 float lpcres_frame_shift(cst_lpcres *t, int frame)
68 {
69     if (frame == 0)
70 	return (float) t->times[frame];
71     else
72 	return (float) t->times[frame]-t->times[frame-1];
73 }
74 
lpcres_resize_frames(cst_lpcres * l,int num_frames)75 void lpcres_resize_frames(cst_lpcres *l,int num_frames)
76 {
77     l->times = cst_alloc(int,num_frames);
78     l->frames = cst_alloc(const unsigned short*,num_frames);
79     l->sizes = cst_alloc(int,num_frames);
80     l->num_frames = num_frames;
81 }
82 
lpcres_resize_samples(cst_lpcres * l,int num_samples)83 void lpcres_resize_samples(cst_lpcres *l,int num_samples)
84 {
85     l->residual = cst_alloc(unsigned char,num_samples);
86     /* mulaw for 0 is 255 */
87     memset(l->residual,255,num_samples);
88     l->num_samples = num_samples;
89 
90 }
91