Ejemplo n.º 1
0
void pdsp::PRNoiseGen::process(int bufferSize) noexcept  {

        int trigSeedBufferState;
        const float* trigSeedBuffer = processInput(input_trig_seed, trigSeedBufferState);

        int trigSyncBufferState;
        const float* trigSyncBuffer = processInput(input_trig_clock, trigSyncBufferState);

        //generate noise
        switch(trigSyncBufferState){
            case Unchanged: case Changed:
                process_run(bufferSize); //just noise
            break;
            case AudioRate:
                switch (trigSeedBufferState){
                    case Unchanged: case Changed:
                         process_PA(trigSyncBuffer, bufferSize);
                    break;
                        
                    case AudioRate:                    
                        process_SA_TA(trigSyncBuffer, trigSeedBuffer, bufferSize);
                    break;
                    
                    default: break;                       
                }
            break;
            
            default: break;
        }
        
}
Ejemplo n.º 2
0
void pdsp::EnvelopeFollower::process (int bufferSize) noexcept {
    
    int inputState;
    const float* inputBuffer = processInput(input, inputState);

    if(inputState==AudioRate){
                           
        int changed;
        const float* attackBuffer = processInput(in_attack_ms, changed);
        if(changed) {  attackCoeff  = expf( TC / (attackBuffer[0]  * sampleRate * 0.001f) ); }
        const float* releaseBuffer = processInput(in_release_ms, changed);
        if(changed) {  releaseCoeff = expf( TC / (releaseBuffer[0] * sampleRate * 0.001f) ); }
        
        float* outputBuffer = getOutputBufferToFill(output);
        
        for(int n=0; n<bufferSize; ++n){
            float xn = inputBuffer[n]; 
            if(xn > envelopeOutput ){
                envelopeOutput = attackCoeff  * (envelopeOutput-xn) + xn;
            }else{
                envelopeOutput = releaseCoeff * (envelopeOutput-xn) + xn;
            }
            outputBuffer[n] = envelopeOutput;
        }
        
        meter.store(outputBuffer[0]);
        
    }else{
        
        setOutputToZero( output );
        meter.store( 0.0f );
        
    }
    
}
Ejemplo n.º 3
0
void pdsp::Amp::process (int bufferSize) noexcept {
    
    int modState;
    const float* modBuffer = processInput(input_mod, modState);
    meter.store(modBuffer[0]);
        
    if ( modBuffer[0] == 0.0f && modState != AudioRate ){

        setOutputToZero(output);
        meterOut.store(0.0f);   
             
    }else{        
           
        int signalState;
        const float* signalBuffer = processInput(input_signal, signalState);

        if (signalState == AudioRate){
            float* outputBuffer = getOutputBufferToFill(output);
            if (modState == AudioRate){
                ofx_Aeq_BmulC(outputBuffer, signalBuffer, modBuffer, bufferSize);
            }else{
                ofx_Aeq_BmulS(outputBuffer, signalBuffer, modBuffer[0], bufferSize);
            }
            meterOut.store(outputBuffer[0]);       
        }else {
            float out = modBuffer[0]*signalBuffer[0];
            setControlRateOutput(output, out);
            meterOut.store(out);       
        }
        
    }
    


}
Ejemplo n.º 4
0
void pdsp::Bitcruncher::process (int bufferSize) noexcept  {
       
        int inputBufferState;
        const float* inputBuffer = processInput(input_signal, inputBufferState);
     
        if( inputBufferState == AudioRate){
            int bitsState;
            const float* bitsBuffer = processInput(input_bits, bitsState);
         
            switch (bitsState){
                case Unchanged:
                    process_audio<false>(inputBuffer, bitsBuffer, bufferSize);
                    break;
                case Changed:
                    multiply = powf(2.0f, bitsBuffer[0]);
                    scaleBack = 1.0f / multiply;
                    process_audio<false>(inputBuffer, bitsBuffer, bufferSize);
                    break;      
                case AudioRate:
                    process_audio<true>(inputBuffer, bitsBuffer, bufferSize);
                    break;          
            }     
        }else{
            setOutputToZero(output);
        }
}
Ejemplo n.º 5
0
void pdsp::GainComputer::process (int bufferSize) noexcept {
  
        int inputState;
        const float* inputBuffer = processInput(input, inputState);

        if(inputState==AudioRate){
                
                float threshold = processAndGetSingleValue(in_thresh, 0);
                float knee = processAndGetSingleValue(input_knee, 0);
                
                int ratioChanged;
                const float * ratioBuffer = processInput(input_ratio, ratioChanged);
                
                if(ratioChanged){
                    if(ratioBuffer[0] > 40.0f){
                        CS = 1.0f;
                    }else{
                        CS = 1.0f-(1.0f/ratioBuffer[0]);
                    }
                }

                float* outputBuffer = getOutputBufferToFill(output);
                
                if(knee>0.0f){
                        vect_calculateGainReductionDBWithKnee(outputBuffer, inputBuffer, threshold, CS, knee, bufferSize); 
                }else{
                        vect_calculateGainReductionDB(outputBuffer, inputBuffer, threshold, CS, bufferSize); 
                }
                
                meter.store(outputBuffer[0]);
        }else{
            setOutputToZero(output);
            meter.store(0.0f);
        }  
}
Ejemplo n.º 6
0
void pdsp::Decimator::process (int bufferSize) noexcept {
        int inputBufferState;
        const float* inputBuffer = processInput(input_signal, inputBufferState);
          
        if( inputBufferState == AudioRate){
            int freqBufferState;
            const float* freqBuffer = processInput(input_freq, freqBufferState);
             
            switch (freqBufferState){
                case Unchanged:
                    process_audio<false>(inputBuffer, freqBuffer, bufferSize);
                    break;
                case Changed:
                    inc = freqBuffer[0] * incCalculationMultiplier;
                    process_audio<false>(inputBuffer, freqBuffer, bufferSize);
                    break;      
                case AudioRate:
                    process_audio<true>(inputBuffer, freqBuffer, bufferSize);
                    break;          
            }     
            
            if(phase >= 1.0f){ // if the fre rate is higher than the sampling rate this could happen
                int phase_i = static_cast<int> (phase);
                phase -= phase_i;
            }
        }else{
            setOutputToZero(output);
        }

}
Ejemplo n.º 7
0
bool GUIConfirmRegistration::OnEvent(const SEvent &event)
{
	if (event.EventType == EET_KEY_INPUT_EVENT) {
		// clang-format off
		if ((event.KeyInput.Key == KEY_ESCAPE ||
				event.KeyInput.Key == KEY_CANCEL) &&
				event.KeyInput.PressedDown) {
			closeMenu(false);
			return true;
		}
		// clang-format on
		if (event.KeyInput.Key == KEY_RETURN && event.KeyInput.PressedDown) {
			acceptInput();
			if (processInput())
				closeMenu(true);
			return true;
		}
	}

	if (event.EventType != EET_GUI_EVENT)
		return Parent ? Parent->OnEvent(event) : false;

	if (event.GUIEvent.EventType == gui::EGET_ELEMENT_FOCUS_LOST && isVisible()) {
		if (!canTakeFocus(event.GUIEvent.Element)) {
			dstream << "GUIConfirmRegistration: Not allowing focus "
				   "change."
				<< std::endl;
			// Returning true disables focus change
			return true;
		}
	} else if (event.GUIEvent.EventType == gui::EGET_BUTTON_CLICKED) {
		switch (event.GUIEvent.Caller->getID()) {
		case ID_confirm:
			acceptInput();
			if (processInput())
				closeMenu(true);
			return true;
		case ID_cancel:
			closeMenu(false);
			return true;
		}
	} else if (event.GUIEvent.EventType == gui::EGET_EDITBOX_ENTER) {
		switch (event.GUIEvent.Caller->getID()) {
		case ID_confirmPassword:
			acceptInput();
			if (processInput())
				closeMenu(true);
			return true;
		}
	}

	return false;
}
Ejemplo n.º 8
0
void MainGame::gameLoop() {
	while (_gameState != GameState::EXIT) {
		processInput();
		_time += 0.01f;
		draw();
	}
}
Ejemplo n.º 9
0
void MainGame::gameLoop()
{
	Skengine::FpsLimiter fpsLimiter;
	fpsLimiter.setMaxFPS(60);
	while (_currentState == GAME_STATE::PLAY)
	{
		fpsLimiter.begin();



		processInput();
		_camera.setPosition(_player->getPosition());
		_camera.update();
		//UPDUATE AGENTS
		for (int i = 0; i < _humans.size(); i++)
		{
			_humans[i]->update(_levels[_currentLevel]->getLevelData(), _humans, _zombies);
		}
		for (int i = 0; i < _humans.size(); i++)
		{
			for (int j = i + 1; j < _humans.size(); j++)
			{
				_humans[i]->collideWithAgent(_humans[j]);
			}
		}

		//Add Zombies
		drawGame();

		_fps = fpsLimiter.end();
	}
}
Ejemplo n.º 10
0
void MultiplayerGUI::clientDataRecieved()
{
    while(clientSock->canReadLine()){
        QString str = clientSock->readLine();
        processInput(str);
    }
}
QString LanguageDetector::detectLanguage(QString inputStr){
    processInput(inputStr);
    init();
    int weight = 1;
    QList<int> occurenceList = inputWeightMap->uniqueKeys();
    QList<QString> languageList = languageScoreMap->keys();
    for(int i = occurenceList.size() - 1; i > -1; i--)  {
        QList<QString> sameWeightNGramList = inputWeightMap->values(occurenceList.at(i));

        for(int j = 0; j < sameWeightNGramList.size(); j++) {
            QString nGram = sameWeightNGramList[j];
            for(int k = 0; k < languageList.size(); k++) {
                QString language = languageList.at(k);
                updateScore(language, nGram, weight);
            }
            languageList = removeNonProbableLanguages(languageList, 3);
            if(languageList.size() == 1) {
                return languageList.at(0);
            }
        }
        weight++;
    }
    languageList = removeNonProbableLanguages(languageList, 0);
    return languageList.at(0);
}
Ejemplo n.º 12
0
void Boiler::run()
{
	double prevTime = SDL_GetTicks();
	double frameLag = 0.0f;

	running = true;
	while(running)
	{
		//get the delta time
		double currentTime = SDL_GetTicks();
		double frameDelta = (currentTime - prevTime) / 1000.0f;
		prevTime = currentTime;
		frameLag += frameDelta;

		processInput();

		while (frameLag >= frameInterval)
		{
			// TODO: Render system needs to not kick in when frame is lagging, only physics etc systems should be updated during frame lag catchup.
			// Need a clean way to essentially move the render() to outside the while loop here (after).
			update(frameInterval);
			part->update(frameInterval);
			frameLag -= frameInterval;
		} 
		
		renderer->beginRender();
		renderSystem->update(getEcs().getComponentStore(), frameDelta);
		glyphSystem->update(getEcs().getComponentStore(), frameDelta);
		renderer->endRender();
	}
}
Ejemplo n.º 13
0
void Util::waitMouseUp() {
	do {
		processInput();
		if (_mouseButtons != kMouseButtonsNone)
			delay(10);
	} while (_mouseButtons != kMouseButtonsNone);
}
Ejemplo n.º 14
0
 // Load and process the cloud in the given PCD file
 void
 loadInputCloud (const std::string &pcd_file)
 {
   xyz_ = PointCloud::Ptr (new PointCloud);
   pcl::io::loadPCDFile (pcd_file, *xyz_);
   processInput ();
 }
Ejemplo n.º 15
0
void Game::updatePVP()
{
	cout << "|=                                                                          =|" << endl;
	cout << "|============================================================================|" << endl;
	cout << "|=                              Player VS Player                            =|" << endl;
	cout << "|============================================================================|" << endl;
	cout << "|=                                                                          =|" << endl;

	renderBoard();

	if (_error) {
		cout << "|= ERROR: Incorrect user input or block already taken.                      =|" << endl;
		_error = false;
	}
	else {
		cout << "|=                                                                          =|" << endl;
	}
		
	cout << "|= Please select a row    : ";
	cin >> rowSelection;
	cout << "|= Please select a column : ";
	cin >> colSelection;

	processInput();
}
Ejemplo n.º 16
0
void MTD_FLASHMEM ParameterReplacer::start(char const *strStart, char const *strEnd, Params *params, BlockParams *blockParams) {
  m_params = params;
  m_blockParams = blockParams;
  m_strStart = strStart;
  m_strEnd = strEnd;
  processInput();
}
Ejemplo n.º 17
0
//--------------------------------------------------------------
// control value changed
void mgDebugPane::guiChange(
  void* source,
  const char* name)
{
  mgString value;
  mgFieldControl* field = (mgFieldControl*) source;
  field->getText(value);
  field->reset();

  if (m_debugApp == NULL)
  {
    m_console->addLine(ERROR_COLOR, NULL, "mgDebugPane::setDebugApp() not called.");
    return;
  }

  value.trim();
  // echo the input
  if (value.length() > 0)
  {
    m_console->addLine(ECHO_COLOR, NULL, value);
    processInput(value);
  }
  else 
  {
    m_debugApp->debugIntro(value);
    m_console->addLine(OUTPUT_COLOR, NULL, value);
  }
}
Ejemplo n.º 18
0
void CmdPromptInput::checkEditedText(const QString& txt)
{
    updateCurrentText(txt);

    if(rapidFireEnabled)
        processInput();
}
Ejemplo n.º 19
0
void Util::waitEndFrame(bool handleInput) {
	int32 time;

	time = getTimeKey() - _startFrameTime;
	if ((time > 1000) || (time < 0)) {
		_vm->_video->retrace();
		_startFrameTime = getTimeKey();
		return;
	}

	int32 toWait = 0;
	do {
		if (toWait > 0)
			delay(MIN<int>(toWait, 10));

		if (handleInput)
			processInput();

		_vm->_video->retrace();

		time   = getTimeKey() - _startFrameTime;
		toWait = _frameWaitTime - time;
	} while (toWait > 0);

	_startFrameTime = getTimeKey();
}
int main()
{
    processInput();
    generateStringSubsets(0, 0);

    return 0;
}
Ejemplo n.º 21
0
int main(int argc, char *argv[])
{
	generateHeader(stdout);
	processInput(stdin, stdout);
	generateFooter(stdout);
	return 0;
}
Ejemplo n.º 22
0
void  MainGame::gameLoop()
{

	while (_gameState != GameState::EXIT)
	{
		//frame time measure
		float startTicks = SDL_GetTicks();
		processInput();

		_camera.update();
		drawGame();

		_time += 0.1f;
		calculateFPS();
		//print olny once every 10 frames
		static int frameCounter = 0;
		if (frameCounter == 10)
		{
			std::cout << _fps << std::endl;
			frameCounter = 0;
		}
		frameCounter++;

		float frameTicks = SDL_GetTicks() - startTicks;
		//limiting fps 
		if (1000.0f/_maxFPS >frameTicks)
		{
			SDL_Delay((1000.0f/_maxFPS)-frameTicks);
		}
	}

};
Ejemplo n.º 23
0
void Application::run()
{
	sf::Clock clock;
	sf::Time timeSinceLastUpdate = sf::Time::Zero;

	while (mWindow.isOpen())
	{
		sf::Time dt = clock.restart();
		timeSinceLastUpdate += dt;
		while (timeSinceLastUpdate > TimePerFrame)
		{
			timeSinceLastUpdate -= TimePerFrame;

			processInput();
			update(TimePerFrame);

			// Check inside this loop, because stack might be empty before update() call
			if (mStateStack.isEmpty())
				mWindow.close();
		}

		updateStatistics(dt);
		render();
	}
}
Ejemplo n.º 24
0
void OneSheeldClass::processInput()
{
  while(OneSheeldSerial.available())
  {
    processInput(OneSheeldSerial.read());
  }
}
Ejemplo n.º 25
0
static int
handleInput (void) {
  int processed = 0;

  suspendCommandQueue();

  if (!isSuspended) {
    apiClaimDriver();
    if (processInput()) processed = 1;
    apiReleaseDriver();
  }

#ifdef ENABLE_API
  else if (apiStarted) {
    switch (readBrailleCommand(&brl, KTB_CTX_DEFAULT)) {
      case BRL_CMD_RESTARTBRL:
        restartBrailleDriver();
        break;

      default:
        processed = 1;
      case EOF:
        break;
    }
  }
#endif /* ENABLE_API */

  resumeCommandQueue();
  return processed;
}
Ejemplo n.º 26
0
void VRSim::tick(float dt){
  tree.model = cavr::math::mat4f::translate(0,0,0);
  quad.model = cavr::math::mat4f::translate(0,0,0);
  sphere.model = cavr::math::mat4f::translate(0,0,0);
  processInput();

}
Ejemplo n.º 27
0
void MainGame::gameLoop(){
	while (_gameState != GameState::EXIT) {
		//used for frame time measuring
		_fpsLimiter.begin();
		processInput();

		_time += 0.01f;

		_camera.update();

		//update bullets
		for (int i = 0; i < _bullets.size(); i++) {
			if (_bullets[i].update()) {
				_bullets[i] = _bullets.back();
				_bullets.pop_back();
			}
			else {
				i++;
			}
			
		}

		drawGame();
		_fps = _fpsLimiter.end();

		static int count = 0;
		count++;
		if (count == 10000) {
			std::cout << _fps << std::endl;
			count = 0;
		}
	}
}
Ejemplo n.º 28
0
void HandleTCPClient(int clntSocket, int client_id)
{
    char buffer[BUFSIZE]; // Buffer for echo string

    char logname[16];
    sprintf(logname, "log_file%03d.log", client_id);
    log_file = fopen(logname, "w"); //open log file

    numBytesRcvd = recv(clntSocket, buffer, BUFSIZE, 0); // receive first frame

    while (numBytesRcvd > 0)
    {
        // Use this format to extract the frame content
        printf("%u", *(uint16_t *)buffer);
        printf("%c", buffer[2]);
        printf("%c", buffer[3]);
        printf("%s\n", buffer + 4);
        printf("%ld\n", numBytesRcvd);
        fflush(stdout);


        buffer[numBytesRcvd] = '\0';
        processInput(buffer, clntSocket, client_id);
        printf("process input returns\n\n\n\n");

        numBytesRcvd = recv(clntSocket, buffer, BUFSIZE, 0);
        if (numBytesRcvd < 0)
            DieWithSystemMessage("recv() failed");
    }

    fclose(log_file);
}
Ejemplo n.º 29
0
//--------------------------------------------------------------
void testApp::update(){
	for (int i=0; i<cameras.size(); i++)
		cameras[i]->update();

	while (rx.hasWaitingMessages()) 
		processInput();
}
Ejemplo n.º 30
0
//======================================================================================================================
// exec                                                                                                                =
//======================================================================================================================
int Application::exec()
{
	while(1)
	{
		inputCallback();
		processInput();

		glMatrixMode(GL_MODELVIEW);
		glLoadIdentity();
		gluLookAt(camPos.getX(), camPos.getY(), camPos.getZ(), camPos.getX() - camZ.getX(), camPos.getY() - camZ.getY(),
							camPos.getZ() - camZ.getZ(), camY.getX(), camY.getY(), camY.getZ());

		glClear(GL_COLOR_BUFFER_BIT);
		glClear(GL_DEPTH_BUFFER_BIT);

		renderGrid();

		mainLoop();

		SDL_GL_SwapBuffers();
		waitForNextFrame();
	}
	
	return 0;
}