コード例 #1
0
ファイル: main.c プロジェクト: tsbelanger/Alfredo
void show_window(GtkButton *button, gpointer data)
{
        int i;
        char *name;
        unsigned long len;
        Window *windows;
        Atom atom;
        XWindowAttributes attr;
        XEvent xev;

        XFetchName(disp, (Window) data, &name);
        windows =  (Window*) get_windows(&len);

        g_print ("Raising: [%s]\n", name);

        for (i = 0; i < (int) len; i++) {
                if ((Window) data != windows[i]) {
                        XLowerWindow(disp, windows[i]);
                }
        }

        XRaiseWindow(disp, (Window) data);
        XFlush(disp);
        XSync(disp, False);
}
コード例 #2
0
ファイル: dawm.c プロジェクト: dstenb/dawm
void
init(const char *_cmd)
{
	x11_init();

	checkotherwm();

	cmd = _cmd;

	/* Setup the motion struct */
	motion = xcalloc(1, sizeof(struct motion));
	motion->type = NoMotion;

	sysinfo_init();

	clients_init();
	bars_init(settings()->barfont);
	launcher_init();

	/* Select wvents to handle */
	XSelectInput(dpy, root, WM_EVENT_MASK);

	/* Setup cursors */
	cursors_init();
	cursor_set(root, NormalCursor);

	/* Setup key bindings */
	keys = settings()->keys;
	key_init();
	key_grab_all(keys);

	/* Init atoms and EWMH */
	atoms_init();
	ewmh_init(wm_name);

	/* Init program lists */
	program_init(getenv("PATH"));

	/* Create monitors */
	create_monitors();

	/* Init ewmh desktop functionality */
	ewmh_root_set_number_of_desktops(
			monitor_count(mons) * N_WORKSPACES);
	ewmh_root_set_current_desktop(0);

	get_windows();

	set_environment();
}
コード例 #3
0
//
//	終了する
//
void ExampleApplication::on_menu_file_quit()
{
  std::cout << G_STRFUNC << std::endl;
  quit(); // Not really necessary, when Gtk::Widget::hide() is called.

  // Gio::Application::quit() will make Gio::Application::run() return,
  // but it's a crude way of ending the program. The window is not removed
  // from the application. Neither the window's nor the application's
  // destructors will be called, because there will be remaining reference
  // counts in both of them. If we want the destructors to be called, we
  // must remove the window from the application. One way of doing this
  // is to hide the window.
  std::vector<Gtk::Window*> windows = get_windows();
  if (windows.size() > 0)
    windows[0]->hide(); // In this simple case, we know there is only one window.
}
コード例 #4
0
ファイル: lsw.c プロジェクト: laserswald/wm-core
static void
list_windows(xcb_window_t w, int listmask)
{
	int i, wn;
	xcb_window_t *wc;

	wn = get_windows(conn, w, &wc);

	if (wc == NULL)
		errx(1, "0x%08x: unable to retrieve children", w);

	for (i=0; i<wn; i++) {
		if (should_list(wc[i], listmask))
			printf("0x%08x\n", wc[i]);
	}
}
コード例 #5
0
ファイル: wew.c プロジェクト: laserswald/opt
void
handle_events(void)
{
	int i, wn;
	xcb_window_t *wc, wid = 0;
	xcb_generic_event_t *e;
	xcb_create_notify_event_t *ec;

	/*
	 * We need to get notifed of window creations, no matter what, because
	 * we need to register the event mask on all newly created windows
	 */
	register_events(scr->root, XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY);

	if (mask & XCB_EVENT_MASK_BUTTON_PRESS) {
		xcb_grab_button(conn, 0, scr->root,
		                XCB_EVENT_MASK_BUTTON_PRESS |
		                XCB_EVENT_MASK_BUTTON_RELEASE,
		                XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC,
		                scr->root, XCB_NONE, 1, XCB_NONE);
	}

	/* register the events on all mapped windows */
	wn = get_windows(conn, scr->root, &wc);
	for (i=0; i<wn; i++)
		register_events(wc[i], mask);

	xcb_flush(conn);

	for(;;) {
		e = xcb_wait_for_event(conn);

		switch (e->response_type & ~0x80)
		{
			case XCB_CREATE_NOTIFY:
				ec = (xcb_create_notify_event_t*)e;
				register_events(ec->window, mask);
			default:
				wid = get_window_id(e);
		}

		if (wid > 0) {
			printf("%d:0x%08x\n", e->response_type, wid);
			fflush(stdout);
		}
	}
}
コード例 #6
0
ファイル: main.c プロジェクト: tsbelanger/Alfredo
void listen_keyboard(void *unused)
{
        int i;
        unsigned long len;
        int screen = DefaultScreen(disp);
        Window root_window = DefaultRootWindow(disp);
        Window *list;
        char *name;
        XEvent event;

        XGrabKeyboard(disp, root_window, False, GrabModeAsync, GrabModeAsync, CurrentTime);

        while (1) {
                XNextEvent(disp, &event);

                if (event.type == KeyPress) {
                        printf("Key pressed: %d\n", event.xkey.keycode);

                        /* ESC key */
                        if (event.xkey.keycode == 0x09) {
                                list = (Window*) get_windows(&len);

                                for (i = 0; i < (int) len; i++) {
                                        XFetchName(disp, list[i], &name);

                                        if (name != NULL && g_ascii_strcasecmp(name, "Alfredo") == 0) {
                                                show_window(NULL, &list[i]);
                                        }

                                        free(name);
                                }
                        }
                }
        }

        XUngrabKeyboard(disp, CurrentTime);
}
コード例 #7
0
ファイル: main.c プロジェクト: tsbelanger/Alfredo
void update_listbox(GtkEntry *entry, GdkEventKey *event, gpointer listbox)
{
        GList *elem, *buttons;
        Window *windows;
        int i;
        int num_items = 0;
        unsigned long len;
        char *name;

        windows =  (Window*) get_windows(&len);
        buttons = gtk_container_get_children(GTK_CONTAINER(listbox));

        for (elem = buttons; elem; elem = elem->next) {
                GtkWidget *button = elem->data;
                gtk_widget_destroy(button);
        }

        if (strlen(gtk_entry_get_text(entry)) == 0) {
                /* Loop through current windows */
                for (i = 0; i < (int) len; i++) {
                        if (num_items > LIST_MAX) {
                                i = BIN_MAX;
                        } else {
                                XFetchName(disp, windows[i], &name);

                                if (name != NULL) {
                                        GtkWidget *newbutton = gtk_button_new_with_label((char *) name);
                                        g_signal_connect(newbutton, "clicked", G_CALLBACK (show_window), (gpointer) windows[i]);
                                        gtk_container_add(GTK_CONTAINER(listbox), newbutton);

                                        num_items++;
                                }

                                free(name);
                        }
                }
        } else {
                /* Loop through current windows */
                for (i = 0; i < (int) len; i++) {
                        if (num_items > LIST_MAX) {
                                i = BIN_MAX;
                        } else {
                                XFetchName(disp, windows[i], &name);

                                if (name != NULL && strstr(name, gtk_entry_get_text(entry)) != NULL) {
                                        GtkWidget *newbutton = gtk_button_new_with_label((char *) name);
                                        g_signal_connect(newbutton, "clicked", G_CALLBACK (show_window), (gpointer) windows[i]);
                                        gtk_container_add(GTK_CONTAINER(listbox), newbutton);

                                        num_items++;
                                }

                                free(name);
                        }
                }

                /* Loop through binaries */
                for (i = 0; i < BIN_MAX; i++) {
                        if (num_items > LIST_MAX) {
                                i = BIN_MAX;
                        } else {
                                if (strstr(binaries[i], gtk_entry_get_text(entry)) != NULL) {
                                        GtkWidget *newbutton = gtk_button_new_with_label((char *) binaries[i]);
                                        g_signal_connect(newbutton, "clicked", G_CALLBACK (execute_command), (gpointer) binaries[i]);
                                        gtk_container_add(GTK_CONTAINER(listbox), newbutton);

                                        num_items++;
                                }
                        }
                }
        }

        gtk_widget_show_all(listbox);
        g_print("Input: %s", gtk_entry_get_text(entry));
}
コード例 #8
0
static void load_hts_engine_data(const SMap *data,
								 SHTSEngineMESynthUttProc105 *HTSsynth,
								 const char *voice_base_path, s_erc *error)
{
	const SMap *tmp;
	const SList *trees;
	const SList *pdfs;
	const SList *windows;
	int num;
	int i;
	char **ctrees;
	char **cpdfs;
	char **cwindows;
	int num_win;
	const char *gv;
	const char *gv_tree;
	const char *gv_switch;
	const char *pd_filter;
	HTS_Engine *engine = &(HTSsynth->engine);


	S_CLR_ERR(error);

	/* duration */
	tmp = S_MAP(SMapGetObjectDef(data, "duration", NULL, error));
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"SMapGetObjectDef\" failed"))
		return;

	if (tmp == NULL)
	{
		S_CTX_ERR(error, S_FAILURE,
				  "load_hts_engine_data",
				  "Failed to find 'duration' HTS Engine data");
		return;
	}

	trees = S_LIST(SMapGetObjectDef(tmp, "trees", NULL, error));
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"SMapGetObjectDef\" failed"))
		return;

	if (trees == NULL)
	{
		S_CTX_ERR(error, S_FAILURE,
				  "load_hts_engine_data",
				  "Failed to find 'duration:trees' HTS Engine data");
		return;
	}

	pdfs = S_LIST(SMapGetObjectDef(tmp, "pdfs", NULL, error));
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"SMapGetObjectDef\" failed"))
		return;

	if (pdfs == NULL)
	{
		S_CTX_ERR(error, S_FAILURE,
				  "load_hts_engine_data",
				  "Failed to find 'duration:pdfs' HTS Engine data");
		return;
	}

	get_trees_pdfs(trees, pdfs, &ctrees, &cpdfs, &num, voice_base_path, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"get_trees_pdfs\" failed"))
		return;

	HTS_Engine_load_duration_from_fn(engine, cpdfs, ctrees, 1);
	for (i = 0; i < num; i++)
	{
		S_FREE(ctrees[i]);
		S_FREE(cpdfs[i]);
	}

	S_FREE(ctrees);
	S_FREE(cpdfs);


	/* log F0 */
	tmp = S_MAP(SMapGetObjectDef(data, "log F0", NULL, error));
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"SMapGetObjectDef\" failed"))
		return;

	if (tmp == NULL)
	{
		S_CTX_ERR(error, S_FAILURE,
				  "load_hts_engine_data",
				  "Failed to find 'log F0' HTS Engine data");
		return;
	}

	trees = S_LIST(SMapGetObjectDef(tmp, "trees", NULL, error));
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"SMapGetObjectDef\" failed"))
		return;

	if (trees == NULL)
	{
		S_CTX_ERR(error, S_FAILURE,
				  "load_hts_engine_data",
				  "Failed to find 'log F0:trees' HTS Engine data");
		return;
	}

	pdfs = S_LIST(SMapGetObjectDef(tmp, "pdfs", NULL, error));
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"SMapGetObjectDef\" failed"))
		return;

	if (pdfs == NULL)
	{
		S_CTX_ERR(error, S_FAILURE,
				  "load_hts_engine_data",
				  "Failed to find 'log F0:pdfs' HTS Engine data");
		return;
	}

	get_trees_pdfs(trees, pdfs, &ctrees, &cpdfs, &num, voice_base_path, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"get_trees_pdfs\" failed"))
		return;

	windows = S_LIST(SMapGetObjectDef(tmp, "windows", NULL, error));
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"SMapGetObjectDef\" failed"))
		return;

	if (windows == NULL)
	{
		S_CTX_ERR(error, S_FAILURE,
				  "load_hts_engine_data",
				  "Failed to find 'log F0:windows' HTS Engine data");
		return;
	}

	get_windows(windows, &cwindows, &num_win, voice_base_path, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"get_windows\" failed"))
		return;

	/* log f0 is stream 1, and msd_flag is TRUE */
	HTS_Engine_load_parameter_from_fn(engine, cpdfs, ctrees, cwindows,
									  1, TRUE, num_win, 1);

	for (i = 0; i < num; i++)
	{
		S_FREE(ctrees[i]);
		S_FREE(cpdfs[i]);
	}

	S_FREE(ctrees);
	S_FREE(cpdfs);

	for (i = 0; i < num_win; i++)
		S_FREE(cwindows[i]);

	S_FREE(cwindows);

	/* log f0 gv */
	gv = SMapGetStringDef(tmp, "gv-lf0", NULL, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"SMapGetStringDef\" failed"))
		return;

	/* log f0 gv tree */
	gv_tree = SMapGetStringDef(tmp, "tree-gv-lf0", NULL, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"SMapGetStringDef\" failed"))
		return;

	if (gv != NULL)
	{
		char *combined_path_gv;
		char *combined_path_gv_tree;


		/* get data path, the one in the config file may be relative
		 * to the voice base path
		 */
		combined_path_gv = s_path_combine(voice_base_path, gv,
										  error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "load_hts_engine_data",
					  "Call to \"s_path_combine\" failed"))
			return;

		if (gv_tree != NULL)
		{
			/* get data path, the one in the config file may be relative
			 * to the voice base path
			 */
			combined_path_gv_tree = s_path_combine(voice_base_path, gv_tree,
												   error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "load_hts_engine_data",
						  "Call to \"s_path_combine\" failed"))
			{
				S_FREE(combined_path_gv);
				return;
			}
		}
		else
		{
			combined_path_gv_tree = NULL;
		}


		HTS_Engine_load_gv_from_fn(engine, (char**)&combined_path_gv,
								   (char**)&combined_path_gv_tree, 1, 1);
		S_FREE(combined_path_gv);
		if (combined_path_gv_tree != NULL)
			S_FREE(combined_path_gv_tree);
	}

	/* spectrum */
	tmp = S_MAP(SMapGetObjectDef(data, "spectrum", NULL, error));
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"SMapGetObjectDef\" failed"))
		return;

	if (tmp == NULL)
	{
		S_CTX_ERR(error, S_FAILURE,
				  "load_hts_engine_data",
				  "Failed to find 'spectrum' HTS Engine data");
		return;
	}

	trees = S_LIST(SMapGetObjectDef(tmp, "trees", NULL, error));
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"SMapGetObjectDef\" failed"))
		return;

	if (trees == NULL)
	{
		S_CTX_ERR(error, S_FAILURE,
				  "load_hts_engine_data",
				  "Failed to find 'spectrum:trees' HTS Engine data");
		return;
	}

	pdfs = S_LIST(SMapGetObjectDef(tmp, "pdfs", NULL, error));
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"SMapGetObjectDef\" failed"))
		return;

	if (pdfs == NULL)
	{
		S_CTX_ERR(error, S_FAILURE,
				  "load_hts_engine_data",
				  "Failed to find 'spectrum:pdfs' HTS Engine data");
		return;
	}

	get_trees_pdfs(trees, pdfs, &ctrees, &cpdfs, &num, voice_base_path, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"get_trees_pdfs\" failed"))
		return;

	windows = S_LIST(SMapGetObjectDef(tmp, "windows", NULL, error));
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"SMapGetObjectDef\" failed"))
		return;

	if (windows == NULL)
	{
		S_CTX_ERR(error, S_FAILURE,
				  "load_hts_engine_data",
				  "Failed to find 'spectrum:windows' HTS Engine data");
		return;
	}

	get_windows(windows, &cwindows, &num_win, voice_base_path, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"get_windows\" failed"))
		return;

	/* spectrum is stream 0, and msd_flag is FALSE */
	HTS_Engine_load_parameter_from_fn(engine, cpdfs, ctrees, cwindows,
									  0, FALSE, num_win, 1);

	for (i = 0; i < num; i++)
	{
		S_FREE(ctrees[i]);
		S_FREE(cpdfs[i]);
	}

	S_FREE(ctrees);
	S_FREE(cpdfs);

	for (i = 0; i < num_win; i++)
		S_FREE(cwindows[i]);

	S_FREE(cwindows);

	/* spectrum gv */
	gv = SMapGetStringDef(tmp, "gv-mgc", NULL, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"SMapGetStringDef\" failed"))
		return;

	/* spectrum gv tree */
	gv_tree = SMapGetStringDef(tmp, "tree-gv-mgc", NULL, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"SMapGetStringDef\" failed"))
		return;

	if (gv != NULL)
	{
		char *combined_path_gv;
		char *combined_path_gv_tree;


		/* get data path, the one in the config file may be relative
		 * to the voice base path
		 */
		combined_path_gv = s_path_combine(voice_base_path, gv,
										  error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "load_hts_engine_data",
					  "Call to \"s_path_combine\" failed"))
			return;

		if (gv_tree != NULL)
		{
			/* get data path, the one in the config file may be relative
			 * to the voice base path
			 */
			combined_path_gv_tree = s_path_combine(voice_base_path, gv_tree,
												   error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "load_hts_engine_data",
						  "Call to \"s_path_combine\" failed"))
			{
				S_FREE(combined_path_gv);
				return;
			}
		}
		else
		{
			combined_path_gv_tree = NULL;
		}


		HTS_Engine_load_gv_from_fn(engine, (char**)&combined_path_gv,
								   (char**)&combined_path_gv_tree, 0, 1);
		S_FREE(combined_path_gv);
		if (combined_path_gv_tree != NULL)
			S_FREE(combined_path_gv_tree);
	}

	/* band strengths */
	if (HTSsynth->me == TRUE)
	{
		const char *me_filter;


		tmp = S_MAP(SMapGetObjectDef(data, "strengths", NULL, error));
		if (S_CHK_ERR(error, S_CONTERR,
					  "load_hts_engine_data",
					  "Call to \"SMapGetObjectDef\" failed"))
			return;

		if (tmp == NULL)
		{
			S_CTX_ERR(error, S_FAILURE,
					  "load_hts_engine_data",
					  "Failed to find 'strengths' HTS Engine data");
			return;
		}

		trees = S_LIST(SMapGetObjectDef(tmp, "trees", NULL, error));
		if (S_CHK_ERR(error, S_CONTERR,
					  "load_hts_engine_data",
					  "Call to \"SMapGetObjectDef\" failed"))
			return;

		if (trees == NULL)
		{
			S_CTX_ERR(error, S_FAILURE,
					  "load_hts_engine_data",
					  "Failed to find 'strengths:trees' HTS Engine data");
			return;
		}

		pdfs = S_LIST(SMapGetObjectDef(tmp, "pdfs", NULL, error));
		if (S_CHK_ERR(error, S_CONTERR,
					  "load_hts_engine_data",
					  "Call to \"SMapGetObjectDef\" failed"))
			return;

		if (pdfs == NULL)
		{
			S_CTX_ERR(error, S_FAILURE,
					  "load_hts_engine_data",
					  "Failed to find 'strengths:pdfs' HTS Engine data");
			return;
		}

		get_trees_pdfs(trees, pdfs, &ctrees, &cpdfs, &num, voice_base_path, error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "load_hts_engine_data",
					  "Call to \"get_trees_pdfs\" failed"))
			return;

		windows = S_LIST(SMapGetObjectDef(tmp, "windows", NULL, error));
		if (S_CHK_ERR(error, S_CONTERR,
					  "load_hts_engine_data",
					  "Call to \"SMapGetObjectDef\" failed"))
			return;

		if (windows == NULL)
		{
			S_CTX_ERR(error, S_FAILURE,
					  "load_hts_engine_data",
					  "Failed to find 'strengths:windows' HTS Engine data");
			return;
		}

		get_windows(windows, &cwindows, &num_win, voice_base_path, error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "load_hts_engine_data",
					  "Call to \"get_windows\" failed"))
			return;

		/* strengths is stream 2, and msd_flag is FALSE */
		HTS_Engine_load_parameter_from_fn(engine, cpdfs, ctrees, cwindows,
										  2, FALSE, num_win, 1);

		for (i = 0; i < num; i++)
		{
			S_FREE(ctrees[i]);
			S_FREE(cpdfs[i]);
		}

		S_FREE(ctrees);
		S_FREE(cpdfs);

		for (i = 0; i < num_win; i++)
			S_FREE(cwindows[i]);

		S_FREE(cwindows);

		/* strengths gv */
		gv = SMapGetStringDef(tmp, "gv-str", NULL, error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "load_hts_engine_data",
					  "Call to \"SMapGetStringDef\" failed"))
			return;

		/* strengths gv tree */
		gv_tree = SMapGetStringDef(tmp, "tree-gv-str", NULL, error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "load_hts_engine_data",
					  "Call to \"SMapGetStringDef\" failed"))
			return;

		if (gv != NULL)
		{
			char *combined_path_gv;
			char *combined_path_gv_tree;


			/* get data path, the one in the config file may be relative
			 * to the voice base path
			 */
			combined_path_gv = s_path_combine(voice_base_path, gv,
											  error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "load_hts_engine_data",
						  "Call to \"s_path_combine\" failed"))
				return;

			if (gv_tree != NULL)
			{
				/* get data path, the one in the config file may be relative
				 * to the voice base path
				 */
				combined_path_gv_tree = s_path_combine(voice_base_path, gv_tree,
													   error);
				if (S_CHK_ERR(error, S_CONTERR,
							  "load_hts_engine_data",
							  "Call to \"s_path_combine\" failed"))
				{
					S_FREE(combined_path_gv);
					return;
				}
			}
			else
			{
				combined_path_gv_tree = NULL;
			}


			HTS_Engine_load_gv_from_fn(engine, (char**)&combined_path_gv,
									   (char**)&combined_path_gv_tree, 2, 1);
			S_FREE(combined_path_gv);
			if (combined_path_gv_tree != NULL)
				S_FREE(combined_path_gv_tree);
		}

		/* mixed excitation filter */
		me_filter = SMapGetStringDef(tmp, "mixed excitation filter", NULL, error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "load_hts_engine_data",
					  "Call to \"SMapGetStringDef\" failed"))
			return;

		if (me_filter != NULL)
		{
			char *combined_path;

			/* get data path, the one in the config file may be relative
			 * to the voice base path
			 */
			combined_path = s_path_combine(voice_base_path, me_filter,
										   error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "load_hts_engine_data",
						  "Call to \"s_path_combine\" failed"))
				return;

			HTS_Engine_load_me_filter_from_fn(combined_path, &(HTSsynth->me_filter),
											  &(HTSsynth->me_num_filters), &(HTSsynth->me_filter_order));
			S_FREE(combined_path);

			/* allocate memory for other filter buffers */
			filter_constructor(HTSsynth, error);
			if (S_CHK_ERR(error, S_CONTERR,
						  "load_hts_engine_data",
						  "Call to \"filter_constructor\" failed"))
				return;
		}
		else
		{
			S_CTX_ERR(error, S_FAILURE,
					  "load_hts_engine_data",
					  "Failed to find 'strengths:mixed excitation filter' HTS Engine data");
			return;
		}
	}

	/* gv switch */
	gv_switch = SMapGetStringDef(data, "gv-switch", NULL, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"SMapGetObjectDef\" failed"))
		return;

	if (gv_switch != NULL)
	{
		char *combined_path;


		/* get data path, the one in the config file may be relative
		 * to the voice base path
		 */
		combined_path = s_path_combine(voice_base_path, gv_switch,
									   error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "load_hts_engine_data",
					  "Call to \"s_path_combine\" failed"))
			return;

		HTS_Engine_load_gv_switch_from_fn(engine, combined_path);
		S_FREE(combined_path);
	}

	/* pulse dispersion filter */
	pd_filter = SMapGetStringDef(data, "pulse dispersion filter", NULL, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"SMapGetObjectDef\" failed"))
		return;

	if (pd_filter != NULL)
	{
		char *combined_path;


		/* get data path, the one in the config file may be relative
		 * to the voice base path
		 */
		combined_path = s_path_combine(voice_base_path, pd_filter,
									   error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "load_hts_engine_data",
					  "Call to \"s_path_combine\" failed"))
			return;

		HTS_Engine_load_pd_filter_from_fn(combined_path, &(HTSsynth->pd_filter),
										  &(HTSsynth->pd_filter_order));
		S_FREE(combined_path);
	}
}
コード例 #9
0
static void load_hts_engine_data(const SMap *data, HTS_Engine *engine,
								 const char *voice_base_path, s_erc *error)
{
	const SMap *tmp;
	const SList *trees;
	const SList *pdfs;
	const SList *windows;
	int num;
	int i;
	char **ctrees;
	char **cpdfs;
	char **cwindows;
	int num_win;
	const char *gv;
	const char *gv_switch;


	S_CLR_ERR(error);

	/* duration */
	tmp = S_MAP(SMapGetObjectDef(data, "duration", NULL, error));
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"SMapGetObjectDef\" failed"))
		return;

	if (tmp == NULL)
	{
		S_CTX_ERR(error, S_FAILURE,
				  "load_hts_engine_data",
				  "Failed to find 'duration' HTS Engine data");
		return;
	}

	trees = S_LIST(SMapGetObjectDef(tmp, "trees", NULL, error));
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"SMapGetObjectDef\" failed"))
		return;

	if (trees == NULL)
	{
		S_CTX_ERR(error, S_FAILURE,
				  "load_hts_engine_data",
				  "Failed to find 'duration:trees' HTS Engine data");
		return;
	}

	pdfs = S_LIST(SMapGetObjectDef(tmp, "pdfs", NULL, error));
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"SMapGetObjectDef\" failed"))
		return;

	if (pdfs == NULL)
	{
		S_CTX_ERR(error, S_FAILURE,
				  "load_hts_engine_data",
				  "Failed to find 'duration:pdfs' HTS Engine data");
		return;
	}

	get_trees_pdfs(trees, pdfs, &ctrees, &cpdfs, &num, voice_base_path, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"get_trees_pdfs\" failed"))
		return;

	HTS_Engine_load_duration_from_fn(engine, cpdfs, ctrees, 1);
	for (i = 0; i < num; i++)
	{
		S_FREE(ctrees[i]);
		S_FREE(cpdfs[i]);
	}

	S_FREE(ctrees);
	S_FREE(cpdfs);


	/* log F0 */
	tmp = S_MAP(SMapGetObjectDef(data, "log F0", NULL, error));
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"SMapGetObjectDef\" failed"))
		return;

	if (tmp == NULL)
	{
		S_CTX_ERR(error, S_FAILURE,
				  "load_hts_engine_data",
				  "Failed to find 'log F0' HTS Engine data");
		return;
	}

	trees = S_LIST(SMapGetObjectDef(tmp, "trees", NULL, error));
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"SMapGetObjectDef\" failed"))
		return;

	if (trees == NULL)
	{
		S_CTX_ERR(error, S_FAILURE,
				  "load_hts_engine_data",
				  "Failed to find 'log F0:trees' HTS Engine data");
		return;
	}

	pdfs = S_LIST(SMapGetObjectDef(tmp, "pdfs", NULL, error));
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"SMapGetObjectDef\" failed"))
		return;

	if (pdfs == NULL)
	{
		S_CTX_ERR(error, S_FAILURE,
				  "load_hts_engine_data",
				  "Failed to find 'log F0:pdfs' HTS Engine data");
		return;
	}

	get_trees_pdfs(trees, pdfs, &ctrees, &cpdfs, &num, voice_base_path, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"get_trees_pdfs\" failed"))
		return;

	windows = S_LIST(SMapGetObjectDef(tmp, "windows", NULL, error));
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"SMapGetObjectDef\" failed"))
		return;

	if (windows == NULL)
	{
		S_CTX_ERR(error, S_FAILURE,
				  "load_hts_engine_data",
				  "Failed to find 'log F0:windows' HTS Engine data");
		return;
	}

	get_windows(windows, &cwindows, &num_win, voice_base_path, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"get_windows\" failed"))
		return;

	/* log f0 is stream 1, and msd_flag is TRUE */
	HTS_Engine_load_parameter_from_fn(engine, cpdfs, ctrees, cwindows,
									  1, TRUE, num_win, 1);

	for (i = 0; i < num; i++)
	{
		S_FREE(ctrees[i]);
		S_FREE(cpdfs[i]);
	}

	S_FREE(ctrees);
	S_FREE(cpdfs);

	for (i = 0; i < num_win; i++)
		S_FREE(cwindows[i]);

	S_FREE(cwindows);

	/* log f0 gv */
	gv = SMapGetStringDef(tmp, "gv-lf0", NULL, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"SMapGetStringDef\" failed"))
		return;

	if (gv != NULL)
	{
		char *combined_path;

		/* get data path, the one in the config file may be relative
		 * to the voice base path
		 */
		combined_path = s_path_combine(voice_base_path, gv,
									   error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "load_hts_engine_data",
					  "Call to \"s_path_combine\" failed"))
			return;

		HTS_Engine_load_gv_from_fn(engine, (char**)&combined_path, NULL, 1, 1);
		S_FREE(combined_path);
	}

	/* spectrum */
	tmp = S_MAP(SMapGetObjectDef(data, "spectrum", NULL, error));
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"SMapGetObjectDef\" failed"))
		return;

	if (tmp == NULL)
	{
		S_CTX_ERR(error, S_FAILURE,
				  "load_hts_engine_data",
				  "Failed to find 'spectrum' HTS Engine data");
		return;
	}

	trees = S_LIST(SMapGetObjectDef(tmp, "trees", NULL, error));
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"SMapGetObjectDef\" failed"))
		return;

	if (trees == NULL)
	{
		S_CTX_ERR(error, S_FAILURE,
				  "load_hts_engine_data",
				  "Failed to find 'spectrum:trees' HTS Engine data");
		return;
	}

	pdfs = S_LIST(SMapGetObjectDef(tmp, "pdfs", NULL, error));
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"SMapGetObjectDef\" failed"))
		return;

	if (pdfs == NULL)
	{
		S_CTX_ERR(error, S_FAILURE,
				  "load_hts_engine_data",
				  "Failed to find 'spectrum:pdfs' HTS Engine data");
		return;
	}

	get_trees_pdfs(trees, pdfs, &ctrees, &cpdfs, &num, voice_base_path, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"get_trees_pdfs\" failed"))
		return;

	windows = S_LIST(SMapGetObjectDef(tmp, "windows", NULL, error));
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"SMapGetObjectDef\" failed"))
		return;

	if (windows == NULL)
	{
		S_CTX_ERR(error, S_FAILURE,
				  "load_hts_engine_data",
				  "Failed to find 'spectrum:windows' HTS Engine data");
		return;
	}

	get_windows(windows, &cwindows, &num_win, voice_base_path, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"get_windows\" failed"))
		return;

	/* spectrum is stream 0, and msd_flag is FALSE */
	HTS_Engine_load_parameter_from_fn(engine, cpdfs, ctrees, cwindows,
									  0, FALSE, num_win, 1);

	for (i = 0; i < num; i++)
	{
		S_FREE(ctrees[i]);
		S_FREE(cpdfs[i]);
	}

	S_FREE(ctrees);
	S_FREE(cpdfs);

	for (i = 0; i < num_win; i++)
		S_FREE(cwindows[i]);

	S_FREE(cwindows);

	/* spectrum gv */
	gv = SMapGetStringDef(tmp, "gv-mgc", NULL, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"SMapGetStringDef\" failed"))
		return;

	if (gv != NULL)
	{
		char *combined_path;

		/* get data path, the one in the config file may be relative
		 * to the voice base path
		 */
		combined_path = s_path_combine(voice_base_path, gv,
									   error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "load_hts_engine_data",
					  "Call to \"s_path_combine\" failed"))
			return;

		HTS_Engine_load_gv_from_fn(engine, (char**)&combined_path, NULL, 0, 1);
		S_FREE(combined_path);
	}

	/* gv switch */
	gv_switch = SMapGetStringDef(data, "gv-switch", NULL, error);
	if (S_CHK_ERR(error, S_CONTERR,
				  "load_hts_engine_data",
				  "Call to \"SMapGetObjectDef\" failed"))
		return;

	if (gv_switch != NULL)
	{
		char *combined_path;


		/* get data path, the one in the config file may be relative
		 * to the voice base path
		 */
		combined_path = s_path_combine(voice_base_path, gv_switch,
									   error);
		if (S_CHK_ERR(error, S_CONTERR,
					  "load_hts_engine_data",
					  "Call to \"s_path_combine\" failed"))
			return;

		HTS_Engine_load_gv_switch_from_fn(engine, combined_path);
		S_FREE(combined_path);
	}
}