Example #1
0
bool ex_stream_info(void *arg) {

	Factory::RegisterDLL("ssimouse");

	ITheFramework *frame = Factory::GetFramework();

	Decorator *decorator = ssi_create (Decorator, 0, true);
	frame->AddDecorator(decorator);

	ITheEventBoard *board = Factory::GetEventBoard();

	//ClockEventSender *eclock = ssi_create(ClockEventSender, 0, true);

	Mouse *mouse = ssi_create(Mouse, "mouse", true);
	mouse->getOptions()->mask = Mouse::LEFT;
	mouse->getOptions()->scale = true;
	mouse->getOptions()->single = false;
	mouse->getOptions()->sendEvent = true;
	ITransformable *cursor_p = frame->AddProvider(mouse, SSI_MOUSE_CURSOR_PROVIDER_NAME);
	ITransformable *button_p = frame->AddProvider(mouse, SSI_MOUSE_BUTTON_PROVIDER_NAME);
	frame->AddSensor(mouse);
	board->RegisterSender(*mouse);

	Websocket *websocket = ssi_create(Websocket, 0, true);
	websocket->getOptions()->setHttpRoot("stream_to_browser_info");
	websocket->getOptions()->send_info = true;
	//frame->AddConsumer(cursor_p, websocket, "0.25s");

	ssi::ITransformable *src[2] = { cursor_p, button_p };
	frame->AddConsumer(2, src, websocket, "1");

	board->RegisterSender(*websocket);
	board->RegisterListener(*websocket);

	EventMonitor *monitor = ssi_create_id (EventMonitor, 0, "monitor");
	board->RegisterListener(*monitor);

	decorator->add("console", 0, 0, 650, 800);
	decorator->add("plot*", 650, 0, 400, 400);
	decorator->add("monitor*", 650, 400, 400, 400);

	board->Start();
	frame->Start();

	frame->Wait();

	frame->Stop();
	frame->Clear();

	return true;
}
Example #2
0
bool ex_gsr_arousal(void *args) {

	ITheEventBoard *board = Factory::GetEventBoard();
	ITheFramework *frame = Factory::GetFramework();

	Decorator *decorator = ssi_create(Decorator, 0, true);
	frame->AddDecorator(decorator);

	FileReader *reader = ssi_create(FileReader, 0, true);
	reader->getOptions()->setPath("data\\gsr");
	reader->getOptions()->block = 0.2;
	ITransformable *gsr_p = frame->AddProvider(reader, SSI_FILEREADER_PROVIDER_NAME);
	frame->AddSensor(reader);

	GSRArousalEstimation *arousal = ssi_create(GSRArousalEstimation, 0, true);
	ITransformable *arousal_p = frame->AddTransformer(gsr_p, arousal, "1");

	ThresClassEventSender *classifier = ssi_create(ThresClassEventSender, 0, true);
	classifier->getOptions()->setClasses("low,med,high");
	classifier->getOptions()->setThresholds("0.01,0.3,0.7");
	frame->AddConsumer(arousal_p, classifier, "1");
	board->RegisterSender(*classifier);

	EventMonitor *monitor = ssi_create_id(EventMonitor, 0, "monitor");
	board->RegisterListener(*monitor, "@");

	SignalPainter *plot = 0;

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("gsr");
	plot->getOptions()->size = 150.0;
	frame->AddConsumer(gsr_p, plot, "0.2s");

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("arousal");
	plot->getOptions()->size = 150.0;
	frame->AddConsumer(arousal_p, plot, "0.2s");

	decorator->add("console", 0, 0, 650, 800);
	decorator->add("plot*", 650, 0, 400, 400);
	decorator->add("monitor*", 650, 400, 400, 400);

	board->Start();
	frame->Start();
	frame->Wait();
	frame->Stop();
	board->Stop();
	frame->Clear();
	board->Clear();

	return true;
}
Example #3
0
bool ex_events_string(void *arg) {

	ITheFramework *frame = Factory::GetFramework();

	Decorator *decorator = ssi_create (Decorator, 0, true);
	frame->AddDecorator(decorator);

	ITheEventBoard *board = Factory::GetEventBoard();

	ClockEventSender *eclock = ssi_create(ClockEventSender, 0, true);
	eclock->getOptions()->clock = 1000;
	eclock->getOptions()->empty = false;
	eclock->getOptions()->setString("test");
	board->RegisterSender(*eclock);
	frame->AddRunnable(eclock);

	Websocket *websocket = ssi_create(Websocket, 0, true);

	board->RegisterSender(*websocket);
	board->RegisterListener(*websocket);

	EventMonitor *monitor = ssi_create_id (EventMonitor, 0, "monitor");
	board->RegisterListener(*monitor);

	decorator->add("console", 0, 0, 650, 800);
	decorator->add("plot*", 650, 0, 400, 400);
	decorator->add("monitor*", 650, 400, 400, 400);

	board->Start();
	frame->Start();

	frame->Wait();

	frame->Stop();
	frame->Clear();

	return true;
}
Example #4
0
bool ex_event(void *args)
{
	ITheFramework *frame = Factory::GetFramework();
	ITheEventBoard *board = Factory::GetEventBoard();

	Decorator *decorator = ssi_create(Decorator, 0, true);
	frame->AddDecorator(decorator);

	Mouse *mouse = ssi_create(Mouse, 0, true);
	mouse->getOptions()->mask = Mouse::LEFT;
	ITransformable *button_t = frame->AddProvider(mouse, SSI_MOUSE_BUTTON_PROVIDER_NAME);
	ITransformable *cursor_t = frame->AddProvider(mouse, SSI_MOUSE_CURSOR_PROVIDER_NAME);
	frame->AddSensor(mouse);

	PythonConsumer *py_send = ssi_create_id(PythonConsumer, 0, "pysend");
	py_send->getOptions()->setScript("ssi_send");
	ITransformable *input[] = { button_t, cursor_t };
	frame->AddConsumer(2, input, py_send, "100ms");
	board->RegisterSender(*py_send);

	PythonObject *py_listen = ssi_create_id(PythonObject, 0, "pylisten");
	py_listen->getOptions()->setScript("ssi_listen");
	board->RegisterListener(*py_listen, py_send->getEventAddress());

	EventMonitor *monitor = ssi_create_id(EventMonitor, 0, "monitor");
	board->RegisterListener(*monitor, 0, 10000u);

	SignalPainter *plot = 0;

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("CURSOR");
	frame->AddEventConsumer(cursor_t, plot, board, py_send->getEventAddress());

	decorator->add("console", 0, 0, 650, 800);
	decorator->add("plot*", 650, 0, 400, 400);
	decorator->add("monitor*", 650, 400, 400, 400);

	board->Start();
	frame->Start();
	frame->Wait();
	frame->Stop();
	board->Stop();
	frame->Clear();
	board->Clear();

	return true;
}
Example #5
0
bool ex_mobile_events(void *arg)
{

	Factory::RegisterDLL("ssiioput");

	ITheFramework *frame = Factory::GetFramework();

	Decorator *decorator = ssi_create (Decorator, 0, true);
	frame->AddDecorator(decorator);

	ITheEventBoard *board = Factory::GetEventBoard();

	Websocket *websocket = ssi_create(Websocket, 0, true);
	websocket->getOptions()->setHttpRoot("mobile_browser_to_SSI");

	board->RegisterSender(*websocket);
	board->RegisterListener(*websocket);

	EventMonitor *monitor = ssi_create_id (EventMonitor, 0, "monitor");
	board->RegisterListener(*monitor);

	FileEventWriter *writer = ssi_create(FileEventWriter, 0, true);
	writer->getOptions()->setPath("sensor_data");
	board->RegisterListener(*writer);

	decorator->add("console", 0, 0, 650, 800);
	decorator->add("plot*", 650, 0, 400, 400);
	decorator->add("monitor*", 650, 400, 400, 400);

	board->Start();
	frame->Start();

	frame->Wait();

	frame->Stop();
	frame->Clear();

	return true;
}
Example #6
0
void ex_pitchdirection () {

	//general
	ITheFramework *frame = Factory::GetFramework ();

	Decorator *decorator = ssi_create (Decorator, 0, true);
	frame->AddDecorator(decorator);

	ITheEventBoard *board = Factory::GetEventBoard ();
	ssi_pcast (TheEventBoard, board)->getOptions()->update = 250;

	// audio sensor	
#ifndef SIMULATE
	Audio *audio = ssi_create (Audio, "audio", true);
	audio->getOptions()->scale = true;		
	ITransformable *audio_p = frame->AddProvider(audio, SSI_AUDIO_PROVIDER_NAME);
#else
	WavReader *audio = ssi_create (WavReader, 0, true);
	audio->getOptions()->setPath("audio.wav");
	audio->getOptions()->scale = true;		
	ITransformable *audio_p = frame->AddProvider(audio, SSI_WAVREADER_PROVIDER_NAME);
#endif	
	frame->AddSensor(audio);
	
	OSPitchChain * pitch = ssi_create (OSPitchChain, "pitch", true);
	pitch->getOSPitchSmoother()->getOptions()->F0final = true;
	pitch->getOSPitchSmoother()->getOptions()->F0finalEnv = true;
	double frameSize = audio_p->getSampleRate() * 0.01;
	double deltaSize = audio_p->getSampleRate() * 0.04;
	pitch->getOSTransformFFT()->getOptions()->nfft = smileMath_ceilToNextPowOf2(frameSize + deltaSize); //we set the FFT frame size so it's a power of 2 but can also fit all the samples	
	pitch->getOSPitchShs()->getOptions()->baseSr = audio_p->getSampleRate();
	ssi::ITransformable *pitch_p = frame->AddTransformer(audio_p, pitch, "0.01s", "0.04s");
	
	OSEnergy * energy = ssi_create (OSEnergy, 0, true);
	energy->getOptions()->type = OSEnergy::TYPE::RMS;
	ssi::ITransformable *energy_p = frame->AddTransformer(audio_p, energy, "0.01s");

	OSPitchDirection * dir = ssi_create (OSPitchDirection, 0, true);
	ssi::ITransformable * xtra_src[1] = {energy_p};
	ssi::ITransformable *dir_p = frame->AddTransformer(pitch_p, 1, xtra_src, dir, "0.01s");
	board->RegisterSender(*dir);

	SignalPainter *audio_plot = ssi_create_id (SignalPainter, 0, "plot");
	audio_plot->getOptions()->setTitle("audio");
	audio_plot->getOptions()->size = 10.0;		
	audio_plot->getOptions()->type = PaintSignalType::AUDIO;
	frame->AddConsumer(audio_p, audio_plot, "0.2s");

	SignalPainter *pitch_plot = ssi_create_id (SignalPainter, 0, "plot");
	pitch_plot->getOptions()->setTitle("pitch");
	pitch_plot->getOptions()->size = 10.0;		
	pitch_plot->getOptions()->type = PaintSignalType::SIGNAL;
	frame->AddConsumer(pitch_p, pitch_plot, "0.2s");

	SignalPainter *energy_plot = ssi_create_id (SignalPainter, 0, "plot");
	energy_plot->getOptions()->setTitle("energy");
	energy_plot->getOptions()->size = 10.0;		
	energy_plot->getOptions()->type = PaintSignalType::SIGNAL;
	frame->AddConsumer(energy_p, energy_plot, "0.2s");
	
	SignalPainter *dir_plot = ssi_create_id (SignalPainter, 0, "plot");
	dir_plot->getOptions()->setTitle("direction");
	dir_plot->getOptions()->size = 10.0;		
	dir_plot->getOptions()->type = PaintSignalType::SIGNAL;
	frame->AddConsumer(dir_p, dir_plot, "0.2s");

	EventMonitor *monitor = ssi_create_id (EventMonitor, 0, "monitor");
	board->RegisterListener(*monitor, dir->getEventAddress());

#ifdef SIMULATE
	AudioPlayer *player = ssi_create (AudioPlayer, "player", true);
	player->getOptions()->bufferSize = 0.2;
	player->getOptions()->remember = true;
	frame->AddConsumer(audio_p, player, "0.01s");
#endif

	decorator->add("console", 0, 0, 650, 800);
	decorator->add("plot*", 650, 0, 400, 400);
	decorator->add("monitor*", 650, 400, 400, 400);

	board->Start();
	frame->Start();
	frame->Wait();
	frame->Stop();
	board->Stop();
	frame->Clear();
	board->Clear();
}
Example #7
0
void ex_vad () {

	//general
	ITheFramework *frame = Factory::GetFramework ();

	Decorator *decorator = ssi_create (Decorator, 0, true);
	frame->AddDecorator(decorator);

	ITheEventBoard *board = Factory::GetEventBoard ();
	ssi_pcast (TheEventBoard, board)->getOptions()->update = 250;

	// audio sensor	
#ifndef SIMULATE
	Audio *audio = ssi_create (Audio, "audio", true);
	audio->getOptions()->scale = true;		
	ITransformable *audio_p = frame->AddProvider(audio, SSI_AUDIO_PROVIDER_NAME);
#else
	WavReader *audio = ssi_create (WavReader, 0, true);
	audio->getOptions()->setPath("audio.wav");
	audio->getOptions()->scale = true;		
	ITransformable *audio_p = frame->AddProvider(audio, SSI_WAVREADER_PROVIDER_NAME);
#endif	
	frame->AddSensor(audio);

	SignalPainter *audio_plot = ssi_create_id (SignalPainter, 0, "plot");
	audio_plot->getOptions()->setTitle("audio");
	audio_plot->getOptions()->size = 10.0;		
	audio_plot->getOptions()->type = PaintSignalType::AUDIO;
	frame->AddConsumer(audio_p, audio_plot, "0.2s");

	OSLpc * lpc = ssi_create (OSLpc, 0, true);
	lpc->getOptions()->lsp = true;
	ssi::ITransformable *lpc_p = frame->AddTransformer(audio_p, lpc, "160");
	
	OSPitchChain * pitch = ssi_create (OSPitchChain, 0, true);
	pitch->getOSPitchShs()->getOptions()->voicingC1 = true;
	pitch->getOSPitchSmoother()->getOptions()->voicingC1 = true;
	ssi::ITransformable *pitch_p = frame->AddTransformer(audio_p, pitch, "160", "160");
	
	OSEnergy * energy = ssi_create (OSEnergy, 0, true);
	energy->getOptions()->type = OSEnergy::TYPE::LOG;
	ssi::ITransformable *energy_p = frame->AddTransformer(audio_p, energy, "160");

	OSVad * vad = ssi_create (OSVad, 0, true);
	ssi::ITransformable * src[3] = {lpc_p, pitch_p, energy_p};
	frame->AddConsumer(3, src, vad, "0.01s");
	board->RegisterSender(*vad);

	EventMonitor *monitor = ssi_create_id (EventMonitor, 0, "monitor");
	board->RegisterListener(*monitor, vad->getEventAddress());

#ifdef SIMULATE
	AudioPlayer *player = ssi_create (AudioPlayer, "player", true);
	frame->AddConsumer(audio_p, player, "0.01s");
#endif

	decorator->add("console", 0, 0, 650, 800);
	decorator->add("plot*", 650, 0, 400, 400);
	decorator->add("monitor*", 650, 400, 400, 400);

	board->Start();
	frame->Start();
	frame->Wait();
	frame->Stop();
	board->Stop();
	frame->Clear();
	board->Clear();
}
Example #8
0
bool ex_annotation(void *arg) {

	ITheFramework *frame = Factory::GetFramework();
	ITheEventBoard *board = Factory::GetEventBoard();

	Mouse *mouse = ssi_create(Mouse, 0, true);
	mouse->getOptions()->sr = 50.0;
	mouse->getOptions()->mask = Mouse::LEFT;
	ITransformable *cursor_p = frame->AddProvider(mouse, SSI_MOUSE_CURSOR_PROVIDER_NAME);
	ITransformable *button_p = frame->AddProvider(mouse, SSI_MOUSE_BUTTON_PROVIDER_NAME);
	frame->AddSensor(mouse);

	TriggerEventSender *ezero = 0;
	
	ezero = ssi_create(TriggerEventSender, 0, true);
	ezero->getOptions()->triggerType = TriggerEventSender::TRIGGER::NOT_EQUAL;
	ezero->getOptions()->setAddress("click@mouse");
	ezero->getOptions()->minDuration = 0.2;
	frame->AddConsumer(button_p, ezero, "0.25s");
	board->RegisterSender(*ezero);

	ezero = ssi_create(TriggerEventSender, 0, true);
	ezero->getOptions()->triggerType = TriggerEventSender::TRIGGER::NOT_EQUAL;
	ezero->getOptions()->setAddress("click@mouse");
	ezero->getOptions()->minDuration = 0.2;
	ezero->getOptions()->eventType = SSI_ETYPE_STRING;
	ezero->getOptions()->setEventString("string");
	frame->AddConsumer(button_p, ezero, "0.25s");
	board->RegisterSender(*ezero);

	StringEventSender *ssender = ssender = ssi_create(StringEventSender, 0, true);
	ssender->getOptions()->setAddress("cursor@string");
	ssender->getOptions()->mean = true;
	frame->AddEventConsumer(cursor_p, ssender, board, ezero->getEventAddress());
	board->RegisterSender(*ssender);

	MapEventSender *msender = 0;
	
	msender = ssi_create(MapEventSender, 0, true);
	msender->getOptions()->setAddress("cursor@map");
	msender->getOptions()->setKeys("x,y");
	frame->AddEventConsumer(cursor_p, msender, board, ezero->getEventAddress());
	board->RegisterSender(*msender);

	msender = ssi_create(MapEventSender, 0, true);
	msender->getOptions()->setAddress("cursor@map");
	msender->getOptions()->setKeys("y,x");
	frame->AddEventConsumer(cursor_p, msender, board, ezero->getEventAddress());
	board->RegisterSender(*msender);
	
	FileAnnotationWriter *annotation = 0;
			
	annotation = ssi_create(FileAnnotationWriter, 0, true);	
	annotation->getOptions()->setAnnoPath("discrete_empty_and_string");
	annotation->getOptions()->setSchemePath("scheme_discrete.annotation");
	annotation->getOptions()->setDefaultLabel("empty");
	annotation->getOptions()->defaultConfidence = 0.5f;
	annotation->getOptions()->setMeta("annotator=hans;role=wurscht");
	board->RegisterListener(*annotation, ezero->getEventAddress());	

	annotation = ssi_create(FileAnnotationWriter, 0, true);
	annotation->getOptions()->setAnnoPath("discrete_map");
	annotation->getOptions()->setSchemePath("scheme_discrete.annotation");
	annotation->getOptions()->mapKeyIndex = 1;
	annotation->getOptions()->setMeta("annotator=hans;role=wurscht");
	board->RegisterListener(*annotation, msender->getEventAddress());

	annotation = ssi_create(FileAnnotationWriter, 0, true);
	annotation->getOptions()->setAnnoPath("free_empty_and_string");
	annotation->getOptions()->setSchemePath("scheme_free");
	annotation->getOptions()->setDefaultLabel("empty");
	annotation->getOptions()->defaultConfidence = 0.5f;
	annotation->getOptions()->setMeta("annotator=hans;role=wurscht");
	board->RegisterListener(*annotation, ezero->getEventAddress());

	annotation = ssi_create(FileAnnotationWriter, 0, true);
	annotation->getOptions()->setAnnoPath("free_map");
	annotation->getOptions()->setSchemePath("scheme_free");
	annotation->getOptions()->mapKeyIndex = 1;
	annotation->getOptions()->setMeta("annotator=hans;role=wurscht");
	board->RegisterListener(*annotation, msender->getEventAddress());

	annotation = ssi_create(FileAnnotationWriter, 0, true);
	annotation->getOptions()->setAnnoPath("continuous");
	annotation->getOptions()->setSchemePath("scheme_continuous");
	annotation->getOptions()->setMeta("annotator=hans;role=wurscht");
	frame->AddConsumer(cursor_p, annotation, "1.0s");

	EventMonitor *monitor = ssi_create_id(EventMonitor, 0, "monitor");
	monitor->getOptions()->setPos(CONSOLE_WIDTH, 0, 600, 300);
	board->RegisterListener(*monitor, 0, 60000);

	board->Start();
	frame->Start();
	frame->Wait();
	frame->Stop();
	board->Stop();
	frame->Clear();
	board->Clear();

	return true;
}
Example #9
0
bool ex_sender_events (void *arg) {

	Socket::TYPE::List *type = ssi_pcast(Socket::TYPE::List, arg);

	ITheFramework *frame = Factory::GetFramework();
	ITheEventBoard *board = Factory::GetEventBoard();

	// start mouse

	Mouse *mouse = ssi_create(Mouse, 0, true);
	mouse->getOptions()->mask = Mouse::LEFT;
	mouse->getOptions()->sendEvent = true;
	mouse->getOptions()->setAddress("click@mouse");
	ITransformable *cursor_p = frame->AddProvider(mouse, SSI_MOUSE_CURSOR_PROVIDER_NAME);	
	frame->AddSensor(mouse);
	board->RegisterSender(*mouse);
	
	MapEventSender *msender = ssi_create(MapEventSender, 0, true);
	msender->getOptions()->setAddress("cursor@mouse");
	msender->getOptions()->setKeys("x,y");
	frame->AddEventConsumer(cursor_p, msender, board, mouse->getEventAddress());
	board->RegisterSender(*msender);

	// start sender and receiver

	SocketEventWriter *socket_event_writer = 0;
	
	socket_event_writer = ssi_create(SocketEventWriter, 0, true);
	socket_event_writer->getOptions()->setUrl(*type, "localhost", 1111);	
	board->RegisterListener(*socket_event_writer, msender->getEventAddress());

	socket_event_writer = ssi_create(SocketEventWriter, 0, true);
	socket_event_writer->getOptions()->setUrl(*type, "localhost", 2222);
	socket_event_writer->getOptions()->osc = true;
	socket_event_writer->getOptions()->xml = false;
	board->RegisterListener(*socket_event_writer, msender->getEventAddress());

	SocketEventReader *socket_event_reader = 0;
	
	socket_event_reader = ssi_create(SocketEventReader, 0, true);
	socket_event_reader->getOptions()->setUrl(*type, "localhost", 1111);	
	socket_event_reader->getOptions()->setAddress("click@remote");
	board->RegisterSender(*socket_event_reader);

	socket_event_reader = ssi_create(SocketEventReader, 0, true);
	socket_event_reader->getOptions()->setUrl(*type, "localhost", 2222);
	socket_event_reader->getOptions()->osc = true;
	socket_event_reader->getOptions()->setAddress("click@remote");
	board->RegisterSender(*socket_event_reader);

	EventMonitor *monitor = ssi_create_id (EventMonitor, 0, "monitor");
	monitor->getOptions()->setPos(CONSOLE_WIDTH, 0, 600, CONSOLE_HEIGHT);
	board->RegisterListener(*monitor, socket_event_reader->getEventAddress(), 60000);

	board->Start();
	frame->Start();
	frame->Wait();
	frame->Stop();
	board->Stop();
	frame->Clear();
	board->Clear();

	return true;
}
Example #10
0
bool ex_qrs_hrv_event(void *args) {

	ITheFramework *frame = Factory::GetFramework();

	Decorator *decorator = ssi_create(Decorator, 0, true);
	frame->AddDecorator(decorator);

	ITheEventBoard *board = Factory::GetEventBoard();

	//raw
	FileReader *reader = ssi_create(FileReader, 0, true);
	reader->getOptions()->setPath("data/ecg");
	reader->getOptions()->block = 0.2;
	ITransformable *ecg_p = frame->AddProvider(reader, SSI_FILEREADER_PROVIDER_NAME);
	frame->AddSensor(reader);

	//bandpass
	Butfilt *ecg_band = ssi_create(Butfilt, 0, true);
	ecg_band->getOptions()->type = Butfilt::BAND;
	ecg_band->getOptions()->norm = false;
	ecg_band->getOptions()->high = 15;
	ecg_band->getOptions()->low = 5;
	ecg_band->getOptions()->order = 13;
	ITransformable *ecg_band_t = frame->AddTransformer(ecg_p, ecg_band, "0.75s");

	//diff
	Derivative *ecg_diff = ssi_create(Derivative, 0, true);
	ssi_strcpy(ecg_diff->getOptions()->names, "1st");
	ITransformable *ecg_diff_t = frame->AddTransformer(ecg_band_t, ecg_diff, "0.75s");

	//qrs-pre-process
	QRSPreProcess *ecg_QRSpre = ssi_create(QRSPreProcess, 0, true);
	ITransformable *ecg_QRSpre_t = frame->AddTransformer(ecg_diff_t, ecg_QRSpre, "0.75s");

	Butfilt *lowpass = ssi_create(Butfilt, 0, true);
	lowpass->getOptions()->zero = true;
	lowpass->getOptions()->norm = false;
	lowpass->getOptions()->low = 6.4;
	lowpass->getOptions()->order = 3;
	lowpass->getOptions()->type = Butfilt::LOW;
	ITransformable *ecg_QRSpre_low_t = frame->AddTransformer(ecg_QRSpre_t, lowpass, "0.75s");

	//qrs-detect
	QRSDetect *ecg_qrs = ssi_create(QRSDetect, 0, true);
	ecg_qrs->getOptions()->sendEvent = true;
	ITransformable *ecg_qrs_t = frame->AddTransformer(ecg_QRSpre_low_t, ecg_qrs, "0.75s");
	board->RegisterSender(*ecg_qrs);

	//visual
	SignalPainter *plot = 0;
	ssi_real_t p_size = 10.0f;
	//raw
	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("raw");
	plot->getOptions()->size = p_size;
	frame->AddConsumer(ecg_p, plot, "0.2s");
	//bandpass
	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("bandpass");
	plot->getOptions()->size = p_size;
	frame->AddConsumer(ecg_band_t, plot, "0.2s");
	//diff
	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("diff");
	plot->getOptions()->size = p_size;
	frame->AddConsumer(ecg_diff_t, plot, "0.2s");
	//qrs-pre
	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("qrs-pre");
	plot->getOptions()->size = p_size;
	frame->AddConsumer(ecg_QRSpre_low_t, plot, "0.2s");
	//qrs
	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("qrs");
	plot->getOptions()->size = p_size;
	frame->AddConsumer(ecg_qrs_t, plot, "0.2s");

	//events
	QRSHrvEventListener *hrv = ssi_create(QRSHrvEventListener, 0, true);
	hrv->getOptions()->span = 120000;
	hrv->getOptions()->update_ms = 5000;
	board->RegisterListener(*hrv, ecg_qrs->getEventAddress(), 10000);
	board->RegisterSender(*hrv);

	EventMonitor *monitor = ssi_create_id(EventMonitor, 0, "monitor");
	board->RegisterListener(*monitor, hrv->getEventAddress(), 10000);

	//framework

	decorator->add("console", 0, 0, 650, 800);
	decorator->add("plot*", 650, 0, 400, 400);
	decorator->add("monitor*", 650, 400, 400, 400);

	board->Start();
	frame->Start();
	frame->Wait();
	frame->Stop();
	board->Stop();
	frame->Clear();
	board->Clear();

	return true;
}
Example #11
0
bool ex_gsr_baseline_mean(void *args) {

	ITheFramework *frame = Factory::GetFramework();

	Decorator *decorator = ssi_create(Decorator, 0, true);
	frame->AddDecorator(decorator);

	ITheEventBoard *board = Factory::GetEventBoard();

	//raw
	FileReader *reader = ssi_create(FileReader, 0, true);
	reader->getOptions()->setPath("data/gsr");
	reader->getOptions()->block = 0.2;
	ITransformable *gsr_p = frame->AddProvider(reader, SSI_FILEREADER_PROVIDER_NAME);
	frame->AddSensor(reader);

	//lowpass
	Butfilt *lowpass = ssi_create(Butfilt, 0, true);
	lowpass->getOptions()->low = 0.01;
	lowpass->getOptions()->order = 3;
	lowpass->getOptions()->type = Butfilt::LOW;
	lowpass->getOptions()->zero = true;
	ITransformable *gsr_low_t = frame->AddTransformer(gsr_p, lowpass, "0.25s");

	//detrend
	GSRRemoveBaseline *detrend = ssi_create(GSRRemoveBaseline, 0, true);
	ITransformable *gsr_detrend_t = frame->AddTransformer(gsr_low_t, detrend, "0.25s");

	//norm
	MvgNorm *norm = ssi_create(MvgNorm, 0, true);
	norm->getOptions()->norm = MvgNorm::SUBMIN;
	norm->getOptions()->method = MvgNorm::SLIDING;
	norm->getOptions()->win = 15.0;
	ITransformable *gsr_detrend_norm_t = frame->AddTransformer(gsr_detrend_t, norm, "0.25s");

	GSRBaselineMean *mean = ssi_create(GSRBaselineMean, 0, true);
	mean->getOptions()->winsize = 15.0;
	frame->AddConsumer(gsr_detrend_norm_t, mean, "0.25s");
	board->RegisterSender(*mean);

	//visual
	SignalPainter *plot = 0;
	ssi_real_t p_size = 100.0f;

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("gsr(lowpassed)");
	plot->getOptions()->size = p_size;
	frame->AddConsumer(gsr_low_t, plot, "0.3s");

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("gsr(detrended)");
	plot->getOptions()->size = p_size;
	frame->AddConsumer(gsr_detrend_t, plot, "0.3s");

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("gsr(detrended & normed)");
	plot->getOptions()->size = p_size;
	frame->AddConsumer(gsr_detrend_norm_t, plot, "0.3s");

	//events
	EventMonitor *monitor = ssi_create_id(EventMonitor, 0, "monitor");
	board->RegisterListener(*monitor, mean->getEventAddress());

	//framework

	decorator->add("console", 0, 0, 650, 800);
	decorator->add("plot*", 650, 0, 400, 400);
	decorator->add("monitor*", 650, 400, 400, 400);

	board->Start();
	frame->Start();

	frame->Wait();
	frame->Stop();
	board->Stop();
	frame->Clear();
	board->Clear();

	return true;
}
Example #12
0
bool ex_gsr_peaks_online(void *args) {

	ITheEventBoard *board = Factory::GetEventBoard();
	ITheFramework *frame = Factory::GetFramework();

	Decorator *decorator = ssi_create(Decorator, 0, true);
	frame->AddDecorator(decorator);

	FileReader *reader = ssi_create(FileReader, 0, true);
	reader->getOptions()->setPath("data\\gsr");
	reader->getOptions()->block = 0.2;
	ITransformable *gsr_p = frame->AddProvider(reader, SSI_FILEREADER_PROVIDER_NAME);
	frame->AddSensor(reader);

	Butfilt *lowpass = ssi_create(Butfilt, 0, true);
	lowpass->getOptions()->low = 0.01;
	lowpass->getOptions()->order = 3;
	lowpass->getOptions()->type = Butfilt::LOW;
	lowpass->getOptions()->zero = true;
	ITransformable *gsr_low = frame->AddTransformer(gsr_p, lowpass, "0.2s");

	GSREventSender *gsr_event = ssi_create(GSREventSender, 0, true);
	gsr_event->getOptions()->tuple = true;
	gsr_event->setLogLevel(SSI_LOG_LEVEL_DEBUG);
	frame->AddConsumer(gsr_low, gsr_event, "4.0s");
	board->RegisterSender(*gsr_event);

	EventMonitor *monitor = ssi_create_id(EventMonitor, 0, "monitor");
	board->RegisterListener(*monitor, gsr_event->getEventAddress());

	SignalPainter *plot = 0;

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("gsr");
	plot->getOptions()->size = 150.0;
	frame->AddConsumer(gsr_p, plot, "0.2s");

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("gsr(lowpassed)");
	plot->getOptions()->size = 150.0;
	frame->AddConsumer(gsr_low, plot, "0.2s");

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("peak");
	plot->getOptions()->reset = true;
	frame->AddEventConsumer(gsr_low, plot, board, "peak@");

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("slope");
	plot->getOptions()->reset = true;
	frame->AddEventConsumer(gsr_low, plot, board, "slope@");

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("drop");
	plot->getOptions()->reset = true;
	frame->AddEventConsumer(gsr_low, plot, board, "drop@");

	decorator->add("console", 0, 0, 650, 800);
	decorator->add("plot*", 650, 0, 400, 400);
	decorator->add("monitor*", 650, 400, 400, 400);

	board->Start();
	frame->Start();
	frame->Wait();
	frame->Stop();
	board->Stop();
	frame->Clear();
	board->Clear();

	return true;
}
Example #13
0
bool ex_bvp_beat_events_raw(void *args) {

	ITheEventBoard *board = Factory::GetEventBoard();
	ITheFramework *frame = Factory::GetFramework();

	Decorator *decorator = ssi_create(Decorator, 0, true);
	frame->AddDecorator(decorator);

	FileReader *reader = ssi_create(FileReader, 0, true);
	reader->getOptions()->setPath("data\\bvp");
	reader->getOptions()->block = 0.2;
	reader->getOptions()->loop = false;

	ITransformable *bvp_p = frame->AddProvider(reader, SSI_FILEREADER_PROVIDER_NAME);
	frame->AddSensor(reader);

	SignalPainter *plot = 0;

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("bvp");
	plot->getOptions()->size = 10.0;
	frame->AddConsumer(bvp_p, plot, "1");

	BVPBeatEventSender *bvp_event = ssi_create(BVPBeatEventSender, 0, true);
	bvp_event->getOptions()->beep = true;
	bvp_event->getOptions()->mean_window = 1;
	bvp_event->getOptions()->tuple = true;

	bvp_event->setLogLevel(SSI_LOG_LEVEL_DEBUG);

	frame->AddConsumer(bvp_p, bvp_event, "0.2s");

	board->RegisterSender(*bvp_event);

	BVPBeatEventRawListener *event_listener = ssi_create(BVPBeatEventRawListener, 0, true);
	event_listener->getOptions()->sr = 9;

	ITransformable *heartRate = frame->AddProvider(event_listener, SSI_BVP_EVENTLISTENER_CHANNEL_HEART_RATE_PROVIDER_NAME);
	ITransformable *amp = frame->AddProvider(event_listener, SSI_BVP_EVENTLISTENER_CHANNEL_AMPLITUDE_PROVIDER_NAME);
	ITransformable *interBeat = frame->AddProvider(event_listener, SSI_BVP_EVENTLISTENER_CHANNEL_INTERBEAT_INTERVAL_PROVIDER_NAME);

	frame->AddSensor(event_listener);

	board->RegisterListener(*event_listener, bvp_event->getEventAddress());

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("heartRate");
	plot->getOptions()->size = 150.0;
	frame->AddConsumer(heartRate, plot, "1");

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("amp");
	plot->getOptions()->size = 150.0;
	frame->AddConsumer(amp, plot, "1");

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("interBeat");
	plot->getOptions()->size = 150.0;
	frame->AddConsumer(interBeat, plot, "1");

	EventMonitor *monitor = ssi_create_id(EventMonitor, 0, "monitor");
	board->RegisterListener(*monitor, bvp_event->getEventAddress());

	decorator->add("console", 0, 0, 650, 800);
	decorator->add("plot*", 650, 0, 400, 400);
	decorator->add("monitor*", 650, 400, 400, 400);

	board->Start();
	frame->Start();
	frame->Wait();
	frame->Stop();
	board->Stop();
	frame->Clear();
	board->Clear();

	return true;
}
Example #14
0
bool ex_gsr_response_amplitude_events(void *args) {

	ITheEventBoard *board = Factory::GetEventBoard();
	ITheFramework *frame = Factory::GetFramework();

	Decorator *decorator = ssi_create(Decorator, 0, true);
	frame->AddDecorator(decorator);

	FileReader *reader = ssi_create(FileReader, 0, true);
	reader->getOptions()->setPath("data\\gsr");
	reader->getOptions()->block = 0.2;
	reader->getOptions()->loop = false;

	ITransformable *gsr_p = frame->AddProvider(reader, SSI_FILEREADER_PROVIDER_NAME);
	frame->AddSensor(reader);

	SignalPainter *plot = 0;

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("gsr(lowpassed)");
	plot->getOptions()->size = 150.0;
	frame->AddConsumer(gsr_p, plot, "1");

	GSRResponseEventSender *gsr_event = ssi_create(GSRResponseEventSender, 0, true);
	gsr_event->getOptions()->tuple = true;
	gsr_event->getOptions()->minRisingTime = 0;
	gsr_event->getOptions()->minAllowedRegression = 0.1f;
	gsr_event->getOptions()->minAmplitude = 0.5f;
	gsr_event->getOptions()->print = false;

	gsr_event->setLogLevel(SSI_LOG_LEVEL_DEBUG);

	frame->AddConsumer(gsr_p, gsr_event, "0.2s");

	board->RegisterSender(*gsr_event);

	GSREventListener *event_listener = ssi_create(GSREventListener, 0, true);
	event_listener->getOptions()->statisticalFn = GSR_SUM;
	event_listener->getOptions()->window = SSI_GSR_EVENTLISTENER_NO_WINDOW;

	ITransformable *nr_of_responses = frame->AddProvider(event_listener, SSI_GSR_EVENTLISTENER_NUMBER_OF_RESPONSES_PROVIDER_NAME);
	ITransformable *amp = frame->AddProvider(event_listener, SSI_GSR_EVENTLISTENER_AMPLITUDE_PROVIDER_NAME);
	ITransformable *power = frame->AddProvider(event_listener, SSI_GSR_EVENTLISTENER_POWER_PROVIDER_NAME);

	frame->AddSensor(event_listener);

	board->RegisterListener(*event_listener, gsr_event->getEventAddress());

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("nr_of_responses");
	plot->getOptions()->size = 150.0;
	frame->AddConsumer(nr_of_responses, plot, "1");

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("amp");
	plot->getOptions()->size = 150.0;
	frame->AddConsumer(amp, plot, "1");

	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("power");
	plot->getOptions()->size = 150.0;
	frame->AddConsumer(power, plot, "1");

	EventMonitor *monitor = ssi_create_id(EventMonitor, 0, "monitor");
	board->RegisterListener(*monitor, gsr_event->getEventAddress());

	decorator->add("console", 0, 0, 650, 800);
	decorator->add("plot*", 650, 0, 400, 400);
	decorator->add("monitor*", 650, 400, 400, 400);

	board->Start();
	frame->Start();
	frame->Wait();
	frame->Stop();
	board->Stop();
	frame->Clear();
	board->Clear();

	return true;

}
Example #15
0
bool ex_qrs_heartrate_mean(void *args) {

	if (!ssi_exists("data/ecg_qrs.stream")) {
		ex_ecg_detection(args);
	}

	ITheFramework *frame = Factory::GetFramework();

	Decorator *decorator = ssi_create(Decorator, 0, true);
	frame->AddDecorator(decorator);

	ITheEventBoard *board = Factory::GetEventBoard();

	//raw
	FileReader *reader = ssi_create(FileReader, 0, true);
	reader->getOptions()->setPath("data/ecg_qrs");
	reader->getOptions()->block = 0.2;
	ITransformable *qrs_p = frame->AddProvider(reader, SSI_FILEREADER_PROVIDER_NAME);
	frame->AddSensor(reader);

	// heart rate
	QRSHeartRate *qrshr = ssi_create(QRSHeartRate, 0, true);
	ITransformable *ecg_hr_t = frame->AddTransformer(qrs_p, qrshr, "0.25s");

	//heart rate mean
	QRSHeartRateMean *qrshr_mean = ssi_create(QRSHeartRateMean, 0, true);
	qrshr_mean->getOptions()->winsize = 15.0;
	frame->AddConsumer(ecg_hr_t, qrshr_mean, "0.25s");
	board->RegisterSender(*qrshr_mean);

	//visual
	SignalPainter *plot = 0;
	ssi_real_t p_size = 100.0f;

	//qrs
	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("qrs");
	plot->getOptions()->size = p_size;
	frame->AddConsumer(qrs_p, plot, "0.3s");

	//heart rate
	plot = ssi_create_id(SignalPainter, 0, "plot");
	plot->getOptions()->setTitle("heartrate");
	plot->getOptions()->size = p_size;
	frame->AddConsumer(ecg_hr_t, plot, "0.3s");

	//events
	EventMonitor *monitor = ssi_create_id(EventMonitor, 0, "monitor");
	board->RegisterListener(*monitor, qrshr_mean->getEventAddress());

	//framework

	decorator->add("console", 0, 0, 650, 800);
	decorator->add("plot*", 650, 0, 400, 400);
	decorator->add("monitor*", 650, 400, 400, 400);

	board->Start();
	frame->Start();

	frame->Wait();
	frame->Stop();
	board->Stop();
	frame->Clear();
	board->Clear();

	return true;
}
Example #16
0
void ex_laughter () {

	ITheFramework *frame = Factory::GetFramework ();

	Decorator *decorator = ssi_create (Decorator, 0, true);
	frame->AddDecorator(decorator);

	ITheEventBoard *board = Factory::GetEventBoard ();
	
#ifndef SIMULATE
	Audio *audio = ssi_create (Audio, "audio", true);
	audio->getOptions()->scale = true;
	audio->getOptions()->sr = 48000;
	ITransformable *audio_p = frame->AddProvider(audio, SSI_AUDIO_PROVIDER_NAME);
	frame->AddSensor(audio);
#else
	WavReader *audio = ssi_create (WavReader, 0, true);
	audio->getOptions()->setPath("audio.wav");
	audio->getOptions()->scale = true;
	audio->getOptions()->block = 0.01;
	ITransformable *audio_p = frame->AddProvider(audio, SSI_WAVREADER_PROVIDER_NAME);
	frame->AddSensor(audio);
#endif

	SNRatio *laughter_vad = ssi_create (SNRatio, 0, true);
	ITransformable *laughter_vad_t = frame->AddTransformer(audio_p, laughter_vad, "0.2s");

	LaughterPreProcessor *laughter_pre = ssi_create (LaughterPreProcessor, 0, true);
	ITransformable *laughter_pre_t = frame->AddTransformer(audio_p, laughter_pre, "0.01s", "0.01s");

	LaughterFeatureExtractor *laughter_extract = ssi_create (LaughterFeatureExtractor, 0, true);
	Classifier *laughter_classifier = ssi_create (Classifier, 0, true);
	laughter_classifier->getOptions()->setTrainer("laughter");
	board->RegisterSender(*laughter_classifier);

	frame->AddConsumer(laughter_pre_t, laughter_classifier, "0.5s", "0.5s", laughter_extract, laughter_vad_t);

	SignalPainter *plot = ssi_create_id (SignalPainter, 0, "plot");
	plot->getOptions()->type = PaintSignalType::AUDIO;
	plot->getOptions()->size = 10.0;
	frame->AddConsumer(audio_p, plot, "0.01s");

	EventMonitor *monitor = ssi_create_id (EventMonitor, 0, "monitor");
	board->RegisterListener(*monitor, laughter_classifier->getEventAddress(), 10000);	

#ifdef SIMULATE
	AudioPlayer *player = ssi_create (AudioPlayer, "player", true);	
	frame->AddConsumer(audio_p, player, "0.01s");
#endif

	decorator->add("console", 0, 0, 650, 800);
	decorator->add("plot*", 650, 0, 400, 400);
	decorator->add("monitor*", 650, 400, 400, 400);

	board->Start();
	frame->Start();
	frame->Wait();
	frame->Stop();
	board->Stop();
	frame->Clear();
	board->Clear();

}