本文整理汇总了C++中HTS_free函数的典型用法代码示例。如果您正苦于以下问题:C++ HTS_free函数的具体用法?C++ HTS_free怎么用?C++ HTS_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HTS_free函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HTS_Audio_close
/* HTS_Audio_close: close audio device */
static void HTS_Audio_close(HTS_Audio * audio)
{
MMRESULT error;
if (audio->max_buff_size <= 0)
return;
/* stop audio */
error = waveOutReset(audio->hwaveout);
if (error != MMSYSERR_NOERROR)
HTS_error(0, "hts_engine: Cannot stop and reset your output audio device.\n");
/* unprepare */
error = waveOutUnprepareHeader(audio->hwaveout, &(audio->buff_1), sizeof(WAVEHDR));
if (error != MMSYSERR_NOERROR)
HTS_error(0, "hts_engine: Cannot cleanup the audio datablocks to play waveform.\n");
error = waveOutUnprepareHeader(audio->hwaveout, &(audio->buff_2), sizeof(WAVEHDR));
if (error != MMSYSERR_NOERROR)
HTS_error(0, "hts_engine: Cannot cleanup the audio datablocks to play waveform.\n");
/* close */
error = waveOutClose(audio->hwaveout);
if (error != MMSYSERR_NOERROR)
HTS_error(0, "hts_engine: Failed to close your output audio device.\n");
HTS_free(audio->buff_1.lpData);
HTS_free(audio->buff_2.lpData);
HTS_free(audio->buff);
}
示例2: HTS_Engine_load_gv_from_fn
/* HTS_Engine_load_gv_from_fn: load GV pdfs and trees from file names */
void HTS_Engine_load_gv_from_fn(HTS_Engine * engine, char **pdf_fn,
char **tree_fn, int stream_index,
int interpolation_size)
{
int i;
FILE **pdf_fp, **tree_fp;
pdf_fp = (FILE **) HTS_calloc(interpolation_size, sizeof(FILE *));
if (tree_fn)
tree_fp = (FILE **) HTS_calloc(interpolation_size, sizeof(FILE *));
else
tree_fp = NULL;
for (i = 0; i < interpolation_size; i++) {
pdf_fp[i] = HTS_get_fp(pdf_fn[i], "rb");
if (tree_fn) {
if (tree_fn[i])
tree_fp[i] = HTS_get_fp(tree_fn[i], "r");
else
tree_fp[i] = NULL;
}
}
HTS_Engine_load_gv_from_fp(engine, pdf_fp, tree_fp, stream_index,
interpolation_size);
for (i = 0; i < interpolation_size; i++) {
fclose(pdf_fp[i]);
if (tree_fp && tree_fp[i])
fclose(tree_fp[i]);
}
HTS_free(pdf_fp);
if (tree_fp)
HTS_free(tree_fp);
}
示例3: HTS_Audio_close
/* HTS_Audio_close: close audio device */
void HTS_Audio_close(HTS_Audio * as)
{
MMRESULT error;
if (as->buff_size != 0)
HTS_Audio_write_buffer(as);
while (as->now_buff_1 == TRUE)
Sleep(AUDIO_WAIT_BUFF_MS);
while (as->now_buff_2 == TRUE)
Sleep(AUDIO_WAIT_BUFF_MS);
/* stop audio */
error = waveOutReset(as->hwaveout);
if (error != MMSYSERR_NOERROR)
HTS_error(0,
"hts_engine: Cannot stop and reset your output audio device.\n");
/* unprepare */
error = waveOutUnprepareHeader(as->hwaveout, &(as->buff_1), sizeof(WAVEHDR));
if (error != MMSYSERR_NOERROR)
HTS_error(0,
"hts_engine: Cannot cleanup the audio datablocks to play waveform.\n");
error = waveOutUnprepareHeader(as->hwaveout, &(as->buff_2), sizeof(WAVEHDR));
if (error != MMSYSERR_NOERROR)
HTS_error(0,
"hts_engine: Cannot cleanup the audio datablocks to play waveform.\n");
/* close */
error = waveOutClose(as->hwaveout);
if (error != MMSYSERR_NOERROR)
HTS_error(0, "hts_engine: Failed to close your output audio device.\n");
HTS_free(as->buff_1.lpData);
HTS_free(as->buff_2.lpData);
HTS_free(as->buff);
}
示例4: HTS_Engine_load_parameter_from_fn
/* HTS_Engine_load_parameter_from_fn: load parameter pdfs, trees and windows from file names */
void HTS_Engine_load_parameter_from_fn(HTS_Engine * engine, char **pdf_fn,
char **tree_fn, char **win_fn,
int stream_index, HTS_Boolean msd_flag,
int window_size, int interpolation_size)
{
int i;
FILE **pdf_fp, **tree_fp, **win_fp;
pdf_fp = (FILE **) HTS_calloc(interpolation_size, sizeof(FILE *));
tree_fp = (FILE **) HTS_calloc(interpolation_size, sizeof(FILE *));
win_fp = (FILE **) HTS_calloc(window_size, sizeof(FILE *));
for (i = 0; i < interpolation_size; i++) {
pdf_fp[i] = HTS_get_fp(pdf_fn[i], "rb");
tree_fp[i] = HTS_get_fp(tree_fn[i], "r");
}
for (i = 0; i < window_size; i++)
win_fp[i] = HTS_get_fp(win_fn[i], "r");
HTS_Engine_load_parameter_from_fp(engine, pdf_fp, tree_fp, win_fp,
stream_index, msd_flag,
window_size, interpolation_size);
for (i = 0; i < interpolation_size; i++) {
fclose(pdf_fp[i]);
fclose(tree_fp[i]);
}
for (i = 0; i < window_size; i++)
fclose(win_fp[i]);
HTS_free(pdf_fp);
HTS_free(tree_fp);
HTS_free(win_fp);
}
示例5: HTS_free_matrix
/* HTS_free_matrix: free double matrix */
void HTS_free_matrix(double **p, size_t x) {
size_t i;
for (i = 0; i < x; i++)
HTS_free(p[i]);
HTS_free(p);
}
示例6: HTS_free_matrix
/* HTS_free_matrix: free double matrix */
void HTS_free_matrix(double **p, const int x)
{
int i;
for (i = x - 1; i >= 0; i--)
HTS_free(p[i]);
HTS_free(p);
}
示例7: HTS_Label_clear
/* HTS_Label_clear: free label */
void HTS_Label_clear(HTS_Label * label)
{
HTS_LabelString *lstring, *next_lstring;
for (lstring = label->head; lstring; lstring = next_lstring) {
next_lstring = lstring->next;
HTS_free(lstring->name);
HTS_free(lstring);
}
HTS_Label_initialize(label);
}
示例8: HTS_Question_clear
/* HTS_Question_clear: clear loaded question */
static void HTS_Question_clear(HTS_Question * question)
{
HTS_Pattern *pattern, *next_pattern;
HTS_free(question->string);
for (pattern = question->head; pattern; pattern = next_pattern) {
next_pattern = pattern->next;
HTS_free(pattern->string);
HTS_free(pattern);
}
}
示例9: HTS_Tree_clear
/* HTS_Tree_clear: clear given tree */
static void HTS_Tree_clear(HTS_Tree * tree)
{
HTS_Pattern *pattern, *next_pattern;
for (pattern = tree->head; pattern; pattern = next_pattern) {
next_pattern = pattern->next;
HTS_free(pattern->string);
HTS_free(pattern);
}
HTS_Node_clear(tree->root);
}
示例10: HTS_Vocoder_postfilter_mcp
/* HTS_Vocoder_postfilter_mcp: postfilter for MCP */
void HTS_Vocoder_postfilter_mcp(HTS_Vocoder *v, double *mcp, const int m,
double alpha, double beta)
{
double e1, e2;
int k;
if (beta > 0.0 && m > 1) {
if (v->postfilter_size < m) {
if (v->postfilter_buff != NULL)
HTS_free(v->postfilter_buff);
v->postfilter_buff = (double *) HTS_calloc(m + 1, sizeof(double));
v->postfilter_size = m;
}
HTS_mc2b(mcp, v->postfilter_buff, m, alpha);
e1 = HTS_b2en(v, v->postfilter_buff, m, alpha);
v->postfilter_buff[1] -= beta * alpha * mcp[2];
for (k = 2; k <= m; k++)
v->postfilter_buff[k] *= (1.0 + beta);
e2 = HTS_b2en(v, v->postfilter_buff, m, alpha);
v->postfilter_buff[0] += log(e1 / e2) / 2;
HTS_b2mc(v->postfilter_buff, mcp, m, alpha);
}
}
示例11: HTS_lsp2en
/* HTS_lsp2en: calculate frame energy */
static double HTS_lsp2en(HTS_Vocoder * v, double *lsp, size_t m, double alpha)
{
size_t i;
double en = 0.0;
double *buff;
if (v->spectrum2en_size < m) {
if (v->spectrum2en_buff != NULL)
HTS_free(v->spectrum2en_buff);
v->spectrum2en_buff = (double *) HTS_calloc(m + 1 + IRLENG, sizeof(double));
v->spectrum2en_size = m;
}
buff = v->spectrum2en_buff + m + 1;
/* lsp2lpc */
HTS_lsp2lpc(v, lsp + 1, v->spectrum2en_buff, m);
if (v->use_log_gain)
v->spectrum2en_buff[0] = exp(lsp[0]);
else
v->spectrum2en_buff[0] = lsp[0];
/* mgc2mgc */
if (NORMFLG1)
HTS_ignorm(v->spectrum2en_buff, v->spectrum2en_buff, m, v->gamma);
else if (MULGFLG1)
v->spectrum2en_buff[0] = (1.0 - v->spectrum2en_buff[0]) * ((double) v->stage);
if (MULGFLG1)
for (i = 1; i <= m; i++)
v->spectrum2en_buff[i] *= -((double) v->stage);
HTS_mgc2mgc(v, v->spectrum2en_buff, m, alpha, v->gamma, buff, IRLENG - 1, 0.0, 1);
for (i = 0; i < IRLENG; i++)
en += buff[i] * buff[i];
return en;
}
示例12: HTS_freqt
/* HTS_freqt: frequency transformation */
static void HTS_freqt(HTS_Vocoder * v, const double *c1, const int m1, double *c2, const int m2, const double a)
{
int i, j;
const double b = 1 - a * a;
double *g;
if (m2 > v->freqt_size) {
if (v->freqt_buff != NULL)
HTS_free(v->freqt_buff);
v->freqt_buff = (double *) HTS_calloc(m2 + m2 + 2, sizeof(double));
v->freqt_size = m2;
}
g = v->freqt_buff + v->freqt_size + 1;
for (i = 0; i < m2 + 1; i++)
g[i] = 0.0;
for (i = -m1; i <= 0; i++) {
if (0 <= m2)
g[0] = c1[-i] + a * (v->freqt_buff[0] = g[0]);
if (1 <= m2)
g[1] = b * v->freqt_buff[0] + a * (v->freqt_buff[1] = g[1]);
for (j = 2; j <= m2; j++)
g[j] = v->freqt_buff[j - 1] + a * ((v->freqt_buff[j] = g[j]) - g[j - 1]);
}
HTS_movem(g, c2, m2 + 1);
}
示例13: HTS_b2en
/* HTS_b2en: calculate frame energy */
static double HTS_b2en(HTS_Vocoder * v, const double *b, const int m, const double a)
{
int i;
double en = 0.0;
double *cep;
double *ir;
if (v->spectrum2en_size < m) {
if (v->spectrum2en_buff != NULL)
HTS_free(v->spectrum2en_buff);
v->spectrum2en_buff = (double *) HTS_calloc((m + 1) + 2 * IRLENG, sizeof(double));
v->spectrum2en_size = m;
}
cep = v->spectrum2en_buff + m + 1;
ir = cep + IRLENG;
HTS_b2mc(b, v->spectrum2en_buff, m, a);
HTS_freqt(v, v->spectrum2en_buff, m, cep, IRLENG - 1, -a);
HTS_c2ir(cep, IRLENG, ir, IRLENG);
for (i = 0; i < IRLENG; i++)
en += ir[i] * ir[i];
return (en);
}
示例14: HTS_gc2gc
/* HTS_gc2gc: generalized cepstral transformation */
static void HTS_gc2gc(HTS_Vocoder * v, double *c1, const int m1, const double g1, double *c2, const int m2, const double g2)
{
int i, min, k, mk;
double ss1, ss2, cc;
if (m1 > v->gc2gc_size) {
if (v->gc2gc_buff != NULL)
HTS_free(v->gc2gc_buff);
v->gc2gc_buff = (double *) HTS_calloc(m1 + 1, sizeof(double));
v->gc2gc_size = m1;
}
HTS_movem(c1, v->gc2gc_buff, m1 + 1);
c2[0] = v->gc2gc_buff[0];
for (i = 1; i <= m2; i++) {
ss1 = ss2 = 0.0;
min = m1 < i ? m1 : i - 1;
for (k = 1; k <= min; k++) {
mk = i - k;
cc = v->gc2gc_buff[k] * c2[mk];
ss2 += k * cc;
ss1 += mk * cc;
}
if (i <= m1)
c2[i] = v->gc2gc_buff[i] + (g2 * ss2 - g1 * ss1) / i;
else
c2[i] = (g2 * ss2 - g1 * ss1) / i;
}
}
示例15: HTS_Node_clear
/* HTS_Node_clear: recursive function to free Node */
static void HTS_Node_clear(HTS_Node * node)
{
if (node->yes != NULL)
HTS_Node_clear(node->yes);
if (node->no != NULL)
HTS_Node_clear(node->no);
HTS_free(node);
}