Ejemplo n.º 1
0
void get_cpu_params ()
{
  FILE* fp;
  char buffer[1024];
  size_t bytes_read;
  float clock_speed;
  int cache_size;
  char modelname[100];

  /* Read the entire contents of /proc/cpuinfo into the buffer. */
  fp = fopen ("/proc/cpuinfo", "r");
  bytes_read = fread (buffer, 1, sizeof (buffer), fp);
  fclose (fp);

  /* Return if read failed or if buffer isn't big enough. */
  if (bytes_read == 0 || bytes_read == sizeof (buffer))
    return ;
  
  buffer[bytes_read] = '\0';
  
  sscanf (get_param_val(buffer,"cpu MHz"), "cpu MHz : %f", &clock_speed);
  printf ("CPU clock speed: %f MHz\n",clock_speed);
  
  sscanf (get_param_val(buffer,"cache size"), "cache size : %d", &cache_size);
  printf ("CPU cache size: %d KB\n",cache_size);
  
}
Ejemplo n.º 2
0
static plc_t configure_limits(int operand,                        
                       const variable_t var, 
                       plc_t plc){
    plc_t p = plc;
    char * max = NULL;
    char * min = NULL;
    
    if((max = get_param_val("MAX", var->params))){
        p = configure_io_limit(p, operand, var->index, max, TRUE);
    }
    if((min = get_param_val("MIN", var->params))){
        p = configure_io_limit(p, operand, var->index, min, FALSE);
    }   
    return p;                         
}
Ejemplo n.º 3
0
static cst_utterance *cg_resynth(cst_utterance *utt)
{
    cst_cg_db *cg_db;
    cst_wave *w;
    cst_track *param_track;
    cst_track *str_track = NULL;
    cst_track *smoothed_track;
    const cst_val *streaming_info_val;
    cst_audio_streaming_info *asi = NULL;

    streaming_info_val=get_param_val(utt->features,"streaming_info",NULL);
    if (streaming_info_val)
        asi = val_audio_streaming_info(streaming_info_val);

    cg_db = val_cg_db(utt_feat_val(utt,"cg_db"));
    param_track = val_track(utt_feat_val(utt,"param_track"));
    if (cg_db->mixed_excitation)
        str_track = val_track(utt_feat_val(utt,"str_track"));

    if (cg_db->do_mlpg)
    {
        smoothed_track = mlpg(param_track, cg_db);
        w = mlsa_resynthesis(smoothed_track,str_track,cg_db,asi);
        delete_track(smoothed_track);
    }
    else
        w=mlsa_resynthesis(param_track,str_track,cg_db,asi);


    utt_set_wave(utt,w);

    return utt;
}
Ejemplo n.º 4
0
cst_utterance *join_units_simple(cst_utterance *utt)
{
    cst_wave *w = 0;
    cst_lpcres *lpcres;
    const char *resynth_type;
    const cst_val *streaming_info_val;

    resynth_type = get_param_string(utt->features, "resynth_type", "fixed");

    asis_to_pm(utt);
    concat_units(utt);

    lpcres = val_lpcres(utt_feat_val(utt, "target_lpcres"));

    streaming_info_val = get_param_val(utt->features, "streaming_info", NULL);
    if (streaming_info_val)
    {
        lpcres->asi = val_audio_streaming_info(streaming_info_val);
        lpcres->asi->utt = utt;
    }

    if (cst_streq(resynth_type, "fixed"))
        w = lpc_resynth_fixedpoint(lpcres);
    else
    {
        cst_errmsg("unknown resynthesis type %s\n", resynth_type);
        cst_error();            /* Should not happen */
    }

    utt_set_wave(utt, w);

    return utt;
}
Ejemplo n.º 5
0
static plc_t configure_counters(const config_t conf, plc_t plc){

    sequence_t seq = get_sequence_entry(CONFIG_MREG, conf);
    
    if(seq) {
        plc_t p = plc;
        int i = 0;
        char * val = NULL;
        for(; i < seq->size; i++){
            //names
            p = declare_names(OP_MEMORY, &(seq->vars[i]), p);
            //defaults
            p = init_values(OP_MEMORY, &(seq->vars[i]), p);
            //readonlies
            p = configure_readonly(OP_MEMORY, &(seq->vars[i]), p);
            //directions    
            if((val = get_param_val("COUNT", seq->vars[i].params))){
                p = configure_counter_direction(p, i, val);
                val = NULL;
            }
        }
        return p;   
    } 
    return plc;
}
Ejemplo n.º 6
0
static plc_t configure_readonly(int operand,                        
                        const variable_t var, 
                        plc_t plc){
    char * val = NULL;
    
    if((val = get_param_val("READONLY", var->params))){
      return configure_variable_readonly(plc, operand, var->index, val);
    } 
    return plc;               
}
Ejemplo n.º 7
0
static plc_t init_values(int operand,                        
                  const variable_t var, 
                  plc_t plc){
    char * val = NULL;
    
    if((val = get_param_val("VALUE", var->params))){
        return init_variable(plc, operand, var->index, val);
    }
    return plc;                         
}
Ejemplo n.º 8
0
static plc_t declare_names(int operand,
                    const variable_t var,                      
                    plc_t plc){

    char * name = var->name;
    if(name){
        unsigned char index = var->index;
        char * byte = get_param_val("BYTE", var->params);
        if(byte){
            int idx = atoi(byte) * BYTESIZE;
            char * bit = get_param_val("BIT", var->params);
            if(bit){
                idx += atoi(bit);
            } 
       
            if(idx>=0 && idx < 256){
                index = (unsigned char)idx;
            }
        }
        return declare_variable(plc, operand, index, name); 
    } else return plc;
} 
Ejemplo n.º 9
0
static plc_t configure_timers(const config_t conf, plc_t plc){

    sequence_t seq = get_sequence_entry(CONFIG_TIMER, conf);
    
    if(seq) {
        int i = 0;
        char * scale = NULL;
        char * preset = NULL;
        char * ondelay = NULL;
        plc_t p = plc;
        for(; i < seq->size; i++){
            //names
            p = declare_names(OP_TIMEOUT, &(seq->vars[i]), plc);
            //scales
            if((scale = get_param_val("RESOLUTION", 
                                        seq->vars[i].params))){
                p = configure_timer_scale(p, i, scale);
                scale = NULL;
            }
            //presets            
            if((preset = get_param_val("PRESET", 
                                        seq->vars[i].params))){
                p = configure_timer_preset(p, i, preset);
                preset = NULL;
            }
            //modes
            if((ondelay = get_param_val("ONDELAY", 
                                        seq->vars[i].params))){
                p = configure_timer_delay_mode(p, i, ondelay);
                ondelay = NULL;
            }
        }   
        return p; 
    } 
    return plc;    
}
Ejemplo n.º 10
0
cst_utterance *join_units_modified_lpc(cst_utterance *utt)
{
    cst_wave *w = 0;
    cst_lpcres *lpcres;
    const char *resynth_type;
    const cst_val *streaming_info_val;

    resynth_type = get_param_string(utt->features, "resynth_type", "float");

    f0_targets_to_pm(utt);
    concat_units(utt);

    lpcres = val_lpcres(utt_feat_val(utt, "target_lpcres"));

    streaming_info_val = get_param_val(utt->features, "streaming_info", NULL);
    if (streaming_info_val)
    {
        lpcres->asi = val_audio_streaming_info(streaming_info_val);
        lpcres->asi->utt = utt;
    }

    if (cst_streq(resynth_type, "float"))
        w = lpc_resynth(lpcres);
    else if (cst_streq(resynth_type, "fixed"))
    {
        w = lpc_resynth_fixedpoint(lpcres);
    }
    else
    {
        cst_errmsg("unknown resynthesis type %s\n", resynth_type);
        cst_error();            /* Should not happen */
    }

    if (w == NULL)
    {
        /* Synthesis Failed, probably because it was interrupted */
        utt_set_feat_int(utt, "Interrupted", 1);
        w = new_wave();
    }

    utt_set_wave(utt, w);

    return utt;
}
Ejemplo n.º 11
0
cst_utterance *default_pos_tagger(cst_utterance *u)
{
    cst_item *word;
    const cst_val *p;
    const cst_cart *tagger;

    p = get_param_val(u->features,"pos_tagger_cart",NULL);
    if (p == NULL)
        return u;
    tagger = val_cart(p);

    for (word=relation_head(utt_relation(u,"Word")); 
	 word; word=item_next(word))
    {
        p = cart_interpret(word,tagger);
        item_set_string(word,"pos",val_string(p));
    }

    return u;
}
Ejemplo n.º 12
0
static plc_t configure_pulses(const config_t conf, plc_t plc){

    sequence_t seq = get_sequence_entry(CONFIG_PULSE, conf);
    
    if(seq) {
        int i = 0;
        char * scale = NULL;
        plc_t p = plc;
        for(; i < seq->size; i++){
            //names
            p = declare_names(OP_BLINKOUT, &(seq->vars[i]), plc);
            //scales
            if((scale = get_param_val("RESOLUTION",
                                     seq->vars[i].params))){
                p = configure_pulse_scale(p, i, scale);
                scale = NULL;
            }
        }   
        return p; 
    } 
    return plc;    
}
Ejemplo n.º 13
0
const cst_val *cart_interpret(cst_item *item, const cst_cart *tree)
{
    /* Tree interpretation */
    const cst_val *v=0;
    const cst_val *tree_val;
    const char *tree_feat = "";
    cst_features *fcache;
    int r=0;
    int node=0;

    fcache = new_features_local(item_utt(item)->ctx);

    while (cst_cart_node_op(node,tree) != CST_CART_OP_LEAF)
    {
#if CART_DEBUG
 	cart_print_node(node,tree);
#endif
	tree_feat = cst_cart_node_feat(node,tree);

	v = get_param_val(fcache,tree_feat,0);
	if (v == 0)
	{
	    v = ffeature(item,tree_feat);
	    feat_set(fcache,tree_feat,v);
	}

#if CART_DEBUG
	val_print(stdout,v); printf("\n");
#endif
	tree_val = cst_cart_node_val(node,tree);
	if (cst_cart_node_op(node,tree) == CST_CART_OP_IS)
	    r = val_equal(v,tree_val);
	else if (cst_cart_node_op(node,tree) == CST_CART_OP_LESS)
	    r = val_less(v,tree_val);
	else if (cst_cart_node_op(node,tree) == CST_CART_OP_GREATER)
	    r = val_greater(v,tree_val);
	else if (cst_cart_node_op(node,tree) == CST_CART_OP_IN)
	    r = val_member(v,tree_val);
	else if (cst_cart_node_op(node,tree) == CST_CART_OP_MATCHES)
	    r = cst_regex_match(cst_regex_table[val_int(tree_val)],
				val_string(v));
	else
	{
	    cst_errmsg("cart_interpret_question: unknown op type %d\n",
		       cst_cart_node_op(node,tree));
	    cst_error();
	}

	if (r)
	{   /* Oh yes it is */
#if CART_DEBUG
            printf("   YES\n");
#endif
	    node = cst_cart_node_yes(node,tree);
	}
	else
	{   /* Oh no it isn't */
#if CART_DEBUG
            printf("   NO\n");
#endif
	    node = cst_cart_node_no(node,tree);
	}
    }

    delete_features(fcache);

    return cst_cart_node_val(node,tree);	

}
Ejemplo n.º 14
0
const cst_val *flite_get_param_val(const cst_features *f, const char *name, cst_val *def)
{
    return get_param_val(f,name,def);
}
Ejemplo n.º 15
0
app_t apply_command(const config_t com, 
                    app_t a){
    char * confstr = "config.yml";
    char * cvalue = NULL;
    char * val = NULL;
    sequence_t seq = NULL;
    int s = CONFIG_PROGRAM;
    int v = -1;
    plc_t p = NULL;
    if(a != NULL){
        switch(get_numeric_entry(CLI_COM, com)){
            case COM_START:
        
                a->plc = plc_start(a->plc);
                break;
            
            case COM_STOP:
        
                a->plc = plc_stop(a->plc);
                break;
        
            case COM_LOAD:
            
                a->plc = plc_stop(a->plc);
                a->conf = init_config();
                cvalue = get_string_entry(CLI_ARG, com);
                if( cvalue == NULL ||
                    cvalue[0] == 0){
                    cvalue = confstr;
                }
                if ((load_config_yml(cvalue, a->conf))->err < PLC_OK) {
                    plc_log("Invalid configuration file %s\n", cvalue);
                } else {
                    a = configure(a->conf, a);
                }    
                break;
            
            case COM_SAVE:
        
                a->plc = plc_stop(a->plc);
                cvalue = get_string_entry(CLI_ARG, com);
                if( cvalue == NULL ||
                    cvalue[0] == 0){
                    cvalue = confstr;
                }
                if ((save_config_yml(cvalue, a->conf)) < PLC_OK) {
                    plc_log("Invalid configuration file %s\n", cvalue);
                }
                break;    
        
            case COM_FORCE:         
            
                for(s = CONFIG_PROGRAM; s < N_CONFIG_VARIABLES; s++){
                    seq = get_sequence_entry(s, com); 
                    for(v = 0; seq && v < seq->size; v++){
                    //filter sequences who have a param "FORCE"
                        val = get_param_val("FORCE", seq->vars[v].params);
                        if(val){  //apply force   
                            p = force(a->plc, Lookup[s], v, val);
                            if(p){
                                a->plc = p;
                            }
                        }
                    } 
                }
                if(p == NULL){
                    plc_log("Invalid force command\n");
                }
                break;
            
            case COM_UNFORCE:
            
                for(s = CONFIG_PROGRAM; s < N_CONFIG_VARIABLES; s++){
                    seq = get_sequence_entry(s, com); 
                    for(v = 0; seq && v < seq->size; v++){
                //filter sequences who have a param "FORCE"
                        val = get_param_val("FORCE", seq->vars[v].params);
                        if(val){  //apply force   
                            p = unforce(a->plc, Lookup[s], v);
                            if(p){
                                a->plc = p;
                            }
                        }
                    } 
                }
                if(p == NULL){
                    plc_log("Invalid force command\n");
                }
                break;
             case COM_EDIT:
                //TODO: filter sequences who have an updated variable                    
                a->plc = configure_di(com, a->plc);
                a->plc = configure_dq(com, a->plc);
                a->plc = configure_ai(com, a->plc);
                a->plc = configure_aq(com, a->plc);
                a->plc = configure_counters(com, a->plc);
                a->plc = configure_reals(com, a->plc);
                a->plc = configure_timers(com, a->plc);
                a->plc = configure_pulses(com, a->plc);
                a->conf = copy_sequences(com, a->conf);
                break;
            default: break;
        }
    }
    return a;
}