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: January 2001 */
35/*************************************************************************/
36/* */
37/* Short term signals */
38/* */
39/*************************************************************************/
40#ifndef _CST_STS_H__
41#define _CST_STS_H__
42
43/* Need some lower level functions in case we are doing streaming */
44#include "cst_wave.h"
45#include "cst_audio.h"
46
47/* The short term signal (sts) structure is the basic unit data info */
48/* it may be diphones or general units. Indexes and names are held */
49/* else where, this information plus the indexes in the Unit relation */
50/* allow reconstruction of the signal itself */
51struct cst_sts_struct {
52 const unsigned short *frame;
53 const int size; /* in samples */
54 const unsigned char *residual;
55};
56typedef struct cst_sts_struct cst_sts;
57
58/* Because many C compilers can't compile when there are 100Ks of symbols */
59/* We store the sts in pages. Each page of stss gets compiled into an */
60/* array in separate files thus reducing the number of symbols -- but */
61/* introducing an extra dereference */
62struct cst_sts_paged_struct {
63 /* const unsigned short frame_offset; */
64 const unsigned int frame_offset;
65 const unsigned short res_size;
66 const unsigned int res_offset;
67 const unsigned short *frame_page;
68 const unsigned char *res_page;
69};
70typedef struct cst_sts_paged_struct cst_sts_paged;
71
72/* This represents a database of short-term signals. */
73struct cst_sts_list_struct {
74 /* If the sts are compiled in, this will point to them. */
75 const cst_sts *sts;
76 /* Or if the data is paged in different structures */
77 const cst_sts_paged *sts_paged;
78 /* Or we could have these set (or set later) */
79 const unsigned short *frames;
80 const unsigned char *residuals;
81 const unsigned int *resoffs;
82 const unsigned char *ressizes;
83
84 int num_sts; /* But I don't think you need that number */
85 int num_channels; /* typically lpc order */
86 int sample_rate;
87 float coeff_min; /* used for decoding the short representation */
88 float coeff_range; /* for coefficients */
89
90 const char *codec; /* encoding type for residual */
91};
92typedef struct cst_sts_list_struct cst_sts_list;
93
94/* This is used to represent a newly constructed waveform to be synthed */
95struct cst_lpcres_struct {
96 const unsigned short **frames;
97 int *times;
98 int num_frames;
99 int num_channels;
100 float lpc_min;
101 float lpc_range;
102 int num_samples;
103 int sample_rate;
104 int *sizes;
105 unsigned char *residual;
106
107 /* Optional call back function */
108 cst_audio_streaming_info *asi;
109
110 /* Expensive decoding can be delayed until resynthesis, hence */
111 /* streaming will be more useful as the decoding will happen */
112 /* during playback time */
113 const unsigned char **packed_residuals;
114 int delayed_decoding; /* 1 if decoding happens at streaming time */
115};
116typedef struct cst_lpcres_struct cst_lpcres;
117
118cst_lpcres *new_lpcres();
119void delete_lpcres(cst_lpcres *l);
120float lpcres_frame_shift(cst_lpcres *t, int frame);
121void lpcres_resize_frames(cst_lpcres *l,int num_frames);
122void lpcres_resize_samples(cst_lpcres *l,int num_samples);
123
124cst_sts_list *new_sts_list();
125void delete_sts_list(cst_sts_list *l);
126
127const unsigned short * get_sts_frame(const cst_sts_list *sts_list, int frame);
128const unsigned char * get_sts_residual(const cst_sts_list *sts_list, int frame);
129const unsigned char * get_sts_residual_fixed(const cst_sts_list *sts_list, int frame);
130
131int get_frame_size(const cst_sts_list *sts_list, int frame);
132int get_unit_size(const cst_sts_list *s,int start, int end);
133
134CST_VAL_USER_TYPE_DCLS(lpcres,cst_lpcres)
135CST_VAL_USER_TYPE_DCLS(sts_list,cst_sts_list)
136
137#endif
138

source code of include/flite/cst_sts.h