int main( int argc, char* argv[]) { //check argument if ( argc != 2 ) { fprintf(stderr, "[PLAY]: %s <filename>.wav \n", argv[0]); exit(1); } play_init(LIST, NOWAIT, NONDISP); play_read_filelist(argv[1]); play_sound("start"); sleep(1); play_sound("stop"); sleep(1); play_sound("left"); sleep(1); play_sound("right"); sleep(1); play_sync(); play_close(); return 1; }
JNIEXPORT void JNICALL Java_com_syouquan_script_ScriptEngine_nativeEventStartReplay (JNIEnv * env, jobject thiz ) { LOGI("---call native method start replay---"); if (in_replay == 1) { LOGI("is in replaying"); return; } //sleep 1s sleep(1); in_record = 0; if(play_init() != 0) { LOGI("init failed\n"); return; } if(replay(env) != 0) { LOGI("replay failed\n"); return; } }
/** * @brief ui_init_ggs * * Init GGS interface. * * @param ui User Interface. */ void ui_init_ggs(UI *ui) { const int n_task = options.n_task; ui->ggs = (GGSClient*) malloc (sizeof (GGSClient)); if (ui->ggs == NULL) fatal_error("ui_init_ggs: cannot allocate the GGS client\n"); play_init(ui->play, ui->book); ui->book->search = ui->play->search; book_load(ui->book, options.book_file); ui->play[0].search->id = 1; options.n_task = 1; play_init(ui->play + 1, ui->book); ui->play[1].search->id = 2; options.n_task = n_task; log_open(ggs_log, options.ggs_log_file); ui_login(ui); }
static int setup(struct app *app) { #ifdef HTS_MELP #define NR_STREAMS 3 #else #define NR_STREAMS 2 #endif /* HTS_MELP */ double gv_weight[] = { app->gv_weight_mgc, app->gv_weight_lf0, #ifdef HTS_MELP app->gv_weight_lpf #endif /* HTS_MELP */ }; int i; app->play_h = play_init(&app->play_info, "default", SND_PCM_FORMAT_S16_LE, 1, app->sampling_rate, 500000, 8); Mecab_initialize(&app->mecab); if (Mecab_load(&app->mecab, app->dn_mecab) != TRUE) return -1; NJD_initialize(&app->njd); JPCommon_initialize(&app->jpcommon); HTS_Engine_initialize(&app->engine); if (HTS_Engine_load(&app->engine, &app->fn_voice, 1) != TRUE) return -1; HTS_Engine_set_sampling_frequency(&app->engine, (size_t)app->sampling_rate); if (app->fperiod >= 0) HTS_Engine_set_fperiod(&app->engine, app->fperiod); if (app->alpha >= 0.0) HTS_Engine_set_alpha(&app->engine, app->alpha); if (app->beta >= 0.0) HTS_Engine_set_beta(&app->engine, app->beta); if (app->half_tone >= 0.0) HTS_Engine_add_half_tone(&app->engine, app->half_tone); if (app->audio_buff_size > 0) HTS_Engine_set_audio_buff_size(&app->engine, app->audio_buff_size); if (app->uv_threshold >= 0.0) HTS_Engine_set_msd_threshold(&app->engine, 1, app->uv_threshold); if (app->speed >= 0.0) HTS_Engine_set_speed(&app->engine, app->speed); for (i = 0; i < NR_STREAMS; i++) if (gv_weight[i] >= 0.0) HTS_Engine_set_gv_weight(&app->engine, i, gv_weight[i]); return 0; }
/** * @brief initialize edax protocol. * @param ui user interface. */ void ui_init_edax(UI *ui) { Play *play = ui->play; book_verbose = true; play_init(play, ui->book); ui->book->search = play->search; book_load(ui->book, options.book_file); play->search->id = 1; search_set_observer(play->search, edax_observer); ui->mode = options.mode; play->type = ui->type; log_open(edax_log, options.ui_log_file); }
/** * @brief initialize edax protocol * @param ui user interface */ void ui_init_nboard(UI *ui) { Play *play = ui->play; // other update... play_init(play, ui->book); play->search->options.header = play->search->options.separator = NULL; ui->book->search = play->search; book_load(ui->book, options.book_file); play->search->id = 1; search_set_observer(play->search, nboard_observer); ui->mode = 3; play->type = ui->type; log_open(nboard_log, options.ui_log_file); }
void Game::main_menu_run() { if( keyboard.isKeyPressed() ) { leave_main_menu(); play_init(); m_change = true; //cout << (TCHAR)keyboard.getKeyPressed(); } //if ( mouse.ButtonIsClicked() ) //{ // cout << "Mouse handler activated." << endl; //} draw_all_views(); }
/** * Initialise the User-Agents * * @param software SIP User-Agent string * @param udp Enable UDP transport * @param tcp Enable TCP transport * @param tls Enable TLS transport * @param prefer_ipv6 Prefer IPv6 flag * * @return 0 if success, otherwise errorcode */ int ua_init(const char *software, bool udp, bool tcp, bool tls, bool prefer_ipv6) { struct config *cfg = conf_config(); uint32_t bsize; int err; uag.cfg = &cfg->sip; bsize = cfg->sip.trans_bsize; play_init(); err = contact_init(); if (err) return err; /* Initialise Network */ err = net_init(&cfg->net, prefer_ipv6 ? AF_INET6 : AF_INET); if (err) { warning("ua: network init failed: %m\n", err); return err; } uag.use_udp = udp; uag.use_tcp = tcp; uag.use_tls = tls; uag.prefer_ipv6 = prefer_ipv6; list_init(&uag.ual); err = sip_alloc(&uag.sip, net_dnsc(), bsize, bsize, bsize, software, exit_handler, NULL); if (err) { warning("ua: sip stack failed: %m\n", err); goto out; } err = ua_add_transp(); if (err) goto out; err = sip_listen(&uag.lsnr, uag.sip, true, request_handler, NULL); if (err) goto out; err = sipsess_listen(&uag.sock, uag.sip, bsize, sipsess_conn_handler, NULL); if (err) goto out; err = sipevent_listen(&uag.evsock, uag.sip, bsize, bsize, NULL, NULL); if (err) goto out; err = cmd_register(cmdv, ARRAY_SIZE(cmdv)); if (err) goto out; net_change(60, net_change_handler, NULL); out: if (err) { warning("ua: init failed (%m)\n", err); ua_close(); } return err; }
// this is called from main event handler u8 app_launch(u8 firstrun) { print_dbg("\r\n launching app with firstrun: "); print_dbg_ulong(firstrun); // net_print(); render_boot("BEES"); render_boot(versionString); if(firstrun) { render_boot("launching app, first run"); print_dbg("\r\n first run, writing nonvolatile data..."); ///... write param scaler data // this is done at firstrun instead of being linked statically, // so that users can tune scaler data offline without recompiling render_boot("init param scaling data..."); flash_init_scaler_data(); print_dbg("\r\n first run, try and load default DSP"); render_boot("launching default DSP..."); files_load_dsp_name("aleph-waves.ldr"); render_boot("waiting for DSP init..."); bfin_wait_ready(); // print_dbg(" requesting param report..."); render_boot("requesting DSP params"); net_report_params(); // print_dbg("\r\n enable DSP audio..."); render_boot("enabling audio"); bfin_enable(); render_boot("writing default dsp to flash..."); // files_store_default_dsp_name("aleph-waves.ldr"); } else { app_pause(); print_dbg("\r\n booting default ldr from flash... "); render_boot("booting DSP from flash"); // flash_read_ldr(); bfin_load_buf(); print_dbg("\r\n DSP booted, waiting to query params..."); render_boot("waiting for DSP init..."); /// blackfin should clear ready pin ASAP on boot. /// but give it a moment to accomplish that. delay_ms(2); bfin_wait_ready(); print_dbg(" requesting param report..."); render_boot("requesting DSP params"); net_report_params(); print_dbg("\r\n enable DSP audio..."); render_boot("enabling audio"); bfin_enable(); print_dbg("\r\n reading default scene... "); render_boot("reading default scene"); scene_read_default(); app_resume(); } // init pages (fill graphics buffers) print_dbg("\r\n pages_init..."); pages_init(); print_dbg("\r\n play_init..."); play_init(); // enable timers print_dbg("\r\n enable app timers..."); render_boot("enabling app timers..."); init_app_timers(); // pull up power control pin, enabling soft-powerdown gpio_set_gpio_pin(POWER_CTL_PIN); // assign app event handlers print_dbg("\r\n assigning handlers "); render_boot("assigning UI handlers..."); assign_bees_event_handlers(); // update page rendering and handlers pages_reselect(); // start in play mode pages_toggle_play(); return 1; }
void TextToSpeech::make_wav(const std::string& sentence, int fperiod) { /* sentence */ const char *talk_str = sentence.c_str(); /* directory name of dictionary */ const char *dn_mecab = dic_dir_.c_str(); /* file names of models */ std::string fn_ms_dur_str = voice_dir_ + "/dur.pdf"; std::string fn_ms_mgc_str = voice_dir_ + "/mgc.pdf"; std::string fn_ms_lf0_str = voice_dir_ + "/lf0.pdf"; const char *fn_ms_dur = fn_ms_dur_str.c_str(); const char *fn_ms_mgc = fn_ms_mgc_str.c_str(); const char *fn_ms_lf0 = fn_ms_lf0_str.c_str(); const char *fn_ms_lpf = NULL; /* file names of trees */ std::string fn_ts_dur_str = voice_dir_ + "/tree-dur.inf"; std::string fn_ts_mgc_str = voice_dir_ + "/tree-mgc.inf"; std::string fn_ts_lf0_str = voice_dir_ + "/tree-lf0.inf"; const char *fn_ts_dur = fn_ts_dur_str.c_str(); const char *fn_ts_mgc = fn_ts_mgc_str.c_str(); const char *fn_ts_lf0 = fn_ts_lf0_str.c_str(); const char *fn_ts_lpf = NULL; /* file names of windows */ const int FN_WS_BUF_SIZE = 3; std::string fn_ws_mgc_str[FN_WS_BUF_SIZE]; std::string fn_ws_lf0_str[FN_WS_BUF_SIZE]; const char *fn_ws_mgc[FN_WS_BUF_SIZE]; const char *fn_ws_lf0[FN_WS_BUF_SIZE]; for (int i = 0; i < FN_WS_BUF_SIZE; ++i) { std::stringstream ss1; ss1 << voice_dir_ << "/mgc.win" << i + 1; fn_ws_mgc_str[i] = ss1.str(); fn_ws_mgc[i] = fn_ws_mgc_str[i].c_str(); std::stringstream ss2; ss2 << voice_dir_ << "/lf0.win" << i + 1; fn_ws_lf0_str[i] = ss2.str(); fn_ws_lf0[i] = fn_ws_lf0_str[i].c_str(); } const char **fn_ws_lpf = NULL; int num_ws_mgc = FN_WS_BUF_SIZE, num_ws_lf0 = FN_WS_BUF_SIZE, num_ws_lpf = 0; /* file names of global variance */ std::string fn_ms_gvm_str = voice_dir_ + "/gv-mgc.pdf"; std::string fn_ms_gvf_str = voice_dir_ + "/gv-lf0.pdf"; const char *fn_ms_gvm = fn_ms_gvm_str.c_str(); const char *fn_ms_gvf = fn_ms_gvf_str.c_str(); const char *fn_ms_gvl = NULL; /* file names of global variance trees */ std::string fn_ts_gvm_str = voice_dir_ + "/tree-gv-mgc.inf"; std::string fn_ts_gvf_str = voice_dir_ + "/tree-gv-lf0.inf"; const char *fn_ts_gvm = fn_ts_gvm_str.c_str(); const char *fn_ts_gvf = fn_ts_gvf_str.c_str(); const char *fn_ts_gvl = NULL; /* file names of global variance switch */ std::string fn_gv_switch_str = voice_dir_ + "/gv-switch.inf"; const char *fn_gv_switch = fn_gv_switch_str.c_str(); /* global parameter */ int sampling_rate = params_.sampling_rate; double alpha = params_.alpha; int stage = params_.stage; double beta = params_.beta; int audio_buff_size = params_.audio_buff_size; double uv_threshold = params_.uv_threshold; double gv_weight_mgc = params_.gv_weight_mgc; double gv_weight_lf0 = params_.gv_weight_lf0; double gv_weight_lpf = params_.gv_weight_lpf; HTS_Boolean use_log_gain = FALSE; /* initialize and load */ initialize(sampling_rate, fperiod, alpha, stage, beta, audio_buff_size, uv_threshold, use_log_gain, gv_weight_mgc, gv_weight_lf0, gv_weight_lpf); load(dn_mecab, fn_ms_dur, fn_ts_dur, fn_ms_mgc, fn_ts_mgc, fn_ws_mgc, num_ws_mgc, fn_ms_lf0, fn_ts_lf0, fn_ws_lf0, num_ws_lf0, fn_ms_lpf, fn_ts_lpf, fn_ws_lpf, num_ws_lpf, fn_ms_gvm, fn_ts_gvm, fn_ms_gvl, fn_ts_gvl, fn_ms_gvf, fn_ts_gvf, fn_gv_switch); /* init alsa player */ play_info_t play_info; play_h_ = play_init(&play_info, "default", SND_PCM_FORMAT_S16_LE, 1, sampling_rate, audio_buff_size, 8); /* synthesis */ synthesis(talk_str); }
// this is called from main event handler u8 app_launch(u8 firstrun) { print_dbg("\r\n launching app with firstrun: "); print_dbg_ulong(firstrun); // net_print(); render_boot("BEES"); render_boot(versionString); while (!sd_mmc_spi_mem_check()) { render_boot("waiting for SD card..."); } if(firstrun) { render_boot("launching app, first run"); print_dbg("\r\n first run, writing nonvolatile data..."); ///... write param scaler data // this is done at firstrun instead of being linked statically, // so that users can tune scaler data offline without recompiling render_boot("init param scaling data..."); flash_init_scaler_data(); print_dbg("\r\n first run, try and load default DSP"); render_boot("launching default DSP"); //// startup using default DSP name files_load_dsp_name(DEFAULT_LDR); render_boot("waiting for DSP init..."); bfin_wait_ready(); // print_dbg("\r\n enable DSP audio..."); render_boot("enabling audio"); bfin_enable(); } else { app_pause(); /// blackfin should clear ready pin ASAP on boot. /// but give it a moment to accomplish that. delay_ms(2); /// read the default scene from sd card /// this also attempts to load associated .ldr render_boot("reading default scene"); print_dbg("\r\n loading default scene. current module name from sceneData: "); print_dbg(sceneData->desc.moduleName); scene_read_default(); delay_ms(2); app_resume(); } // init pages (fill graphics buffers) render_boot("initializing gfx"); print_dbg("\r\n pages_init..."); pages_init(); print_dbg("\r\n play_init..."); play_init(); // enable timers print_dbg("\r\n enable app timers..."); render_boot("enabling app timers"); init_app_timers(); // pull up power control pin, enabling soft-powerdown // gpio_set_gpio_pin(POWER_CTL_PIN); // assign app event handlers print_dbg("\r\n assigning handlers... "); render_boot("assigning UI handlers"); assign_bees_event_handlers(); // update page rendering and handlers... pages_reselect(); // start in play mode if not firstrun if(!firstrun) pages_toggle_play(); return 1; }