2 #include <unistd.h> /* F_OK ?? */
14 #include "Pitch_to_Sound.h"
18 gpointer
sound_init(void *args
)
20 Sound melderSoundFromMic
;
23 gsl_set_error_handler_off ();
24 Melder_setMaximumAsynchronicity (Melder_SYNCHRONOUS
);
26 melderSoundFromMic
= Sound_recordFixedTime (1, 1.0, 0.5, 44100, 1.0);
27 forget(melderSoundFromMic
);
29 // Melder_flushError (NULL);
33 void playInPraat(gchar
*path
) {
34 if (g_access(path
, F_OK
) == 0) {
35 structMelderFile file
;
36 Sound melderSoundFromFile
;
37 Melder_pathToFile(path
, & file
);
38 melderSoundFromFile
= Sound_readFromSoundFile (& file
);
39 if (! melderSoundFromFile
) {
40 g_warning(_("Praat cannot open the file!"));
42 Sound_play(melderSoundFromFile
, NULL
, NULL
);
43 forget(melderSoundFromFile
);
46 g_warning(_("The file %s just don't exist!"), path
);
49 // Melder_flushError (NULL);
57 gtk_tree_model_get(GTK_TREE_MODEL(liststore
), &mainIter
, COL_TEXT
, &string
, -1);
58 path
= voicepath(string
);
69 gtk_tree_model_get(GTK_TREE_MODEL(liststore
), &mainIter
, COL_TEXT
, &string
, -1);
71 gchar
*upper
= g_malloc(4);
72 g_ascii_dtostr(upper
, 4, upperRegister
);
74 path
= g_strjoin(NULL
, PITCHPATH
, G_DIR_SEPARATOR_S
, string
, "-", upper
, ".wav", NULL
);
76 path
= g_strjoin(NULL
, PITCHPATH
, G_DIR_SEPARATOR_S
, string
, "-", upper
, ".Pitch", NULL
);
83 if (g_access(path
, F_OK
) == 0) {
84 structMelderFile file
;
85 Pitch melderPitchFromFile
;
87 __declspec(dllimport
) Pitch_Table classPitch
;
89 Thing_recognizeClassesByName (classPitch
, NULL
);
90 Melder_pathToFile(path
, & file
);
91 melderPitchFromFile
= Data_readFromTextFile (& file
);
92 if (melderPitchFromFile
!= NULL
) {
93 Pitch_hum(melderPitchFromFile
, 0, 0);
94 forget(melderPitchFromFile
);
96 g_debug("PITCH IS NULL!");
102 Melder_flushError (NULL
);
108 GtkWidget
*gimiVoice
= glade_xml_get_widget(xml
, "checkmenuitemBeforeVoice");
109 GtkWidget
*gimiHum
= glade_xml_get_widget(xml
, "checkmenuitemBeforeHum");
111 /* Check play Example */
112 if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gimiVoice
))) {
118 if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gimiHum
))) {
123 gpointer
example(void *args
) {
124 GtkWidget
*gimiVoice
= glade_xml_get_widget(xml
, "checkmenuitemExampleVoice");
125 GtkWidget
*gimiHum
= glade_xml_get_widget(xml
, "checkmenuitemExampleHum");
127 g_idle_add(setButtonsFalse
, NULL
);
129 /* Check play Example */
130 if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gimiVoice
))) {
136 if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gimiHum
))) {
140 g_idle_add(setButtonsTrue
, NULL
);
144 gpointer
play(void *args
) {
147 g_idle_add(setButtonsTrue
, NULL
);
153 gpointer
record(void *args
) {
156 gtk_tree_model_get(GTK_TREE_MODEL(liststore
), &mainIter
, COL_TEXT
, &string
, -1);
157 // g_debug("%s %d welcome!\n\n\n", __func__, rand());
158 g_idle_add(setButtonsFalse
, NULL
);
160 if (g_access(RECORDPATH
, F_OK
) == 0) {
161 Sound melderSoundFromMic
= Sound_recordFixedTime (1, 1.0, 0.5, 44100, 5.0);
163 if (! melderSoundFromMic
) {
164 g_warning(_("No sound from praat!"));
166 GString
*filename
= g_string_sized_new(128);
167 GString
*cmd
= g_string_sized_new(128);
169 structMelderFile file
;
171 g_string_printf(filename
, "%s.wav", string
);
173 path
= g_build_filename(RECORDPATH
, filename
->str
, NULL
);
174 g_string_free(filename
, TRUE
);
176 Vector_scale(melderSoundFromMic
, 0.99);
177 Melder_pathToFile(path
, &file
);
178 Sound_writeToAudioFile16 (melderSoundFromMic
, &file
, Melder_WAV
);
179 forget(melderSoundFromMic
);
182 g_string_printf(cmd
, "%s SGC_ToneProt.praat ..%s%s %s %0.f 3 none 0", PRAATBIN
, G_DIR_SEPARATOR_S
, path
, string
, upperRegister
);
185 // g_debug("EXECUTES! ");
187 // g_debug("DONE!\n");
189 g_string_free(cmd
, TRUE
);
192 g_warning(_("Missing recording directory %s."), RECORDPATH
);
196 // Melder_flushError (NULL);
197 g_idle_add(setButtonsTrue
, NULL
);
198 // g_debug("%s bye!\n", __func__);