void ofApp::setup(){
    ofEnableDataPath();

    setupConstants();

    setupGlobals();

    setupGL();

    setupGraph(forward_graph, forward_graph_path);

    setupParameters();

    cout<<params<<endl;

    forward_graph->initFbos();

    setupAudio();

    // if(use_camera){
    //     camera.setVerbose(true);
    //     camera.listDevices();
    //     camera.initGrabber(render_width, render_height);
    // }

    cout<<"setup complete"<<endl;
}
void MagicLightCircle::setup(int resolution)
{
  radius = 200;
  totMagicPoints = resolution;
  reverseLogic = true;
  for(int a = 0; a < resolution; a++)
  {
    addNewMagicPoint();
  }

  int cont = 0;
  int startPosOffset = 20;
  for(int a = 0;  a < totMagicPoints; a++)
  {
    int pos = a;
    int index = pos;
    int outputPort = pos;
    if(outputPort >= resolution)
      outputPort = resolution - resolution;
    if(a == 23)
      outputPort = 27;
    if(outputPort > 11)
      outputPort += 3;
    if(a == 16)
      outputPort = 14;
    magicPoints[a]->setOutputPort(outputPort);
  }
  setupPixelMapping();
  setupDMX();
  setupOSC();
  setupAudio();
  timerNoPoints = 0;
}
Exemple #3
0
int main( int argc, char* argv[] )
{
	// Allocate
	gEngine = new sgct::Engine( argc, argv );

	// Bind your functions
	gEngine->setInitOGLFunction( myInitFun );
	gEngine->setDrawFunction( myDrawFun );
	gEngine->setPreSyncFunction( myPreSyncFun );
	gEngine->setCleanUpFunction( myCleanUpFun );
	sgct::SharedData::instance()->setEncodeFunction(myEncodeFun);
	sgct::SharedData::instance()->setDecodeFunction(myDecodeFun);

	// Init the engine
	if( !gEngine->init( sgct::Engine::OpenGL_3_3_Core_Profile ) )
	{
		delete gEngine;
		return EXIT_FAILURE;
	}

	setupAudio();

	// Main loop
	gEngine->render();

	// Clean up (de-allocate)
	delete gEngine;

	// Exit program
	exit( EXIT_SUCCESS );
}
 myPlugin(axContext* aContext)
 : axFormat(aContext, AX_PLUG_DEFAULT)
   {
     axRandomize(418);
     describe("test_widgets","ccernn","axonlibe example",0,AX_MAGIC+0x0000);
     setupAudio(2,2,false);
     setupEditor(640,480);
   }
 myPlugin(axContext* aContext)
 : axFormat(aContext, AX_PLUG_DEFAULT)
   {
     describe("test_","ccernn","axonlibe example",0,AX_MAGIC+0x0000);
     setupAudio(2,2,false);
     setupEditor(640,480);
     //setupParameters();
   }
Exemple #6
0
void AudioOutputPrivate::playInstructions()
{
    setupAudio();
    if ( m_output ) {
        m_output->enqueue( QUrl::fromLocalFile( m_voiceNavigation.instruction() ) );
        m_output->play();
    }
}
        int handle()
        {
            CExeFile &ExeFile = gKeenFiles.exeFile;
            int version = ExeFile.getEXEVersion();
            unsigned char *p_exedata = ExeFile.getRawData();

            if( mEp == 1 && version == 134)
            {
                gLogging.ftextOut("This version of the game is not supported!<br>");
                return 0;
            }

            // Patch the EXE-File-Data directly in the memory.
            CPatcher Patcher(ExeFile, gpBehaviorEngine->mPatchFname);
            Patcher.process();

            mLoader.setPermilage(100);

            gTimer.setLPS(DEFAULT_LPS_VORTICON);

            gpBehaviorEngine->readTeleporterTable(p_exedata);

            if( (mFlags & LOADGFX) == LOADGFX )
            {
                // Decode the entire graphics for the game (EGALATCH, EGASPRIT, etc.)
                // This will also read the Tile-Properties
                CEGAGraphicsVort graphics(mEp, mDataPath);
                graphics.loadData(version, p_exedata);
                mLoader.setPermilage(400);
                mLoader.setStyle(PROGRESS_STYLE_BITMAP);
            }

            if( (mFlags & LOADSTR) == LOADSTR )
            {
                // load the strings.
                CMessages Messages(p_exedata, mEp, version);
                Messages.extractGlobalStrings();
                mLoader.setPermilage(500);
            }

            if( (mFlags & LOADSND) == LOADSND )
            {
                // Load the sound data
                setupAudio();
                mLoader.setPermilage(800);
            }

            gpBehaviorEngine->getPhysicsSettings().loadGameConstants(mEp, p_exedata);
            mLoader.setPermilage(900);

            // If there are patches left that must be apllied later, do it here!
            Patcher.postProcess();

            mLoader.setPermilage(1000);

            gEventManager.add(new FinishedLoadingResources());
            return 1;
        }
 myPlugin(axContext* aContext)
 : axFormat(aContext, pf_None/*HasEditor*/)
   {
     m_Gain = 0;
     describe("test_buttons","ccernn","axonlib example",0,AX_MAGIC+0x0000);
     setupAudio(2,2,false);
     setupEditor(320,240);
     appendParameter( p_Gain = new axParameter(this,"gain","") );
     setupParameters();
   }
Exemple #9
0
  void Cursynth::start(unsigned sample_rate, unsigned buffer_size) {
    // Setup all callbacks.
    setupAudio(sample_rate, buffer_size);
    setupMidi();
    setupGui();
    loadConfiguration();

    // Wait for computer keyboard input.
    while(textInput(getch()))
      ;

    stop();
  }
Exemple #10
0
  void Cursynth::start() {
    // Setup all callbacks.
    setupAudio();
    setupMidi();
    setupGui();
    loadConfiguration();

    // Wait for computer keyboard input.
    while(textInput(getch()))
      ;

    stop();
  }
Exemple #11
0
void ofApp::setupWords()
{
  wordReady = true;
  windowsSize.x = size->x * ofGetWindowWidth();
  windowsSize.y = size->y * ofGetWindowHeight();
  words.setup(windowsSize.x, windowsSize.y);
  ofSetFrameRate(60);
  ofBackground(0);
  setupWebSocket();
  resetWords();
  overlay.load("overlayWords.png");
  blur.setup(windowsSize.x, windowsSize.y, 10, .2, 4);
  setupAudio();
  system("open 'http://localhost:9092/'");
}
Exemple #12
0
//--------------------------------------------------------------
void testApp::setup() {
	
    ofDisableAntiAliasing();
	ofBackgroundHex(0xffffff);
	ofSetLogLevel(OF_LOG_NOTICE);
	ofSetVerticalSync(true);
	
	// Box2d
	box2d.init();
	box2d.setGravity(0, 30);
	box2d.createGround();
	box2d.setFPS(30.0);
	
	
	// load the lines we saved...
	ifstream f;
	f.open(ofToDataPath("lines.txt").c_str());
	vector <string> strLines;
	while (!f.eof()) {
		string ptStr;
		getline(f, ptStr);
		strLines.push_back(ptStr);
	}
	f.close();
	
	for (int i=0; i<strLines.size(); i++) {
		vector <string> pts = ofSplitString(strLines[i], ",");
		if(pts.size() > 0) {
			ofPtr <ofxBox2dEdge> edge = ofPtr<ofxBox2dEdge>(new ofxBox2dEdge);
			for (int j=0; j<pts.size(); j+=2) {
				if(pts[j].size() > 0) {
					float x = ofToFloat(pts[j]);
					float y = ofToFloat(pts[j+1]);
					edge.get()->addVertex(x, y);
				}				
			}
			edge.get()->create(box2d.getWorld());
			edges.push_back(edge);
		}
	}
    
    boxSize = 10;
    
    setupAudio();
	
}
Exemple #13
0
 myPlugin(axContext* aContext, int aFlags)
 : axFormat(aContext)
   {
     w_Editor = NULL;
     w_Painter = NULL;
     describe("test_gain_gui","ccernn","axonlib example",0,AX_MAGIC+0x0000);
     setupAudio(2,2);
     setupEditor(640,480);
     appendParameter( new parInteger(this,"type1","", 0,   0, NUMTYPES-1, str_type ) );
     appendParameter( new parInteger(this,"type2","", 0,   0, NUMTYPES-1, str_type ) );
     appendParameter( new parFloat(  this,"min x","",-10, -10,10 ) );
     appendParameter( new parFloat(  this,"max x","", 10, -10,10 ) );
     appendParameter( new parFloat(  this,"min y","",-10, -10,10 ) );
     appendParameter( new parFloat(  this,"max y","", 10, -10,10 ) );
     appendParameter( new parFloat(  this,"n",    "", 0,  -10,10  ) );
     //setupParameters();
     prepareParameters();
   }
void InitGame()
{
    MM_Startup();

    id0_int_t i;

/*#if 0
    // Handle piracy screen...
    //
    movedata(FP_SEG(PIRACY),(id0_unsigned_t)PIRACY,0xb800,displayofs,4000);
    while (BE_ST_BiosScanCode(0) != sc_Return);
    //while ((bioskey(0)>>8) != sc_Return);
#endif*/

#if GRMODE == EGAGR
    if (mminfo.mainmem < 335l*1024)
    {
//#pragma warn    -pro
//#pragma warn    -nod
#ifdef REFKEEN_VER_KDREAMS_CGA_ALL
        BE_ST_textcolor(7);
#endif
#ifndef REFKEEN_VER_KDREAMS_CGA_ALL
        if (refkeen_current_gamever == BE_GAMEVER_KDREAMSE113)
#endif
        {
            BE_ST_textbackground(0);
        }
//#pragma warn    +nod
//#pragma warn    +pro
        BE_ST_clrscr();                       // we can't include CONIO because of a name conflict
//#pragma warn    +nod
//#pragma warn    +pro
        BE_ST_puts ("There is not enough memory available to play the game reliably.  You can");
        BE_ST_puts ("play anyway, but an out of memory condition will eventually pop up.  The");
        BE_ST_puts ("correct solution is to unload some TSRs or rename your CONFIG.SYS and");
        BE_ST_puts ("AUTOEXEC.BAT to free up more memory.\n");
        BE_ST_puts ("Do you want to (Q)uit, or (C)ontinue?");
        //i = bioskey (0);
        //if ( (i>>8) != sc_C)
        i = BE_ST_BiosScanCode (0);
        if (i != sc_C)
            Quit ("");
    }
#endif

    US_TextScreen();

    VW_Startup ();
    RF_Startup ();
    IN_Startup ();
    SD_Startup ();
    US_Startup ();

#ifdef REFKEEN_VER_KDREAMS_CGA_ALL
    US_UpdateTextScreen();
#endif

    CA_Startup ();
    US_Setup ();

//
// load in and lock down some basic chunks
//

    CA_ClearMarks ();

    CA_MarkGrChunk(STARTFONT);
    CA_MarkGrChunk(STARTFONTM);
    CA_MarkGrChunk(STARTTILE8);
    CA_MarkGrChunk(STARTTILE8M);
    for ( id0_int_t j=KEEN_LUMP_START ; j<=KEEN_LUMP_END ; j++)
    {
        CA_MarkGrChunk(j);
    }

#ifdef REFKEEN_VER_KDREAMS_CGA_ALL
    CA_CacheMarks (NULL);
#elif defined REFKEEN_VER_KDREAMS_ANYEGA_ALL
    CA_CacheMarks (NULL, 0);
#endif

    MM_SetLock (&grsegs[STARTFONT],true);
    MM_SetLock (&grsegs[STARTFONTM],true);
    MM_SetLock (&grsegs[STARTTILE8],true);
    MM_SetLock (&grsegs[STARTTILE8M],true);
    for ( id0_int_t j=KEEN_LUMP_START ; j<=KEEN_LUMP_END ; j++)
    {
        MM_SetLock (&grsegs[j],true);
    }

    setupAudio();

    fontcolor = WHITE;

    RefKeen_FillObjStatesWithDOSPointers(); // Saved games compatibility

    US_FinishTextScreen();
}
void ConferenceDialog::onSipReply(const AmSipReply& reply)
{
  int status = dlg.getStatus();
  AmSession::onSipReply(reply);

  DBG("ConferenceDialog::onSipReply: code = %i, reason = %s\n, status = %i\n",
      reply.code,reply.reason.c_str(),dlg.getStatus());
    
  if(!dialedout && 
     !transfer_req.get())
    return;

  if(status < AmSipDialog::Connected){

    switch(dlg.getStatus()){

    case AmSipDialog::Connected:

      // connected!
      try {

	acceptAudio(reply.body,reply.hdrs);

	if(getDetached() && !getStopped()){
		    
	  setupAudio();
		    
	  if(getInput() || getOutput())
	    AmMediaProcessor::instance()->addSession(this,
						     getCallgroup()); 
	  else { 
	    ERROR("missing audio input and/or ouput.\n");
	    return;
	  }

	  if(!transfer_req.get()){

	    // send connect event
	    AmSessionContainer::instance()
	      ->postEvent(dialout_channel->getConfID(),
			  new DialoutConfEvent(DoConfConnect,
					       dialout_channel->getConfID()));
	  }
	  else {
	    dlg.reply(*(transfer_req.get()),202,"Accepted");
	    transfer_req.reset(0);
	    connectMainChannel();
	  }
	} 
	
      }
      catch(const AmSession::Exception& e){
	ERROR("%i %s\n",e.code,e.reason.c_str());
	dlg.bye();
	setStopped();
      }
      break;

    case AmSipDialog::Pending:

      switch(reply.code){
      case 180:

	// send ringing event
	AmSessionContainer::instance()
	  ->postEvent(dialout_channel->getConfID(),
		      new DialoutConfEvent(DoConfRinging,
					   dialout_channel->getConfID()));
		
	break;
      case 183: break;//TODO: remote ring tone.
      default:  break;// continue waiting.
      }
      break;

    case AmSipDialog::Disconnected:

      if(!transfer_req.get()){

	disconnectDialout();
	//switch(reply.code){
	//default:
	    
	AmSessionContainer::instance()
	  ->postEvent(dialout_channel->getConfID(),
		      new DialoutConfEvent(DoConfError,
					   dialout_channel->getConfID()));
	//}
      }
      else {
		
	dlg.reply(*(transfer_req.get()),reply.code,reply.reason);
	transfer_req.reset(0);
	setStopped();
      }
      break;

	    

    default: break;
    }


  }
}
void ConferenceDialog::onSessionStart(const AmSipRequest& req)
{
  int i, len;
  string lonely_user_file;

  string app_param_hdr = getHeader(req.hdrs, PARAM_HDR);
  if (app_param_hdr.length()) {
    from_header = get_header_keyvalue(app_param_hdr, "Dialout-From");
    extra_headers = get_header_keyvalue(app_param_hdr, "Dialout-Extra");
    dialout_suffix = get_header_keyvalue(app_param_hdr, "Dialout-Suffix");      
    language = get_header_keyvalue(app_param_hdr, "Language");      
  } else {
    from_header = getHeader(req.hdrs, "P-Dialout-From");
    extra_headers = getHeader(req.hdrs, "P-Dialout-Extra");
    dialout_suffix = getHeader(req.hdrs, "P-Dialout-Suffix");
    if (from_header.length() || extra_headers.length() 
	|| dialout_suffix.length()) {
      DBG("Warning: P-Dialout- style headers are deprecated."
	  " Please use P-App-Param header instead.\n");
    }
    language = getHeader(req.hdrs, "P-Language");
    if (language.length()) {
      DBG("Warning: P-Language header is deprecated."
	  " Please use P-App-Param header instead.\n");
    }
  }

  len = extra_headers.length();
  for (i = 0; i < len; i++) {
    if (extra_headers[i] == '|') extra_headers[i] = '\n';
  }
  if (extra_headers[len - 1] != '\n') {
      extra_headers += '\n';
  }

  if (dialout_suffix.length() == 0) {
    if (!ConferenceFactory::DialoutSuffix.empty()) {
      dialout_suffix = ConferenceFactory::DialoutSuffix;
    } else {
      dialout_suffix = "";
    }
  }
    
  allow_dialout = dialout_suffix.length() > 0;

  if (!language.empty()) {

#ifdef USE_MYSQL
    /* Get domain/language specific lonely user file from MySQL */
    if (get_audio_file(LONELY_USER_MSG, req.domain, language,
		       lonely_user_file) &&
	!lonely_user_file.empty()) {
      ConferenceFactory::LonelyUserFile = lonely_user_file;
    } else {
      if (get_audio_file(LONELY_USER_MSG, "", language,
			 lonely_user_file) &&
	  !lonely_user_file.empty()) {
	ConferenceFactory::LonelyUserFile = lonely_user_file;
      }
    }
#else
    /* Get domain/language specific lonely user file from file system */
    lonely_user_file = ConferenceFactory::AudioPath + "/lonely_user_msg/" +
      req.domain + "/" + "default_" + language + ".wav";
    if(file_exists(lonely_user_file)) {
      ConferenceFactory::LonelyUserFile = lonely_user_file;
    } else {
      lonely_user_file = ConferenceFactory::AudioPath +
	"/lonely_user_msg/default_" + language + ".wav";
      if(file_exists(lonely_user_file)) {
	ConferenceFactory::LonelyUserFile = lonely_user_file;
      }
    }
#endif
  }

  DBG("Using LonelyUserFile <%s>\n",
      ConferenceFactory::LonelyUserFile.c_str());
	
  setupAudio();
}
//___________________________________________________________
//      Generic Save Avi loop
//
//___________________________________________________________
//
uint8_t  GenericAviSave::saveAvi (const char *name)
{
uint32_t size;
uint8_t ret=0;
  strcpy(_name,name);
  //frametogo = frameEnd - frameStart + 1;
  frametogo=0;
  
  writter = new aviWrite ();
    // 1- setup audio
  guiStart();
  if (!setupAudio ())
    {
      guiStop();
      GUI_Error_HIG (QT_TR_NOOP("Error initalizing audio filters"), NULL);
      delete writter;
      writter = NULL;
      return 0;
    }
   
   if (!setupVideo (_name))
    {
      guiStop();
      GUI_Error_HIG (QT_TR_NOOP("Error initalizing video filters"), NULL);
      delete   	writter;
      writter = NULL;
     // guiStop();
      return 0;
    }
  
  // 3- setup video
  frametogo=_incoming->getInfo()->nb_frames;
  fps1000=_incoming->getInfo()->fps1000;
  printf ("\n writing %lu frames\n", frametogo);

  //__________________________________
  //   now go to main loop.....
  //__________________________________
  for (uint32_t cf = 0; cf < frametogo; cf++) 
    {
			
			
			
      			if (guiUpdate (cf, frametogo))
					goto abortme;
      			//   printf("\n %lu / %lu",cf,frametogo);
      			writeVideoChunk (cf);
      			writeAudioChunk (cf);
			//writter->sync();
     
     
    };				// end for
    ret=1;
abortme:
  guiStop ();
  //__________________________________
  // and end save
  //__________________________________
  writter->setEnd ();
  delete       writter;
  writter = NULL;
  // resync GUI
  printf ("\n Saving AVI (v_engine)... done\n");
  return ret;
}
Exemple #18
0
//--------------------------------------------------------------
void gamuzaMain::setup(){

	flagSystemLoaded	= false; // first line of gamuza setup

	//////////////////////////////////////////////
	// load settings from xml
	loadGamuzaSettings();
	if(START_WITH_FULLSCREEN){
		isFullscreen = true;
	}else{
		isFullscreen = false;
	}
	// automation
	if(autoPilot){
		gamuzaFullscreen();
	}
	//////////////////////////////////////////////

	//////////////////////////////////////////////
	// init general openframeworks settings
	ofSetFrameRate(FPS);
	ofEnableSmoothing();
	ofSetLogLevel(OF_LOG_VERBOSE);
	//////////////////////////////////////////////

	//////////////////////////////////////////////
	// AUDIO
	if(audioActivated){
		gamuzaSetup.lock();
		setupAudio();
		gamuzaSetup.unlock();
	}
	//////////////////////////////////////////////

	//////////////////////////////////////////////
	// OPENNI
	if(openniActivated){
		gamuzaSetup.lock();
		sensorKinect.setupDevice(workingW,workingH,useKinectInfrared,sensorKinectLedState);
		gamuzaSetup.unlock();
	}
	//////////////////////////////////////////////

	//////////////////////////////////////////////
	// FBO second screen output texture
	gamuzaSetup.lock();
	setupFBO();
	gamuzaSetup.unlock();
	//////////////////////////////////////////////

	//////////////////////////////////////////////
	// OSC data sending @ host_number(IP),host_port
	if(oscActivated){
		gamuzaSetup.lock();
		setupOSC();
		gamuzaSetup.unlock();
	}
	//////////////////////////////////////////////

	//////////////////////////////////////////////
	// ARDUINO
	if(arduinoActivated){
		gamuzaSetup.lock();
		setupArduino();
		gamuzaSetup.unlock();
	}
	//////////////////////////////////////////////

	//////////////////////////////////////////////
	// GUI
	// include setup of webcams & audio inputs
	gamuzaSetup.lock();
	setupGui();
	gamuzaSetup.unlock();
	//////////////////////////////////////////////

	//////////////////////////////////////////////
	// SYSTEM
	currentSavedFrame = 0;
	//////////////////////////////////////////////

	//////////////////////////////////////////////
	// set log level to error only
	ofSetLogLevel(OF_LOG_ERROR);
	//////////////////////////////////////////////

}
Exemple #19
0
//--------------------------------------------------------------
void gamuzaMain::setup(){

	flagSystemLoaded	= false; // first line of gamuza setup

	//////////////////////////////////////////////
	// load settings from xml
	loadGamuzaSettings();
	// automation
    isFullscreen = false;
	if(autoPilot){
		gamuzaFullscreen();
	}
	//////////////////////////////////////////////

	//////////////////////////////////////////////
	// init general openframeworks settings
    ofSetEscapeQuitsApp(false);
	ofSetFrameRate(200);
	ofEnableSmoothing();
	ofSetLogLevel(OF_LOG_VERBOSE);
	//////////////////////////////////////////////

    //////////////////////////////////////////////
	// OSC data sending @ host_number(IP),host_port
    gamuzaSetup.lock();
    setupOSC();
    gamuzaSetup.unlock();
	//////////////////////////////////////////////

	//////////////////////////////////////////////
	// AUDIO
	if(audioActivated){
		gamuzaSetup.lock();
		setupAudio();
		gamuzaSetup.unlock();
	}
	//////////////////////////////////////////////

    //////////////////////////////////////////////
	// MIDI
    gamuzaSetup.lock();
    setupMidi();
    gamuzaSetup.unlock();
    //////////////////////////////////////////////

	//////////////////////////////////////////////
	// OPENNI
	if(openniActivated){
		gamuzaSetup.lock();
		sensorKinect.setupDevice(workingW,workingH,useKinectInfrared,sensorKinectLedState);
		gamuzaSetup.unlock();
	}
	//////////////////////////////////////////////

	//////////////////////////////////////////////
	// FBO second screen output texture
	gamuzaSetup.lock();
	setupFBO();
	gamuzaSetup.unlock();
	//////////////////////////////////////////////

	//////////////////////////////////////////////
	// ARDUINO
	if(arduinoActivated){
		gamuzaSetup.lock();
		setupArduino();
		gamuzaSetup.unlock();
	}
	//////////////////////////////////////////////

	//////////////////////////////////////////////
	// GUI
	// include setup of webcams & audio inputs
	gamuzaSetup.lock();
    setupSettingPanel();
	setupGui();
	gamuzaSetup.unlock();
	//////////////////////////////////////////////

	//////////////////////////////////////////////
	// SYSTEM
	currentSavedFrame   = 0;
    gaFrameCounter      = 0;
    //////////////////////////////////////////////

	//////////////////////////////////////////////
	// set log level to error only
	ofSetLogLevel(OF_LOG_ERROR);
    sendPrivateMessage(GAMUZA_CONSOLE_LOG, " ");
	//////////////////////////////////////////////

}
bool admSaver::save(void)
{


    int ret=false;
    
    
    ADM_info("Audio starting time %s\n",ADM_us2plain(startAudioTime));
    ADM_info("[A_Save] Saving..\n");
    
    const char *defaultExtension=ADM_MuxerGetDefaultExtension(muxerIndex);
    EditableAudioTrack *ed=NULL;
    ADM_info("Muxer default extension %s\n",defaultExtension);
    if(!videoEncoderIndex) 
    {
        if(false==video_body-> checkCutsAreOnIntra())
        {
            if(!GUI_Question("The video is in copy mode but the cut points are not on keyframes.\n"
                            "The video will be saved but there will corruption at cut point(s).\n"
                             "Do you want to continue anyway ?"))
            {
                return false;
            }
        }
    }

    if(!(muxer=ADM_MuxerSpawnFromIndex(muxerIndex)))
    {
        GUI_Error_HIG("Muxer","Cannot instantiante muxer");
        return 0;
    }
     
    ADM_videoStream *video=setupVideo();
    if(!video)
    {
        return false;
    }
    // adjust audio starting time
     for(int i=0;i<nbAudioTracks;i++)
        {
            ADM_audioStream  *stream=video_body->getAudioStreamAt(i);
            stream->goToTime(startAudioTime);
        }
    if(false==setupAudio())
    {
        if(video) delete video;
        if(muxer) delete muxer;
        muxer=NULL;
        return false;
    }
   
    // Check if we need to add an extension....
    if(defaultExtension)
    {
        if(!strstr(fileName.c_str(),"."))
        {
            
            fileName=fileName+std::string(".")+std::string(defaultExtension);
            ADM_info("Adding extension, filename is now %s\n",fileName.c_str());
        }

    }
    if(!muxer->open(fileName.c_str(),video,nbAudioTracks,audioAccess))
    {
        GUI_Error_HIG("Muxer","Cannot open ");
    }else
    {
        ret=muxer->save();
        muxer->close();
    }
abort123:
    if(video)
        delete video;
    video=NULL;
    for(int i=0;i<nbAudioTracks;i++)
    {
        delete audioAccess[i];
        audioAccess[i]=NULL;
    }
    return ret;
}
//___________________________________________________________
//      Generic Save Avi loop
//
//___________________________________________________________
//
uint8_t  GenericAviSave::saveAvi (const char *name)
{
    uint32_t size;
    uint8_t ret=0;
    strcpy(_name,name);
    //frametogo = frameEnd - frameStart + 1;
    frametogo=0;

    writter = new aviWrite ();
    // 1- setup audio
    guiStart();
    if (!setupAudio ())
    {
        guiStop();
        GUI_Error_HIG (QT_TR_NOOP("Error initalizing audio filters"), NULL);
        delete writter;
        writter = NULL;
        return 0;
    }

    if (!setupVideo (_name))
    {
        guiStop();
        GUI_Error_HIG (QT_TR_NOOP("Error initalizing video filters"), NULL);
        delete   	writter;
        writter = NULL;
        // guiStop();
        return 0;
    }

    // 3- setup video
    frametogo=_incoming->getInfo()->nb_frames;
    fps1000=_incoming->getInfo()->fps1000;
    printf ("\n writing %lu frames\n", frametogo);

    //__________________________________
    //   now go to main loop.....
    //__________________________________
    int frameDelay = 0;
    int videoSize;

    for (uint32_t cf = 0; cf < frametogo; cf++)
    {
        if (guiUpdate(cf, frametogo))
            goto abortme;

        for (;;)
        {
            videoSize = writeVideoChunk(cf + frameDelay);

            if (videoSize == 0 && _encode && (_encode->getRequirements() & ADM_ENC_REQ_NULL_FLUSH))
            {
                printf("skipping frame: %u size: %i\n", cf + frameDelay, videoSize);
                frameDelay++;
            }
            else
                break;
        }

        writeAudioChunk(cf);
    }

    ret=1;
abortme:
    guiStop ();
    //__________________________________
    // and end save
    //__________________________________
    writter->setEnd ();
    delete       writter;
    writter = NULL;
    // resync GUI
    printf ("\n Saving AVI (v_engine)... done\n");
    return ret;
}
int initToneGenerator(void)
{
    _int32 staticMemSize, scratchMemSize;
    int policy;
    struct sched_param param;
    int error;
    pthread_attr_t attr;

    if( live == RUNNING) {
        return 0;
    } else if( live == DEAD ) {
        return -EINVAL;
    }


   if( (error = pthread_mutex_init (&fillMutex, NULL) ) != 0 ) {
		return error;
	}

    tone_count = 0;
    if( (error = pthread_mutex_init( &toneMutex, NULL ) ) != 0 ) {
        return error;
    }

    if( (error = pthread_cond_init( &condvar_newtone, NULL ) ) != 0 ) {
        pthread_mutex_destroy( &toneMutex );
        return error;
    }

    audio_manager_get_handle( AUDIO_TYPE_VOICE_TONES, getpid(), true, &audioman_handle );

    if( (error = setupAudio( )) != 0 ) {
        slogf( _SLOG_SETCODE(_SLOGC_AUDIO, 0), _SLOG_CRITICAL, "Unable to initialize audio %s\n", snd_strerror(error));
        pthread_mutex_destroy( &toneMutex );
        pthread_cond_destroy( &condvar_newtone );
        if( audioman_handle ) {
            audio_manager_free_handle( audioman_handle );
        }
        return error;
    }

	// Re-usable buffer for generation
	stage_buffer = malloc (frame_size);
	memset(stage_buffer, 0, frame_size);
	stage_samples = malloc (frame_size);
	memset(stage_samples, 0, frame_size);
	record_buffer = malloc (frame_size);
	memset(record_buffer, 0, frame_size);
	render_buffer = malloc (frame_size);
	memset(render_buffer, 0, frame_size);

    // Default tonegen volume is 75% to achieve a 16dB loss ( SW mixer uses 10%=6dB. )
    setVolume(85);

    live = RUNNING;

    pthread_attr_init (&attr);
    pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_JOINABLE);
    pthread_attr_setinheritsched (&attr, PTHREAD_EXPLICIT_SCHED);
    pthread_getschedparam (pthread_self (), &policy, &param);
    param.sched_priority=12;
    pthread_attr_setschedparam (&attr, &param);
    pthread_attr_setschedpolicy (&attr, SCHED_RR);

    if( (error = pthread_create( &toneGeneratorThread, &attr, processTones, NULL ) ) != 0 ) {
        slogf( _SLOG_SETCODE(_SLOGC_AUDIO, 0), _SLOG_CRITICAL, "Unable to create tone thread %s\n", strerror(error));
        snd_pcm_close (playback_handle);
        //free( frag_buffer );
        pthread_mutex_destroy( &toneMutex );
        pthread_cond_destroy( &condvar_newtone );

        live = STOPPED;
        if( audioman_handle ) {
            audio_manager_free_handle( audioman_handle );
        }
        pthread_attr_destroy(&attr);
        return error;
    }

    pthread_attr_destroy(&attr);

    return 0;
}
Exemple #23
0
UEditorWindow::UEditorWindow(QWidget *parent)
    : QMainWindow(parent),
      ui(new Ui::EditWindowClass),
      _confirmCloseMessageBox(0),
      _redoAction(0),
      _undoAction(0),
      _spaceNoteGeneration(false)
{

    this->setFocusPolicy(Qt::StrongFocus);
_startTime=0;
    _playViolon = false;
    _currentFile = NULL;
    _isPlaying=false;
setAcceptDrops(true);
USetting::Instance.init();

#ifdef QT_MODULE_NETWORK
UCheckUpdate * check = new UCheckUpdate(QUrl(URL_VERSION));
connect(check,SIGNAL(connected()),this,SLOT(onConnected()));
#endif


    setupAudio();
    setupUi();

            _currentFile = new UFile(this);// "songs/arkol - vingt ans/Arkol - vingt ans.txt");

            fileConnect();

            this->showSentenceWidget->setHScroll(0);

        connect(ui->vScroll,SIGNAL(valueChanged(int)),this,SLOT(onUpdateVScrollAndScale(int)));
        connect(ui->vSlider,SIGNAL(valueChanged(int)),this,SLOT(onUpdateVScrollAndScale(int)));
        connect(ui->vScroll,SIGNAL(sliderPressed()),this,SLOT(onUpdateVScrollAndScale()));
        connect(ui->vSlider,SIGNAL(sliderPressed()),this,SLOT(onUpdateVScrollAndScale()));
        //connect(ui->vScroll,SIGNAL(actionTriggered(int)),this,SLOT(changeVScroll(int)));

        connect(_hScroll,SIGNAL(valueChanged(int)),this,SLOT(changeHScroll(int)));
        //connect(ui->hSlider,SIGNAL(valueChanged(int)),this,SLOT(changeHSlider(int)));
        connect(_hScroll,SIGNAL(sliderPressed()),this,SLOT(changeHScroll()));
        //connect(ui->hSlider,SIGNAL(sliderPressed()),this,SLOT(changeHSlider()));
        connect(_hScroll,SIGNAL(pageStepChanged(int)),this,SLOT(changeHSlider(int)));





        connect(ui->actionOpen,SIGNAL(triggered()),this,SLOT(openFile()));

        connect(ui->actionEditHeaders,SIGNAL(triggered()),this,SLOT(editHeader()));
        connect(ui->actionApplyOffset,SIGNAL(triggered()),this,SLOT(openTiming()));
        connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about()));
        connect(playAction, SIGNAL(triggered()), this, SLOT(tooglePlay()));
        connect(pauseAction, SIGNAL(triggered()), this, SLOT(tooglePlay()));
        connect(recordAction, SIGNAL(triggered()), this, SLOT(toggleRecord()));
        connect(showSentenceWidget,SIGNAL(haveToStop()), this, SLOT(tooglePlay()));

        connect(this->ui->offsetSpinBox, SIGNAL(valueChanged(int)), showSentenceWidget, SLOT(setPreviousDisplayed(int)));
        this->ui->offsetSpinBox->setValue(2);
        connect(ui->actionSetNormalNote,SIGNAL(triggered()),showSentenceWidget, SLOT(setNormal()));
        connect(ui->actionSetFreeNote,SIGNAL(triggered()),showSentenceWidget, SLOT(setFree()));
        connect(ui->actionSetGoldNote,SIGNAL(triggered()),showSentenceWidget, SLOT(setGold()));

        connect(ui->actionMergeNotes,SIGNAL(triggered()),showSentenceWidget, SLOT(fusion()));
        connect(ui->actionSplitNote,SIGNAL(triggered()),showSentenceWidget, SLOT(split()));

        connect(ui->actionAddNote,SIGNAL(triggered()),showSentenceWidget, SLOT(nextClickAddNote()));
        connect(ui->actionAddSeparator,SIGNAL(triggered()),showSentenceWidget, SLOT(nextClickAddSeparator()));

        connect(ui->actionSave,SIGNAL(triggered()),this,SLOT(save()));
        connect(ui->actionSaveAs,SIGNAL(triggered()),this,SLOT(saveAs()));
        connect(ui->actionNew,SIGNAL(triggered()),this,SLOT(newSong()));

        connect(ui->actionQuit,SIGNAL(triggered()),this,SLOT(close()));

        connect(&UInputManager::Instance,SIGNAL(spacePressEvent(void)),this,SLOT(tooglePlay()));

        connect(_wydget_timeline, SIGNAL(gapModified(double)),this, SLOT(gapModified(double)));

         connect(ui->actionDeleteNote,SIGNAL(triggered()),showSentenceWidget,SLOT(deleteNotes()));

        connect(ui->actionPreferences,SIGNAL(triggered()),&USetting::Instance,SLOT(showDialog()));

        connect(ui->actionMorphe,SIGNAL(triggered()),showSentenceWidget,SLOT(calquer()));


        connect(ui->actionLockTimings,SIGNAL(toggled(bool)),showSentenceWidget,SLOT(lockTime(bool)));

        connect(ui->actionCenter,SIGNAL(triggered()),this,SLOT(centerView()));

        connect(ui->actionHelp,SIGNAL(triggered()),this,SLOT(displayHelpScreen()));
        connect(ui->actionSendFeedback,SIGNAL(triggered()),this,SLOT(displayFeedback()));




        onUpdateVScrollAndScale();
        changeHScroll(0);


       // _currentFile = new UFile(this);
        this->showSentenceWidget->setLyrics(_currentFile->lyrics);
        _wydget_lyrics->setWidgetWords(showSentenceWidget);


        _undoAction = _currentFile->lyrics->history().createUndoAction(this->ui->menuEdit, tr("Annuler "));
        _undoAction->setShortcut(QKeySequence::Undo);
        _undoAction->setIcon(QIcon(":/images/undo.png"));
        this->ui->menuEdit->addAction(_undoAction);
        this->ui->toolBar->insertAction(this->ui->actionSetNormalNote, _undoAction);

        _redoAction = _currentFile->lyrics->history().createRedoAction(this->ui->menuEdit, tr("Refaire "));
        _redoAction->setShortcut(QKeySequence::Redo);
        _redoAction->setIcon(QIcon(":/images/redo.png"));
        this->ui->menuEdit->addAction(_redoAction);
        this->ui->toolBar->insertAction(this->ui->actionSetNormalNote, _redoAction);


        readLastFile();

        connect(ui->actionRecentFiles,SIGNAL(triggered()),this,SLOT(openLastFile()));



        readSettings();

        _spaceNote = new Recorder(this->showSentenceWidget);

        _autoSaveTimer = new QTimer(this);
          connect(_autoSaveTimer, SIGNAL(timeout()), this, SLOT(autoSave()));

          adaptNewFile();


}