コード例 #1
0
ファイル: StringList.cpp プロジェクト: hihiy/IntelliVoice
void StringList::add (const ssi_char_t *filename) {

	SSI_DBG (SSI_LOG_LEVEL_DEBUG, "add new entry: %s\n", filename);

	ssi_char_t *new_filename = ssi_strcpy (filename);
	_strings.push_back (new_filename);
}
コード例 #2
0
ファイル: EventConsumer.cpp プロジェクト: hcmlab/mobileSSI
void EventConsumer::consume (IConsumer::info info) {
	
	if (info.dur <= 0) {
		return;
	}

	ssi_msg (SSI_LOG_LEVEL_DETAIL, "update (%.2lf@%.2lf, status: %d)", info.dur, info.time, info.status);

	for (ssi_size_t i = 0; i < _consumer_count; i++) {

        SSI_DBG (SSI_LOG_LEVEL_DEBUG, "update '%s'", _consumer[i]->_consumer->getName ());

		int status = _consumer[i]->consume (info);	
#if __gnu_linux__
        if(_terminate)return;
#endif
		// check if operation was successful
		// otherwise try to handle the error
		switch (status) {
			case TimeBuffer::SUCCESS:
				// operation was successful!							
				break;
			case TimeBuffer::DATA_NOT_IN_BUFFER_YET:
				// not all _data is yet available
				// we return and hope that it will be available at next call..
				SSI_DBG (SSI_LOG_LEVEL_DEBUG, "data not in buffer yet '%s'", _consumer[i]->_consumer->getName ());
				break;
			case THEFRAMEWORK_ERROR:
				// framework error, probably framework is in idle mode
				// there is not much to do for us but wait..
				//SSI_DBG (SSI_LOG_LEVEL_DEBUG, "framework not running '%s'", _consumer[i]->getName ());
				break;
			default:
				// well, something critical happend, probably the requested _data is not available anymore				
				ssi_wrn ("requested data not available (%s) '%s'", TimeBuffer::STATUS_NAMES[status], _consumer[i]->_consumer->getName ());
				ssi_time_t frame_time = _frame->GetElapsedTime ();
				_consumer[i]->_consumer->consume_fail (info.time, frame_time - info.time, _consumer[i]->_stream_number, _consumer[i]->_streams);
				info.time = frame_time;
				break; 
		}
	}
}
コード例 #3
0
ファイル: Rank.cpp プロジェクト: hihiy/IntelliVoice
bool Rank::train (ISamples &samples,
	ssi_size_t stream_index) {

	if (!_model) {
		ssi_wrn ("a model has not been set yet");
		return false;
	}

	release ();

	_n_scores = samples.getStream (stream_index).dim;	
	_scores = new score[_n_scores];

	Evaluation eval;
	Trainer trainer (_model, stream_index);
	
	SSI_DBG (SSI_LOG_LEVEL_DEBUG, "evaluate dimensions:");
	for (ssi_size_t ndim = 0; ndim < _n_scores; ndim++) {
		ISSelectDim samples_s (&samples);
		samples_s.setSelection (stream_index, 1, &ndim);
		if (_options.loo) {
			eval.evalLOO (&trainer, samples_s);
		} else if (_options.louo) {
			eval.evalLOUO (&trainer, samples_s);
		} else {
			eval.evalKFold (&trainer, samples_s, _options.kfold);
		}
		_scores[ndim].index = ndim;
		_scores[ndim].value = eval.get_classwise_prob ();
		SSI_DBG (SSI_LOG_LEVEL_DEBUG, "  #%02u -> %.2f", _scores[ndim].index, _scores[ndim].value);
	} 

	trainer.release ();

	return true;
}
コード例 #4
0
ファイル: FileReader.cpp プロジェクト: hcmlab/mobileSSI
void FileReader::run () {
	
	if (_stopped) {
		::Sleep (100);
		return;
	}

	if (_is_providing) {
		if (_file_stream_in.read (_stream) == FileStreamIn::READ_ERROR) {
			ssi_err ("an error occured while reading file (%s)", _file_stream_in.getDataFile ()->getPath ());
		}
	}

	_is_providing = _provider->provide (_stream.ptr, _stream.num);
	if (!_is_providing) {
		::Sleep (100);
		return;
	}
	SSI_DBG (SSI_LOG_LEVEL_DEBUG, "read %u samples", _stream.num);

	if (!_timer) {
		_timer = new Timer (_options.block);
	}

	if (++_step_counter >= _max_steps)
	{
		if (_options.loop) 
		{
			if (!prepare_file ()) {
				ssi_err ("an error occured while reading file (%s)", _file_stream_in.getDataFile ()->getPath ());
			}
			ssi_msg (SSI_LOG_LEVEL_DETAIL, "loop 'path=%s'", _options.path);
		}
		else
		{
			ssi_msg (SSI_LOG_LEVEL_DETAIL, "release 'path=%s'", _options.path);
			_stopped = true;
			_interrupted = false;
			_event.release ();
		}
	
	}
	
	_timer->wait ();
}
コード例 #5
0
void SocketEventReader::run () {

	int result = 0;
	
	if (_options.osc) {
		result = _socket_osc->recv (this, _options.timeout); 
	} else {
		result = _socket->recv (_buffer, _options.size, _options.timeout); 
		if (result > 0) {
			// send event
			if (_elistener) {
				_event_string.time = _frame->GetElapsedTimeMs ();
				_event_string.dur = 0;
				ssi_event_adjust (_event_string, ssi_strlen (_buffer) + 1);
				strcpy (_event_string.ptr, _buffer);
				_elistener->update (_event_string);
			}	
		}
	}

	SSI_DBG (SSI_LOG_LEVEL_DEBUG, "received %d bytes", result);
};
コード例 #6
0
ファイル: FFMPEGReader.cpp プロジェクト: hcmlab/mobileSSI
void FFMPEGReader::run () {

	if (_video_provider) {
		
		ssi_size_t n_bytes;
		bool is_old;
		ssi_byte_t *frame = _video_buffer->pop(n_bytes, is_old);
		
		SSI_ASSERT (n_bytes == ssi_video_size (_video_format));
		
		if (!_options.bestEffort || !is_old) //in bestEffort mode we only provide new frames
		{
			bool result = _video_provider->provide(frame, 1);

			if (!_options.stream) {
				if (result) {
					_video_buffer->pop_done();
				}
			}
			else {
				_video_buffer->pop_done();
			}

			SSI_DBG(SSI_LOG_LEVEL_DEBUG, "video buffer : %.2f%% ", _video_buffer->getFillState() * 100);
		}
	}

	if (_audio_provider) {

		ssi_size_t n_samples;
		bool is_old;
		ssi_real_t *chunk = _audio_buffer->pop(n_samples, is_old);

		if (!_options.bestEffort || !is_old) // in bestEffort mode we only provide new frames
		{
			bool result = _audio_provider->provide(ssi_pcast(ssi_byte_t, chunk), n_samples);
			if (!_options.stream) {
				if (result) {
					_audio_buffer->pop_done(n_samples);
				}
			}
			else {
				_audio_buffer->pop_done(n_samples);
			}

			SSI_DBG(SSI_LOG_LEVEL_DEBUG, "audio buffer : %.2f%% ", _audio_buffer->getFillState() * 100);
		}
	}

	if (_client->getState() == FFMPEGReaderClient::STATE::IDLE || _client->getState() == FFMPEGReaderClient::STATE::TERMINATE)
	{

		if (_audio_provider) // provide remaining samples in buffer
		{
			ssi_size_t n_samples;
			ssi_real_t *chunk = _audio_buffer->pop_all(n_samples);
			if (n_samples > 0)
			{
				_audio_provider->provide(ssi_pcast(ssi_byte_t, chunk), n_samples);
			}
		}

		_interrupted = false;
		_wait_event.release();
	}

	if (!_options.bestEffort)
	{
		_timer->wait();
	}
}