Пример #1
0
int initialize_espeak(struct synth_t *s)
{
	int rate;

	/* initialize espeak */
	rate = espeak_Initialize(AUDIO_OUTPUT_PLAYBACK, 50, NULL, 0);
	if (rate < 0) {
		fprintf(stderr, "Unable to initialize espeak.\n");
		return -1;
	}

	/* We need a callback in acsint mode, but not in speakup mode. */
	if (espeakup_mode == ESPEAKUP_MODE_ACSINT)
		espeak_SetSynthCallback(acsint_callback);

	/* Setup initial voice parameters */
	if (defaultVoice) {
		set_voice(s, defaultVoice);
		free(defaultVoice);
		defaultVoice = NULL;
	}
	set_frequency(s, defaultFrequency, ADJ_SET);
	set_pitch(s, defaultPitch, ADJ_SET);
	set_rate(s, defaultRate, ADJ_SET);
	set_volume(s, defaultVolume, ADJ_SET);
	espeak_SetParameter(espeakCAPITALS, 0, 0);
	return 0;
}
Пример #2
0
void Classic_Emu::mute_voices_( int mask )
{
	Music_Emu::mute_voices_( mask );
	for ( int i = voice_count(); i--; )
	{
		if ( mask & (1 << i) )
		{
			set_voice( i, 0, 0, 0 );
		}
		else
		{
			Multi_Buffer::channel_t ch = buf->channel( i, (voice_types ? voice_types [i] : 0) );
			assert( (ch.center && ch.left && ch.right) ||
					(!ch.center && !ch.left && !ch.right) ); // all or nothing
			set_voice( i, ch.center, ch.left, ch.right );
		}
	}
}
Пример #3
0
 CompatKeys(char *keys1, char *keys2, gk_string *gstr)
{
	gk_string  Gstr;
	gk_string  Gstr2;
	gk_word * BlnkGkword;
	int rval = 0;
	int is_deriv = 0;
	
	BlnkGkword = CreatGkword(1);
	
	is_deriv = has_morphflag(morphflags_of(gstr),IS_DERIV);
	Gstr = BlankGkend;
	Gstr2 = BlankGkend;
	*gstr = BlankGkend;
	if( is_deriv ) add_morphflag(morphflags_of(gstr),IS_DERIV);
	ScanAsciiKeys(keys1,BlnkGkword,gstr,NULL);
	ScanAsciiKeys(keys2,BlnkGkword,&Gstr2,NULL);
	FreeGkword(BlnkGkword);

	rval = EndingOk(keys2,gstr,&Gstr,1);
	/*
	 *  grc 3/16/91
	 *
	 *  suppose we match a stem "a):ss:pres" against "ss:aor2_pass".  we don't at this
	 *  point decide whether or not the aor2_pass stem type could be a present.  we just
	 *  make sure that only present forms will be generated -- thus we will generate no
	 *  present forms and filter out the problem later.
	 */
	if( rval ) {
		if( tense_of(forminfo_of(&Gstr2)) ) set_tense(forminfo_of(gstr),tense_of(forminfo_of(&Gstr2)));
		if( mood_of(forminfo_of(&Gstr2)) ) set_mood(forminfo_of(gstr),mood_of(forminfo_of(&Gstr2)));
		if( voice_of(forminfo_of(&Gstr2)) ) set_voice(forminfo_of(gstr),voice_of(forminfo_of(&Gstr2)));
	}

 	return(rval);
}
Пример #4
0
void matrix_init_user(void)
{
    set_voice(default_voice);
    play_startup_tone();
    println("Matrix Init");
}
Пример #5
0
static int
set_new_event( int t )
{
    int ptr;
    unsigned char *data;
    int count;
    int follower;
    __GETMDX;

    data = mdx->data;
    ptr = mdx->track[t].current_mml_ptr;
    count = 0;
    follower = 0;

#if 0
    if ( ptr+1 <= mdx->length && t>7 ) {
        fprintf(stderr,"%2d %2x %2x\n",t,data[ptr],data[ptr+1]);
        fflush(stderr);
    }
#endif

    if ( data[ptr] <= MDX_MAX_REST ) {  /* rest */
        note_off(t);
        count = data[ptr]+1;
        mdx->track[t].gate = count+1;
        follower=0;

    } else if ( data[ptr] <= MDX_MAX_NOTE ) { /* note */
        note_on( t, data[ptr]);
        count = data[ptr+1]+1;
        do_quantize( t, count );
        follower = 1;

    } else {
        switch ( data[ptr] ) {

        case MDX_SET_TEMPO:
            set_tempo( data[ptr+1] );
            follower = 1;
            break;

        case MDX_SET_OPM_REG:
            set_opm_reg( t, data[ptr+1], data[ptr+2] );
            follower = 2;
            break;

        case MDX_SET_VOICE:
            set_voice( t, data[ptr+1] );
            follower = 1;
            break;

        case MDX_SET_PHASE:
            set_phase( t, data[ptr+1] );
            follower = 1;
            break;

        case MDX_SET_VOLUME:
            set_volume( t, data[ptr+1] );
            follower = 1;
            break;

        case MDX_VOLUME_DEC:
            dec_volume( t );
            follower = 0;
            break;

        case MDX_VOLUME_INC:
            inc_volume( t );
            follower = 0;
            break;

        case MDX_SET_QUANTIZE:
            set_quantize( t, data[ptr+1] );
            follower = 1;
            break;

        case MDX_SET_KEYOFF:
            set_keyoff( t );
            follower = 0;
            break;

        case MDX_REPEAT_START:
            mdx->track[t].loop_counter[mdx->track[t].loop_depth] = data[ptr+1];
            if ( mdx->track[t].loop_depth < MDX_MAX_LOOP_DEPTH )
                mdx->track[t].loop_depth++;
            follower = 2;
            break;

        case MDX_REPEAT_END:
            if (--mdx->track[t].loop_counter[mdx->track[t].loop_depth-1] == 0 ) {
                if ( --mdx->track[t].loop_depth < 0 ) mdx->track[t].loop_depth=0;
            } else {
                if ( data[ptr+1] >= 0x80 ) {
                    ptr = ptr+2 - (0x10000-(data[ptr+1]*256 + data[ptr+2])) - 2;
                } else {
                    ptr = ptr+2 + data[ptr+1]*256 + data[ptr+2] - 2;
                }
            }
            follower = 2;
            break;

        case MDX_REPEAT_BREAK:
            if ( mdx->track[t].loop_counter[mdx->track[t].loop_depth-1] == 1 ) {
                if ( --mdx->track[t].loop_depth < 0 ) mdx->track[t].loop_depth=0;
                ptr = ptr+2 + data[ptr+1]*256 + data[ptr+2] -2 +2;
            }
            follower = 2;
            break;

        case MDX_SET_DETUNE:
            set_detune( t, data[ptr+1], data[ptr+2] );
            follower = 2;
            break;

        case MDX_SET_PORTAMENT:
            set_portament( t, data[ptr+1], data[ptr+2] );
            follower = 2;
            break;

        case MDX_DATA_END:
            if ( data[ptr+1] == 0x00 ) {
                count = -1;
                note_off(t);
                follower = 1;
            } else {
                ptr = ptr+2 - (0x10000-(data[ptr+1]*256 + data[ptr+2])) - 2;
                mdx->track[t].infinite_loop_times++;
                follower = 2;
            }
            break;

        case MDX_KEY_ON_DELAY:
            follower = 1;
            break;

        case MDX_SEND_SYNC:
            send_sync( data[ptr+1] );
            follower = 1;
            break;

        case MDX_RECV_SYNC:
            recv_sync( t );
            follower = 0;
            count = 1;
            break;

        case MDX_SET_FREQ:
            set_freq( t, data[ptr+1] );
            follower = 1;
            break;

        case MDX_SET_PLFO:
            if ( data[ptr+1] == 0x80 || data[ptr+1] == 0x81 ) {
                set_plfo_onoff( t, data[ptr+1]-0x80 );
                follower = 1;
            } else {
                set_plfo( t,
                          data[ptr+1], data[ptr+2], data[ptr+3],
                          data[ptr+4], data[ptr+5] );
                follower = 5;
            }
            break;

        case MDX_SET_ALFO:
            if ( data[ptr+1] == 0x80 || data[ptr+1] == 0x81 ) {
                set_alfo_onoff( t, data[ptr+1]-0x80 );
                follower = 1;
            } else {
                set_alfo( t,
                          data[ptr+1], data[ptr+2], data[ptr+3],
                          data[ptr+4], data[ptr+5] );
                follower = 5;
            }
            break;

        case MDX_SET_OPMLFO:
            if ( data[ptr+1] == 0x80 || data[ptr+1] == 0x81 ) {
                set_hlfo_onoff( t, data[ptr+1]-0x80 );
                follower = 1;
            } else {
                set_hlfo( t,
                          data[ptr+1], data[ptr+2], data[ptr+3],
                          data[ptr+4], data[ptr+5] );
                follower = 5;
            }
            break;

        case MDX_SET_LFO_DELAY:
            set_lfo_delay( t, data[ptr+1] );
            follower = 1;
            break;

        case MDX_SET_PCM8_MODE:
            follower = 0;
            break;

        case MDX_FADE_OUT:
            if ( data[ptr+1]==0x00 ) {
                follower = 1;
                set_fade_out( 5 );
            } else {
                follower = 2;
                set_fade_out( data[ptr+2] );
            }
            break;

        default:
            count = -1;
            break;
        }
    }

    ptr += 1+follower;
    mdx->track[t].current_mml_ptr = ptr;

    return count;
}
Пример #6
0
/*static*/
 WantGkEnd(gk_string *wantend, gk_string *haveend, bool writeflag, int strict)
{
	int compval;

	word_form wform, hform;
/*
	Dialect wdial = dialect_of(wantend);
	Dialect hdial = dialect_of(haveend);
*/
	Dialect wdial;
	Dialect hdial;

	Dialect d/*, AndDialect()*/;

	int wmood = mood_of( forminfo_of(wantend) );
	int hmood = mood_of( forminfo_of(haveend) );

	int wvoice = voice_of( forminfo_of(wantend) );
	int hvoice = voice_of( forminfo_of(haveend) );

	int wtense = tense_of( forminfo_of(wantend) );
	int htense = tense_of( forminfo_of(haveend) );

	int wgender = gender_of( forminfo_of(wantend) );
	int hgender = gender_of( forminfo_of(haveend) );

	int wdegree = degree_of( forminfo_of(wantend) );
	int hdegree = degree_of( forminfo_of(haveend) );

	int wcase = case_of( forminfo_of(wantend) );
	int hcase = case_of( forminfo_of(haveend) );

	int wperson = person_of( forminfo_of(wantend) );
	int hperson = person_of( forminfo_of(haveend) );

	int wnumber = number_of( forminfo_of(wantend) );
	int hnumber = number_of( forminfo_of(haveend) );

	char wendstr[MAXWORDSIZE];
	char * hendstr = gkstring_of(haveend);

	wform = forminfo_of(wantend);
	hform = forminfo_of(haveend);
	
/*
 * basically, we check to see if any particular form has been requested
 * and check each ending against this. if nothing is asked for (e.g. no
 * mood or voice is specified) then we just take the ending (i.e. we take
 * subjunctive, optative, indicative etc. rather than just the optatives or
 * subjunctives or whatever...
 */
	setwendstr(wendstr,gkstring_of(wantend));
	if( wmood && hmood != wmood ) {
		if( hmood || (!hmood && strict) ) {
#ifdef SHOWFAIL
printf("failing on wmood %o hmood %o\n", wmood, hmood );
#endif
			return(0);
		}
	}

/*
 *
 *  perfect actives are, by definition, always active in form
 */


   	if( (stemtype_of(wantend) & PPARTMASK ) == PP_PF ) {
   		wvoice = ACTIVE;
   		voice_of(wform) = ACTIVE;
   	}

   	if( (stemtype_of(wantend) & PPARTMASK ) == PP_SU && 
	     cur_lang() == LATIN && wvoice == DEPONENT ) {
			set_voice(forminfo_of(haveend), wvoice);
   	}

	if( cur_lang() == LATIN && wvoice == DEPONENT ) {
		if( hvoice == ACTIVE && hmood != PARTICIPLE && hmood != GERUNDIVE ) return(0);
	} else if( wvoice ) {
		if( ! Want_Voice( wform , hform )) {
		   if( hvoice || (!hvoice && strict)) {
#ifdef SHOWFAIL
printf("have [%s] failing on wvoice %o hvoice %o\n",hendstr, wvoice, hvoice );
#endif
				return(0);
			}
		} else {
/*
 * note that an ending may generally be either middle or passive, but
 * if the stem in hand is strictly middle or strictly passive,
 * then the ending inherits that limitation.
 */

			if( writeflag == YES )
			   set_voice(forminfo_of(haveend), wvoice);
		}
	}

	if( wtense && htense != wtense )
		if( htense || (!htense && strict) ) {
#ifdef SHOWFAIL
printf("failing on wtense %o htense %o\n", wtense, htense );
#endif
			return(0);
		}

/*
 * note that here you only fail if the gender is set in the
 * ending as well as in the stem.
 * 
 * if we follow the normal algorithm, a masculine stem would 
 * not match a set of endings that had no gender specified.
 *
 * likewise, we need to match either masculine or feminine against
 * an ending that is common to both (but not, for example, to a neuter
 * stem, e.g. -es in nom pl for masc and fem, but -a for neuter)
 */
/*

/*
 * only fail if gender set for both.
 * 	e.g., dwr- from dw=ron will want to find 
 * endings such as -on, or -a that are specifically flagged
 * as neuter, but will also want to find other endings
 * that can attach themselves to any gender
 */
	if( wgender ) {
		if( hgender ) {
			if( ! Want_Gender(wform, hform)) {
#ifdef SHOWFAIL
printf("failing with hgender %o and wgender %o\n", hgender , wgender );
#endif
				return(0);
			}
		}
		if( writeflag )
			if( Want_Gender(wform,hform) )
				set_gender(forminfo_of(haveend), Want_Gender(wform, hform));
			else
			   	set_gender(forminfo_of(haveend), wgender );
	}

	if( wcase ) {
		if( ! Want_Case(wform, hform))
			if( hcase || (!hcase && strict) ) {
#ifdef SHOWFAIL
printf("failing with hcase %o wcase %o\n", hcase , wcase );
#endif
				return(0);
			}
if( writeflag ) {
#ifdef SHOWFAIL
printf("[%s] hcase %o wcase %o anded %o\n", gkstring_of(haveend), hcase, wcase, hcase & wcase );
#endif
		set_case(forminfo_of(haveend) , wcase&hcase );
}
	}

	if( wperson && hperson != wperson ) {
		if( hperson || (!hperson && strict) ) {
#ifdef SHOWFAIL
printf("failing with hperson %o wperson %o\n", hperson , wperson );
#endif
			return(0);
		}
	}

	if( wnumber && hnumber != wnumber )
		if( hnumber || (!hnumber && strict) ) {
#ifdef SHOWFAIL
printf("failing on wnumber %o hnumber %o\n", wnumber , hnumber );
#endif
			return(0);
		}

	if( *wendstr && strict ) {
	
		if( (compval=endstrcmp(wendstr,hendstr))){
	/*
	 * this expects that you have a sorted list of endings and that you
	 * don't want to look for endings that are alphabetically larger
	 * than the ending that you want 
	 */
			if( compval < 0 && noaccstrcmp(wendstr,hendstr) ) {

#ifdef SHOWFAIL
#endif

				return(compval);
			}
#ifdef SHOWFAIL
printf("failing on wendsrr\n");
#endif
		/*
		 * don't fail if you did not specifically ask for a long vowel.
		 *
		 * do fail if you specifically ask for a long vowel and this ending is not 
		 * marked as long.
		 */
		if( has_quantacc(hendstr) != has_quantacc(wendstr) ) {
			char tmp[MAXWORDSIZE];
			
			Xstrncpy(tmp,hendstr,MAXWORDSIZE);
			stripquantacc(tmp);
			compval=endstrcmp(wendstr,tmp);
/*
			compval=dictstrcmp(wendstr,tmp);
*/
			if( compval  ) 				
						return(0);
		}  else
						return(0);
		} else {
			/*
			 * if you ask for "w=", then match only "w=" and not "w".
			 *
			 * if you ask for "w", however, then match both "w=" and "w".
			 */

			if( hasaccent(wendstr)  ) {
				char tmp1[MAXWORDSIZE];
				char tmp2[MAXWORDSIZE];
				
				Xstrncpy(tmp1,wendstr,(int)sizeof tmp1);
				stripquant(tmp1);
				
				Xstrncpy(tmp2,hendstr,(int)sizeof tmp2);
				stripquant(tmp2);
				if( strcmp(tmp1,tmp2) )
						return(0);
			}
		}
	}

	if(  ! EuphEnd(wantend,haveend,strict) ) {
#ifdef SHOWFAIL
printf("[%s] failing on euph end\n", gkstring_of(haveend) );
#endif
		return(0);
	}
	wdial = dialect_of(wantend);
	hdial = dialect_of(haveend);

/*
 * note that we are checking not for equality, but to see if
 * we want any of the dialect bits set for the current ending
 */
	if( (d=AndDialect(hdial,wdial)) < 0 )
		return(0);
/*
	else if( writeflag ) {
		set_dialect(haveend,d);
	}
*/
/*
 * we currently mark a)/ristos as "os_h_on superl". 
 * we thus want a)rist- to have all the normal endings (-os,-h,-on,-ou,-hs,-ou)
 * but not to have endings such as "-o/tatos" or "-w/teros" tacked onto it.
 */
 
/*
 * grc 6/5/89
 *
 * this system prevents morphology formulas from generating any actual endings.  the
 * formula has the flag "comp" or "superl", but none of the endings in the basic
 * paradigms are so marked, so they are all skipped.  i added the requirement that this
 * rule only be active if strict is non zero to get around this (this is much the same
 * strategy that we took with iteratives.
 */
	if( wdegree ) {
		if(  hdegree && wdegree != hdegree /* grc 6/5/89 */ && strict /* end mod*/) {
			if( hdegree || (!hdegree && strict) )
				return(0);
		}
		if( wdegree && writeflag ) set_degree(forminfo_of(haveend),wdegree);
	}

	if( ! RightMorphflags(wantend,haveend)) {
#ifdef SHOWFAIL
printf("[%s] failing on rightmorphflags\n", gkstring_of(haveend) );
#endif
		return(0);
	}
	return(1);
}
Пример #7
0
 EndingOk(char *keys, gk_string *gstr, gk_string *avoidgstr, int wantderiv)
{
	int good = 0;
	gk_word * BlnkGkword;
	
	Cur_gkend = BlankGkend;
	BlnkGkword = CreatGkword(1);
	ScanAsciiKeys(keys,BlnkGkword,&Cur_gkend,avoidgstr);
	FreeGkword(BlnkGkword);
	
	if( wantderiv ) {
		if( ! derivtype_of(gstr) || derivtype_of(gstr) < 0 ) return(0);
		
		if( derivtype_of(gstr) != derivtype_of(&Cur_gkend)) 
			return(0);
	}
	
	good =  (WantGkEnd(gstr,&Cur_gkend,NO,0) > 0) &&
	  (NoWantGkEnd(avoidgstr,&Cur_gkend,1) == 0 );
/*
if( ! good ) {
printf("gstr [%s] [%s] want %o nowant %o\n",gkstring_of(gstr), gkstring_of(&Cur_gkend), WantGkEnd(gstr,&Cur_gkend,NO,0) ,
NoWantGkEnd(avoidgstr,&Cur_gkend,1)  );
LPrntGstr(gstr,stdout);
LPrntGstr(&Cur_gkend,stdout);

}
*/
	if( good ) {
		int case1, case2;
		int gend1, gend2;
		int num2, pers2;
		int voice1, voice2;
		Dialect dial1, dial2;

		voice1 = voice_of(forminfo_of(&Cur_gkend));
		voice2 = voice_of(forminfo_of(gstr));
		
		if( voice1 ) set_voice(forminfo_of(gstr),voice1);
		
		case1 = case_of(forminfo_of(&Cur_gkend));
		case2 = case_of(forminfo_of(gstr));
		if( case1 & case2 )
			set_case(forminfo_of(gstr), (case1 & case2) );
		else if( case1 && ! case2 )
			set_case(forminfo_of(gstr), case1 );
	
		num2 = number_of(forminfo_of(&Cur_gkend));
		if( num2 )
			set_number(forminfo_of(gstr), number_of(forminfo_of(&Cur_gkend)) );

		pers2 = person_of(forminfo_of(&Cur_gkend));
		if( pers2 )
			set_person(forminfo_of(gstr), person_of(forminfo_of(&Cur_gkend)) );

		gend1 = gender_of(forminfo_of(&Cur_gkend));
		gend2 = gender_of(forminfo_of(gstr));
		if( gend1 & gend2 )
			set_gender(forminfo_of(gstr), (gend1 & gend2) );
		else if( gend1 && ! gend2 )
			set_gender(forminfo_of(gstr), gend1 );

		dial1 = dialect_of(&Cur_gkend);
		dial2 = dialect_of(gstr);
		if( dial1 & dial2 ) 
			set_dialect(gstr,(dial1 & dial2) );
		else if( dial1 && (! dial2) )
			set_dialect(gstr,dial1);
			
		add_morphflags(gstr,morphflags_of(&Cur_gkend));
	}
	return( good );
}