Example #1
0
int main(int argc, char **argv)
{
    cst_wave *nw, *all;
    cst_val *files;
    const cst_val *w;
    cst_val *wavelist;
    cst_features *args;
    int i,j;
    float ntime;
    int stime;
    const char *nwfile;

    args = new_features();
    files =
        cst_args(argv,argc,
                 "usage: combine_waves OPTIONS\n"
                 "Combine waves into single waveform\n"
		 "-o <string>  Output waveform\n"
		 "-f <int>     Input sample rate (for raw input)\n"
		 "-itype <string>  Input type, raw or headered\n"
		 "-wavelist <string>  File containing times and wave filenames\n",
                 args);

    wavelist = get_wavelist(get_param_string(args,"-wavelist","-"));

    if (wavelist == 0)
	return -1;

    all = new_wave();
    for (w = wavelist; w; w = val_cdr(w))
    {
	ntime = decode_time(val_string(val_car(w)));
	nwfile = val_string(val_car(val_cdr(w)));

	nw = new_wave();
	if (cst_wave_load_riff(nw,nwfile) != CST_OK_FORMAT)
	{
	    fprintf(stderr,
		    "combine_waves: can't read file or wrong format \"%s\"\n",
		    nwfile);
	    continue;
	}

	stime = ntime * nw->sample_rate;

	cst_wave_resize(all,stime+nw->num_samples,1);
	
	for (i=0,j=stime; i<nw->num_samples; i++,j++)
	{
	    /* this will cause overflows */
	    all->samples[j] += nw->samples[i];
	}
	delete_wave(nw);
    }

    cst_wave_save_riff(all,get_param_string(args,"-o","-"));

    return 0;
}
int main(int argc, char **argv)
{
    cst_wave *in, *out;
    cst_val *files;
    cst_features *args;
    int i,j;
    int w, a, t;

    args = new_features();
    files =
        cst_args(argv,argc,
                 "usage: dcoffset_wave OPTIONS\n"
                 "Subtract window average from waveform\n"
		 "-i <string>  Input waveform\n"
		 "-o <string>  Output waveform\n"
		 "-w <int>     Window size (in samples)\n",
                 args);

    w = flite_get_param_int(args,"-w",20);
    in = new_wave();
    cst_wave_load_riff(in,flite_get_param_string(args,"-i","-"));

    out = copy_wave(in);

    for (i=0; i<=out->num_samples; i++)
    {
        for (t=a=0,j=i-w/2; j < i+w/2; j++)
        {
            if ((j > 0) && (j < out->num_samples))
            {
                t += 1;
                a+=in->samples[j];
            }
        }
        /*        printf("%d %d %d %d %d\n",i,out->samples[i],a/t,t,out->samples[i]-a/t); */
        out->samples[i] -= a/t;
    }

    cst_wave_save_riff(out,flite_get_param_string(args,"-o","-"));

    return 0;
}
Example #3
0
int main(int argc, char **argv)
{
    cst_track *t1;
    cst_track *me_filters = NULL;
    cst_wave *w1, *w2, *res = NULL;
    cst_val *files;
    cst_features *args;
    int i, j;
    int order, o, s;
    int frame_length;
    float *lpcs, *residual;
    float m;
    const char *f1, *f2;
    const char *resfn = NULL;
    int last_peak = 0, next_peak;
    int period;
    float power;
    int rfc = 0;
    int str = 0;
    int fn, fo, ss;
    float xpulse, xnoise;
    float fxpulse, fxnoise;
    float x, me;
    float *hpulse = NULL, *hnoise = NULL;
    float *xpulsesig = NULL, *xnoisesig = NULL;
    int q = 0;
    int position;
    int lpc_start = 0;

    args = new_features();
    files =
        cst_args(argv, argc,
                 "usage: lpc_resynth OPTIONS INTRACK OUTWAVE\n"
                 "Resynth an lpc track\n"
                 "-res <string> residual (as waveform)\n"
                 "-save_res Save the generated residual\n"
                 "-lpc_start <int> start of lpc params in lpc track {1}\n"
                 "-order <int> LPC order {16}\n"
                 "-str mixed excitation strengths\n"
                 "-me_filters <string> mixed excitation filters\n"
                 "-rfc Coefficents are reflection coefficients\n", args);

    f1 = val_string(val_car(files));
    f2 = val_string(val_car(val_cdr(files)));
    t1 = new_track();

    lpc_start = mimic_get_param_int(args, "-lpc_start", 1);
    if (feat_present(args, "-rfc"))
        rfc = 1;
    if (feat_present(args, "-str"))
        str = 1;
    if (feat_present(args, "-me_filters"))
    {
        me_filters = new_track();
        if (cst_track_load_est
            (me_filters,
             mimic_get_param_string(args, "-me_filters",
                                    "me_filters.track")) != CST_OK_FORMAT)
        {
            fprintf(stderr,
                    "lpc_resynth: can't read file or wrong format \"%s\"\n",
                    f1);
            return -1;
        }
        hpulse = cst_alloc(float, me_filters->num_channels);
        hnoise = cst_alloc(float, me_filters->num_channels);
        xpulsesig = cst_alloc(float, me_filters->num_channels);
        xnoisesig = cst_alloc(float, me_filters->num_channels);
    }
Example #4
0
int main(int argc, char **argv)
{
    bard_reader *br;
    cst_features *args;
    cst_features *config;
    float idle_time;
    int spos;

    args = new_features();
    cst_args(argv,argc,
	     "usage: bard OPTIONS\n"
             "Bard Storyteller\n"
             "-text <string> Text filename to read\n"
             "-text_pos <int> Starting position in text file\n"
             "-config_file <string> Override default config file ($HOME/.bard_config)\n"
             "-font <string> Pathname to ttf font file\n"
             "-font_size <int> Initial font size\n"
             "-audio_method <string> SDL or flite\n"
             "-voice <string> Voice name (or pathname to dumped voice)\n"
             "-audio_stream_buffer_factor  <int> Bigger for slower processors\n"
             "-gain <float> Volume factor (1.0 is default)\n"
             "-speed <float> Duration stretch (inverse speed)\n"
             "-battery_script <string> Script to get battery charge state\n"
             "-screen_height <int> \n"
             "-screen_width <int> \n"
             "-screen_blank_idle_time <float> In secs (0 means no blanking)\n"
             "-scroll_delay <int> In ms\n"
             "-voices_dir <string>  Directory containing *.flitevox voices\n"
             "-debug <int> Print debug messages\n"
             "",
             args);

    /* If text specified and no position given, start from 0 */
    if (feat_present(args,"-text") && !feat_present(args,"-text_pos"))
        feat_set_int(args,"-text_pos",0);
    if (!feat_present(args,"-font"))
        feat_set_string(args,"-font",BARD_DEFAULT_FONT);
    bard_debug = get_param_int(args,"-debug",0);

    config = bard_read_config(args);
    
    cst_feat_print(stdout,config);

    br = bard_open(config);
    if (br == NULL) return -1;  /* something went really wrong */

    /* Make the windows */
    br->text = bard_make_text_window(br);
    br->file_select = bard_make_file_select_window(br);
    br->info = bard_make_info_window(br); /* general info/params */
    br->help = bard_make_help_window(br);
    br->recent = bard_make_recent_window(br);
    br->menu = bard_make_menu_window(br);
    if (feat_present(br->config,"-voices_dir"))
        br->voice_select = bard_make_voice_select_window(br);
    /* Select focus */
    br->display->current = br->text;

    bard_display_clear(br->display);
    bard_display_update(br->display);
    bard_screen_on(NULL); /* just in case it is currently off */

    while (br->quit == 0)
    {
        if (input_process_events(br) == 0)
        {
            if (br->scroll)
            {
                SDL_Delay(br->scroll_delay); /* no key press but scrolling */
                br->quiet_time = SDL_GetTicks(); /* no blank while scrolling */
            }
            else
                SDL_Delay(br->no_key_delay); /* no key press, so pause a bit */
        }

        if (br->speak == 1)
        {
            /* Within the audio callback function, we also call */
            /* input_process_events so we can stop if requested */
            br->pause = 0;
            if (br->display->current->current_token)
                spos = br->display->current->current_token->file_pos;
            else
                spos = br->display->current->sop_pos;
            /* We need spos-1 here to make it display well */
            bard_speak_text(br->speech,br->display->current->textfile,spos-1);
                            
            br->speak = 0;
            br->quiet_time = SDL_GetTicks();
        }
        else if (br->scroll)
        {   /* Speaking and smooth scrolling are mutually exclusive */
            if (bard_text_scroll(br->text) == 0)
                br->scroll = 0;  /* Reached end of file so stop scroll */
            bard_display_update(br->display); /* Update screen */
        }
        else
            br->text->scroll_offset = 0;

        /* Check if we should black/hide cursor */
        idle_time = (SDL_GetTicks()-br->quiet_time)/1000.0;
        if ((br->screen_blank_idle_time > 0) &&
            (idle_time > br->screen_blank_idle_time) && 
            (br->blank == 0))
        {
            br->blank = 1;
            bard_screen_off(NULL);
        }
        idle_time = (SDL_GetTicks()-br->mouse_quiet_time)/1000.0;
        if (idle_time > 5.0)
            SDL_ShowCursor(SDL_DISABLE);
    }

    /* Save context */
    bard_write_config(br);

    bard_close(br);
    delete_features(args);

    return 0;
}