int Fps (long x, long y)//функци¤ определени¤ FPS
{
	int tr;
	
	time1 = SysCall(26,9);//определ¤ем врем¤ прошедшее момента запуска системы 

	if (timerend==0)
	{
 	   time2=time1; 
	   timerend=time1;	
	}
	
	tr = time1 - timerend;

	if ((time1 - time2) < 100)//если прошло менее 1 секунды 
	{				          //увеличиваем счетчик fps
		fps1++; 
	}
	else 
	{
		//выводим число fps
		SysCall(13,(x<<16)+23,(y<<16)+7,0x00555555); //Ќј–»—ќ¬ј“№ ѕќЋќ—”
    	SysCall(47,4<<16,fps1,(x<<16)+y,0xfafafa);//¬џ¬≈—“» ¬ ќ Ќќ ѕ–»Ћќ∆≈Ќ»я „»—Ћќ
		fps1=0;
		time2=time1;
	}
	
	timerend=time1;
	
return tr;
}
QtSpeech::VoiceNames QtSpeech::voices()
{
    VoiceNames vs;       
    ULONG count = 0;
    CComPtr<IEnumSpObjectTokens> voices;

    CoInitialize(NULL);
    SysCall( SpEnumTokens(SPCAT_VOICES, NULL, NULL, &voices), LogicError);
    SysCall( voices->GetCount(&count), LogicError);

    for(int i=0; i< count; i++) {
        WCHAR * w_id = 0L;
        WCHAR * w_name = 0L;
        CComPtr<ISpObjectToken> voice;
        SysCall( voices->Next( 1, &voice, NULL ), LogicError);
        SysCall( SpGetDescription(voice, &w_name), LogicError);
        SysCall( voice->GetId(&w_id), LogicError);

        QString id = QString::fromWCharArray(w_id);
        QString name = QString::fromWCharArray(w_name);
        VoiceName n = { id, name };
        vs << n;

        voice.Release();
    }
    return vs;
}
Exemple #3
0
void QtSpeech_proc::say(QString text) {
    try {
        if (player)
        {
            player->stop();
            delete player;
        }
        player = new WavePlayer;

        if (!init) {
            int heap_size = FESTIVAL_HEAP_SIZE;
            festival_initialize(true,heap_size);
            init = true;
        }
        has_error = false;
        EST_String est_text(text.toUtf8());
        EST_Wave est_wave;
        SysCall(festival_text_to_wave(est_text, est_wave), QtSpeech::LogicError);
        EST_String est_file(player->filePath().toUtf8());
        est_wave.save(est_file);

        connect(player, SIGNAL(finished(int)), this, SIGNAL(finished()));
        connect(player, SIGNAL(finished(int)), player, SLOT(deleteLater()));
        player->play();
    }
    catch(QtSpeech::LogicError e) {
        has_error = true;
        err = e;
    }
}
// implementation
QtSpeech::QtSpeech(QObject * parent)
    :QObject(parent), d(new Private)
{
    CoInitialize(NULL);
    SysCall( d->voice.CoCreateInstance( CLSID_SpVoice ), InitError);

    VoiceName n;
    WCHAR * w_id = 0L;
    WCHAR * w_name = 0L;
    CComPtr<ISpObjectToken> voice;
    SysCall( d->voice->GetVoice(&voice), InitError);
    SysCall( SpGetDescription(voice, &w_name), InitError);
    SysCall( voice->GetId(&w_id), InitError);
    n.name = QString::fromWCharArray(w_name);
    n.id = QString::fromWCharArray(w_id);
    voice.Release();

    if (n.id.isEmpty())
        throw InitError(Where+"No default voice in system");

    d->name = n;
    d->ptrs << this;
}
void QtSpeech_th::say(QString text) {
    try {
        if (!init) {
            int heap_size = FESTIVAL_HEAP_SIZE;
            festival_initialize(true,heap_size);
            init = true;
        }
        has_error = false;
        EST_String est_text(text.toUtf8());
        SysCall(festival_say_text(est_text), QtSpeech::LogicError);
    }
    catch(QtSpeech::LogicError e) {
        has_error = true;
        err = e;
    }
    emit finished();
}
void QtSpeech::tell(QString text, QObject * obj, const char * slot) const
{
    if (obj != 0L && slot != 0L)
    {
        if (d->waitingFinish)
            throw LogicError(Where+"Already waiting to finish speech");

        d->onFinishObj = obj;
        d->onFinishSlot = slot;
        if (obj && slot)
            connect(const_cast<QtSpeech *>(this), SIGNAL(finished()), obj, slot);

        d->waitingFinish = true;
        const_cast<QtSpeech *>(this)->startTimer(100);
    }

    Private::WCHAR_Holder w_text(text);
    SysCall( d->voice->Speak( w_text.w, SPF_ASYNC | SPF_IS_NOT_XML | SPF_PURGEBEFORESPEAK, 0), LogicError);
}
QtSpeech::QtSpeech(VoiceName n, QObject * parent)
    :QObject(parent), d(new Private)
{
    ULONG count = 0;
    CComPtr<IEnumSpObjectTokens> voices;

    CoInitialize(NULL);
    SysCall( d->voice.CoCreateInstance( CLSID_SpVoice ), InitError);

    if (n.id.isEmpty()) {
        WCHAR * w_id = 0L;
        WCHAR * w_name = 0L;
        CComPtr<ISpObjectToken> voice;
        SysCall( d->voice->GetVoice(&voice), InitError);
        SysCall( SpGetDescription(voice, &w_name), InitError);
        SysCall( voice->GetId(&w_id), InitError);
        n.name = QString::fromWCharArray(w_name);
        n.id = QString::fromWCharArray(w_id);
        voice.Release();
    }
    else {
        SysCall( SpEnumTokens(SPCAT_VOICES, NULL, NULL, &voices), InitError);
        SysCall( voices->GetCount(&count), InitError);
        for (int i =0; i< count; i++) {
            WCHAR * w_id = 0L;
            CComPtr<ISpObjectToken> voice;
            SysCall( voices->Next( 1, &voice, NULL ), InitError);
            SysCall( voice->GetId(&w_id), InitError);
            QString id = QString::fromWCharArray(w_id);
            if (id == n.id) d->voice->SetVoice(voice);
            voice.Release();
        }
    }

    if (n.id.isEmpty())
        throw InitError(Where+"No default voice in system");

    d->name = n;
    d->ptrs << this;
}
Exemple #8
0
void QtSpeech::tell(QString text, QObject * obj, const char * slot) const
{
    if (d->waitingFinish) {
        //throw LogicError(Where+"Already waiting to finish speech");
        //win api to stop any existing speech going
        HRESULT hr = d->voice->Speak( NULL, SPF_PURGEBEFORESPEAK, 0 );
            if (FAILED( hr )) qDebug() << "sapi51: stop is not completed";
    }

    d->onFinishObj = obj;
    d->onFinishSlot = slot;
    if (obj && slot)
        connect(const_cast<QtSpeech *>(this), SIGNAL(finished()), obj, slot);

    d->waitingFinish = true;
    const_cast<QtSpeech *>(this)->startTimer(100);

    Private::WCHAR_Holder w_text(text);
    SysCall( d->voice->Speak( w_text.w, SPF_ASYNC | SPF_IS_NOT_XML, 0), LogicError);
}
void QtSpeech::say(QString text) const
{
    Private::WCHAR_Holder w_text(text);
    SysCall( d->voice->Speak( w_text.w, SPF_IS_NOT_XML, 0), LogicError);
}
void app_main(void)          
{

  win.x = 100;
  win.y = 100;
  win.dx = 400;
  win.dy = 400;	 

  draw_window();

  cgl = kosglCreateContext( 0, 0);
  kosglMakeCurrent( 0, 20, win.dx, win.dy-20, cgl);

  init();

  pri=new process_table_entry_;
  SysCall(66,1,1);

  reshape();
  
do{

   glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

   glPushMatrix();
   glRotatef( view_rotx, 1.0, 0.0, 0.0 );
   glRotatef( view_roty, 0.0, 1.0, 0.0 );
   glRotatef( view_rotz, 0.0, 0.0, 1.0 );

   glPushMatrix();
   glTranslatef( -2.0, -2.0, 0.0 );
   glRotatef( angle, 0.0, 0.0, 1.0 );
   glCallList(gear1);
   glPopMatrix();

   glPushMatrix();
   glTranslatef( 4.1, -2.0, 0.0 );
   glRotatef( -2.0*angle-9.0, 0.0, 0.0, 1.0 );
   glCallList(gear2);
   glPopMatrix();

   glPushMatrix();
   glTranslatef( -2.1, 4.2, 0.0 );
   glRotatef( -2.0*angle-25.0, 0.0, 0.0, 1.0 );
   glCallList(gear3);
   glPopMatrix();

   glPopMatrix();
   
 kosglSwapBuffers();

 angle += 0.01 + 0.3* Fps (330,8);
 			
		  switch(SysCall(11))
		      {
		          case 1: draw_window();				  	   	  
				  	   	  reshape();
				  	   	  break;
				  	   	  
		          case 2: 		          
		          	   switch(__menuet__getkey()){

						   case KEY_F:
                                    if(!FullScreen){									 
									 skin=0;
									 SysCall(67,0,0,SysCall(14)>>16,SysCall(14)&0xffff);
									 draw_window();
									 reshape();
									 FullScreen = 1;
									}
									else{
									 skin=3;
									 draw_window();
									 SysCall(67,win.x,win.y,win.dx,win.dy);
									 reshape();
									 FullScreen = 0;
									};
						  			break;
		          
                           case KEY_ESC: disabletgl();
						  				 return;}
						  				 break;
						  			
			  	  case 3: disabletgl();
						  return;
		      }