3 gdouble upperRegister
= 200.0;
6 GtkWidget
*buttonPlay
= glade_xml_get_widget(xml
, "buttonPlay");
11 gtk_tree_model_get(GTK_TREE_MODEL(liststore
), &mainIter
, COL_TEXT
, &string
, -1);
12 path
= g_strjoin(NULL
, RECORDPATH
, G_DIR_SEPARATOR_S
, string
, ".wav", NULL
);
14 if (g_access(path
, F_OK
) == 0) {
15 gtk_widget_set_sensitive(buttonPlay
, TRUE
);
17 gtk_widget_set_sensitive(buttonPlay
, FALSE
);
22 gtk_widget_set_sensitive(buttonPlay
, FALSE
);
26 gboolean
setButtonsTrue() {
27 GtkWidget
*buttonRecord
= glade_xml_get_widget(xml
, "buttonRecord");
28 GtkWidget
*buttonExample
= glade_xml_get_widget(xml
, "buttonExample");
30 GtkWidget
*drawingareaPitch
= glade_xml_get_widget(xml
, "drawingareaPitch");
35 gtk_widget_set_sensitive(buttonRecord
, TRUE
);
37 gtk_widget_set_sensitive(buttonExample
, TRUE
);
39 gtk_widget_queue_draw(drawingareaPitch
);
41 feedbackTXT
= g_build_filename(SCRIPTPATH
, G_DIR_SEPARATOR_S
, "feedback.txt", NULL
);
43 if (g_file_get_contents(feedbackTXT
, &contents
, NULL
, NULL
) == TRUE
) {
44 g_debug("Sets label!\n");
45 GtkWidget
*label
= glade_xml_get_widget(xml
, "labelFeedback");
46 gtk_label_set_text(GTK_LABEL(label
), contents
);
47 g_debug("Label set!\n");
48 g_unlink(feedbackTXT
);
55 gboolean
setButtonsFalse() {
56 GtkWidget
*buttonRecord
= glade_xml_get_widget(xml
, "buttonRecord");
57 GtkWidget
*buttonPlay
= glade_xml_get_widget(xml
, "buttonPlay");
58 GtkWidget
*buttonExample
= glade_xml_get_widget(xml
, "buttonExample");
59 g_debug("%s welcome!\n", __func__
);
61 gtk_widget_set_sensitive(buttonRecord
, FALSE
);
62 gtk_widget_set_sensitive(buttonPlay
, FALSE
);
63 gtk_widget_set_sensitive(buttonExample
, FALSE
);
65 g_debug("%s bye!\n", __func__
);
70 void on_buttonRecord_clicked(GtkWidget
*widget
, gpointer user_data
) {
73 gtk_tree_model_get(GTK_TREE_MODEL(liststore
), &mainIter
, COL_TEXT
, &string
, -1);
77 GtkWidget
*dialog
= gtk_message_dialog_new(NULL
,
81 "Don't have any (more) tests");
82 gtk_dialog_run (GTK_DIALOG (dialog
));
83 gtk_widget_destroy (dialog
);
86 /* Start record Thread */
88 g_debug("%s creates record", __func__
);
90 g_thread_create((GThreadFunc
)record
, NULL
, FALSE
, NULL
);
92 g_debug("%s is done", __func__
);
98 void on_buttonExample_clicked(GtkWidget
*widget
, gpointer user_data
) {
100 /* Start example Thread */
101 g_thread_create((GThreadFunc
)example
, widget
, FALSE
, NULL
);
104 void on_buttonPlay_clicked(GtkWidget
*widget
, gpointer user_data
) {
106 /* Start play Thread */
107 g_thread_create((GThreadFunc
)play
, widget
, FALSE
, NULL
);
110 gboolean
prev(GtkWidget
*previous
) {
111 gboolean ret
= FALSE
;
113 /* Code From anchient Sylpheed */
117 path
= gtk_tree_model_get_path(GTK_TREE_MODEL(liststore
), &mainIter
);
119 if ((ret
= gtk_tree_path_prev(path
)) == TRUE
) {
120 gtk_tree_model_get_iter(GTK_TREE_MODEL(liststore
), &prev
, path
);
121 if (previous
!= NULL
) {
127 gtk_tree_path_free(path
);
134 gboolean
next(GtkWidget
*next
) {
137 return gtk_tree_model_iter_next(GTK_TREE_MODEL(liststore
), &mainIter
);
139 GtkTreeIter next
= mainIter
;
140 return gtk_tree_model_iter_next(GTK_TREE_MODEL(liststore
), &next
);
147 void updateWidgets() {
148 GtkWidget
*labelFeedback
= glade_xml_get_widget(xml
, "labelFeedback");
153 gtk_tree_model_get(GTK_TREE_MODEL(liststore
), &mainIter
, COL_TEXT
, &string
, -1);
154 GString
*label
= g_string_new(string
);
155 g_string_prepend(label
, "<span size=\"xx-large\">");
156 g_string_append(label
, "</span>");
157 gtk_label_set_markup(GTK_LABEL(labelFeedback
), label
->str
);
158 g_string_free(label
, TRUE
);
162 gtk_label_set_markup(GTK_LABEL(labelFeedback
), "");
165 gtk_widget_set_sensitive(glade_xml_get_widget(xml
, "buttonRecord"), treevalid
);
166 gtk_widget_set_sensitive(glade_xml_get_widget(xml
, "buttonExample"), treevalid
);
167 gtk_widget_set_sensitive(glade_xml_get_widget(xml
, "imagemenuitemSave"), treevalid
);
168 gtk_widget_set_sensitive(glade_xml_get_widget(xml
, "imagemenuitemSaveAs"), treevalid
);
170 gtk_widget_set_sensitive(glade_xml_get_widget(xml
, "buttonPrevious"), prev(NULL
));
171 gtk_widget_set_sensitive(glade_xml_get_widget(xml
, "buttonNext"), next(NULL
));
175 gtk_widget_queue_draw(glade_xml_get_widget(xml
, "drawingareaPitch"));
178 void on_Save(GtkWidget
*chooser
, gpointer user_data
) {
179 fileSave(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(chooser
)));
182 void on_dialogAdd_close(GtkWidget
*button
, gpointer user_data
) {
183 GtkWidget
*buttonAdd
= glade_xml_get_widget(xml
, "buttonAdd");
184 gtk_widget_hide(gtk_widget_get_toplevel(button
));
185 gtk_widget_grab_focus(buttonAdd
);
188 void on_menuitemVoice_activate(GtkWidget
*widget
, gpointer user_data
) {
189 const gchar
*name
= gtk_widget_get_name(widget
);
190 GtkWidget
*drawingareaPitch
= glade_xml_get_widget(xml
, "drawingareaPitch");
191 if (g_str_equal(name
, "menuitemVoice_Male_Low") == TRUE
) upperRegister
= 150.0;
192 if (g_str_equal(name
, "menuitemVoice_Male") == TRUE
) upperRegister
= 200.0;
193 if (g_str_equal(name
, "menuitemVoice_Female") == TRUE
) upperRegister
= 300.0;
194 if (g_str_equal(name
, "menuitemVoice_Child") == TRUE
) upperRegister
= 450.0;
195 gtk_widget_queue_draw(drawingareaPitch
);
198 void paint (GtkWidget
*widget
, GdkEventExpose
*eev
, gpointer data
) {
201 gtk_tree_model_get(GTK_TREE_MODEL(liststore
), &mainIter
, COL_TEXT
, &string
, -1);
203 if (string
!= NULL
) {
205 GString
*filename
= g_string_sized_new (200);
206 GString
*cmd
= g_string_sized_new (200);
207 GString
*recordedPT
= g_string_sized_new(100);
210 g_string_printf(filename
, "%s%s%s-%0.f.PitchTier", PITCHPATH
, G_DIR_SEPARATOR_S
, string
, upperRegister
);
211 g_string_printf(recordedPT
, "%s%s%s.PitchTier", RECORDPATH
, G_DIR_SEPARATOR_S
, string
);
213 if (g_access(filename
->str
, F_OK
) == -1) {
214 /* Eigenlijk wil je de system ranzigheid vervangen door een werkende versie van dit,
215 * maar eigenlijk MOET je gewoon de praat scripts naar C omzetten ;)
219 gchar *upper = g_malloc(5);
220 g_ascii_dtostr(upper, 5, upperRegister);
222 argv[1] = testList[intTestCounter];
226 g_spawn_sync((const gchar *) SCRIPTPATH, argv, NULL, (GSpawnFlags)(G_SPAWN_SEARCH_PATH | G_SPAWN_FILE_AND_ARGV_ZERO), NULL, NULL, NULL, NULL, &exit_status, &err);*/
228 g_string_printf(cmd
, "%s DrawToneContour.praat %s %0.f", PRAATBIN
, string
, upperRegister
);
229 g_debug("%s", cmd
->str
);
234 cr
= gdk_cairo_create (widget
->window
);
235 cairo_set_line_width (cr
, 1);
236 cairo_select_font_face (cr
, "Sans", CAIRO_FONT_SLANT_NORMAL
,
237 CAIRO_FONT_WEIGHT_BOLD
);
240 if (g_access(filename
->str
, F_OK
) == 0) {
241 cairo_move_to (cr
, 5, 15);
242 cairo_set_source_rgb (cr
, 0,0,0);
243 cairo_show_text (cr
, "Reference Pitch");
246 drawPitchTier(cr
, filename
->str
,
247 widget
->allocation
.width
,
248 widget
->allocation
.height
, upperRegister
+ 100.0);
251 //g_debug("%s", recordedPT->str);
253 if (g_access(recordedPT
->str
, F_OK
) == 0) {
254 cairo_move_to (cr
, 15, 30);
255 cairo_set_source_rgb (cr
, 1,0,0);
256 cairo_show_text (cr
, "Your Pitch");
258 drawPitchTier(cr
, recordedPT
->str
,
259 widget
->allocation
.width
,
260 widget
->allocation
.height
, upperRegister
+ 100.0);
263 g_string_free(recordedPT
, TRUE
);
265 g_string_free(filename
, TRUE
);