Skip to content

Commit

Permalink
remove 2nd outlet and synthesize when reading a text file
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucarda committed Jun 22, 2022
1 parent da2fc2c commit 4f6194e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 42 deletions.
21 changes: 3 additions & 18 deletions flite-help.pd
Original file line number Diff line number Diff line change
Expand Up @@ -160,23 +160,9 @@ playing., f 46;
#X text 541 436 open this sub patch;
#X text 412 630 v0.3.1 updated by Lucas Cordiviola https://github.com/Lucarda/pd-flite
;
#N canvas 130 130 450 300 outlet2 0;
#X obj 142 181 print;
#X obj 143 33 inlet;
#X obj 143 75 route 1 2;
#X msg 143 122 flite: finished reading textfile;
#X msg 158 153 flite: finished loading voicefile;
#X connect 1 0 2 0;
#X connect 2 0 3 0;
#X connect 2 1 4 0;
#X connect 3 0 0 0;
#X connect 4 0 0 0;
#X restore 190 639 pd outlet2;
#X text 235 528 "textfile" message reads a text file into the text-buffer
;
#X text 345 43 1 - (bang) on completed synthesis;
#X text 345 59 2 - (float) on finish reading file: (1) textfile \,
(2) voicefile., f 66;
#X text 345 43 1 - bang on completed synthesis;
#X text 235 528 "textfile" message reads a text file and synthesize
it;
#X connect 8 0 59 0;
#X connect 9 0 59 0;
#X connect 10 0 59 0;
Expand Down Expand Up @@ -213,6 +199,5 @@ playing., f 46;
#X connect 56 0 51 0;
#X connect 57 0 53 0;
#X connect 59 0 2 0;
#X connect 59 1 67 0;
#X connect 60 0 15 0;
#X connect 60 0 15 1;
30 changes: 6 additions & 24 deletions flite.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,8 @@ typedef enum _thrd_tick
ARRAYERR = 1,
BUFFERERR = 2,
FAIL = 3,
TEXTFILEDONE = 4,
VOXFILEDONE = 5,
INPROGRESS = 6,
VOXFILEDONE = 4,
INPROGRESS = 5,
} t_thrd_tick;


Expand All @@ -112,7 +111,6 @@ typedef struct _flite
char x_reqfile[MAXPDSTRING];
char x_inprogress;
t_outlet *x_bangout;
t_outlet *x_floatout;
t_clock *x_clock;
t_thrd_request x_requestcode;
t_thrd_tick x_tick_ctl;
Expand Down Expand Up @@ -292,11 +290,9 @@ static void flite_clock_tick(t_flite *x)
} else if (x->x_tick_ctl == FAIL) {
pd_error(x,"flite: synthesis failed for text '%s'", x->x_textbuf);
} else if (x->x_tick_ctl == INPROGRESS) {
pd_error(x,"%s", thread_waiting);
} else if (x->x_tick_ctl == TEXTFILEDONE) {
outlet_float(x->x_floatout, 1);
pd_error(x,"%s", thread_waiting);
} else if (x->x_tick_ctl == VOXFILEDONE) {
outlet_float(x->x_floatout, 2);
logpost(x,2,"Flite: successfully loaded '%s'", x->x_reqfile);
}
x->x_inprogress = 0;
return;
Expand Down Expand Up @@ -501,20 +497,6 @@ static void flite_read_textfile(t_flite *x) {
x->x_textbuf = (char *) calloc(len+1, sizeof(char));
fread(x->x_textbuf, 1, len, fp);
fclose(fp);
pthread_mutex_lock(&x->x_mutex);
if (x->x_requestcode != QUIT)
{
x->x_tick_ctl = TEXTFILEDONE;
if (x->x_requestcode != IDLE)
{
sys_lock();
clock_delay(x->x_clock, 0);
sys_unlock();
} else {
flite_clock_tick(x);
}
}
pthread_mutex_unlock(&x->x_mutex);
return;
}

Expand All @@ -531,6 +513,7 @@ static void flite_textfile(t_flite *x, t_symbol *filename) {
return;
}
flite_read_textfile(x);
flite_synth(x);
return;
}

Expand All @@ -547,7 +530,6 @@ static void flite_thrd_textfile(t_flite *x, t_symbol *filename) {
}

if(!flite_filex(x, filename)) {
//pthread_mutex_unlock(&x->x_mutex);
return;
}
x->x_inprogress = 1;
Expand Down Expand Up @@ -609,6 +591,7 @@ static void flite_thread(t_flite *x) {
{
pthread_mutex_unlock(&x->x_mutex);
flite_read_textfile(x);
flite_thread_synth(x);
pthread_mutex_lock(&x->x_mutex);
if (x->x_requestcode == TEXTFILE)
x->x_requestcode = IDLE;
Expand Down Expand Up @@ -654,7 +637,6 @@ static void *flite_new(t_symbol *ary)

// create bang-on-done outlet
x->x_bangout = outlet_new(&x->x_obj, &s_bang);
x->x_floatout = outlet_new(&x->x_obj, &s_float);

// default voice
x->x_voice = register_cmu_us_kal16();
Expand Down

0 comments on commit 4f6194e

Please sign in to comment.