int main(int argc, char* argv[]) { lsl_streaminfo info; /* out stream declaration object */ lsl_outlet outlet; /* stream outlet */ double endtime; /* used for send timing */ char *mrk; /* marker to send next */ /* declare a new streaminfo (name: "MyEventStream", content type: "Markers", 1 channel, irregular rate, ... */ /* ... string values, some made-up source id (can also be empty) */ info = lsl_create_streaminfo("MyEventStream","Markers",1,LSL_IRREGULAR_RATE,cft_string,"myuniquesourceid23443"); /* make a new outlet (chunking: default, buffering: 360k markers) */ outlet = lsl_create_outlet(info,0,360); /* send random marker streams (note: this loop is keeping the CPU busy, normally one would sleep or yield here) */ printf("Now sending markers...\n"); while(1) { /* wait for a random period of time */ endtime = ((double)clock())/CLOCKS_PER_SEC + (rand()%1000)/1000.0; while (((double)clock())/CLOCKS_PER_SEC < endtime); /* and choose the marker to send */ mrk = markertypes[rand() % (sizeof(markertypes)/sizeof(markertypes[0]))]; printf("now sending: %s\n",mrk); /* now send it (note the &, since this function takes an array of char*) */ lsl_push_sample_str(outlet,&mrk); } /* we never get here, buy anyway */ lsl_destroy_outlet(outlet); return 0; }
void __fastcall TMainCaptureForm::BitBtnPlayClick(TObject *Sender) { if(outlet) { lsl_destroy_outlet(outlet); outlet = NULL; } double requestedFrameRate = edtRequestedFrameRate->Text.ToDouble(); lsl_streaminfo info = lsl_create_streaminfo("VideoStream_0","VideoStream_0",1,requestedFrameRate,cft_int32,""); lsl_xml_ptr desc = lsl_get_desc(info); lsl_xml_ptr chn = lsl_append_child(desc, "channels"); lsl_append_child_value(chn, "name","frame"); lsl_append_child_value(chn,"unit","number"); lsl_xml_ptr sync = lsl_append_child(desc, "synchronization"); lsl_append_child_value(sync, "can_drop_samples", "true"); outlet = lsl_create_outlet(info,0,360); cbVideoInputDevice->Enabled = false; cbVideoInput->Enabled = false; cbVideoInputFormat->Enabled = false; SpatialDivisorEdit->Enabled = false; cbRecord->Enabled =false; Start(CaptureWorkerForm, edOutput0->Text, bmpQueue, hMutex, outlet, requestedFrameRate); frameThread = new TFrameThread(this, bmpQueue, hMutex, false); BitBtnStop->Enabled=true; BitBtnPlay->Enabled=false; edtFrameRate->Text = FormatFloat ("0.00", CaptureWorkerForm->VideoGrabber->CurrentFrameRate); double ratio = requestedFrameRate/CaptureWorkerForm->VideoGrabber->CurrentFrameRate; if(ratio > 1.02 || ratio < .98) { edtFrameRate->Text = FormatFloat ("0.00", CaptureWorkerForm->VideoGrabber->CurrentFrameRate); Application->MessageBoxA(L"Camera 0 unable to display requested frame rate.", L"Error", MB_OK); btStopClick(this); return; } }
int _tmainxx(int argc, _TCHAR* argv[]) { int nChannels = 9; // char *channels[] = {"C3","C4","Cz","FPz","POz","CPz","O1","O2"}; int t,c; /* time point and channel index */ lsl_streaminfo info; /* out stream declaration object */ lsl_xml_ptr desc, chn; /* some xml element pointers */ lsl_outlet outlet; /* stream outlet */ double starttime; /* used for send timing */ float cursample[9]; /* the current sample */ /* declare a new streaminfo (8 channels, 100 Hz, float-formatted, some pseudo device id */ info = lsl_create_streaminfo("BioSemi","EEG",nChannels,100,cft_float32,"325wqer4354"); /* add some meta-data fields to it */ desc = lsl_get_desc(info); lsl_append_child_value(desc,"manufacturer","BioSemi"); /* for (c=0;c<8;c++) { chn = lsl_append_child(desc,"channels"); lsl_append_child_value(chn,"name",channels[c]); lsl_append_child_value(chn,"unit","microvolts"); lsl_append_child_value(chn,"type","EEG"); } */ /* make a new outlet */ outlet = lsl_create_outlet(info,0,360); /* send data forever */ printf("Now sending data...\n"); starttime = ((double)clock())/CLOCKS_PER_SEC; for(t=0;;t++) { for (c=0;c<nChannels;c++) cursample[c] = (float)((rand()%1500)/500.0-1.5); lsl_push_sample_f(outlet,cursample); while (((double)clock())/CLOCKS_PER_SEC < starttime + t*0.01); } /* we never get here, buy anyway */ lsl_destroy_outlet(outlet); return 0; }
int main(int argc, char* argv[]) { int t,c; /* time point and channel index */ lsl_streaminfo info; /* out stream declaration object */ lsl_xml_ptr desc, chn, chns;/* some xml element pointers */ lsl_outlet outlet; /* stream outlet */ double starttime; /* used for send timing */ float cursample[8]; /* the current sample */ /* declare a new streaminfo (name: BioSemi, content type: EEG, 8 channels, 100 Hz, float values, some made-up device id (can also be empty) */ info = lsl_create_streaminfo("BioSemi","EEG",8,100,cft_float32,"325wqer4354"); /* add some meta-data fields to it */ /* (for more standard fields, see https://github.com/sccn/xdf/wiki/Meta-Data) */ desc = lsl_get_desc(info); lsl_append_child_value(desc,"manufacturer","BioSemi"); chns = lsl_append_child(desc,"channels"); for (c=0;c<8;c++) { chn = lsl_append_child(chns,"channel"); lsl_append_child_value(chn,"label",channels[c]); lsl_append_child_value(chn,"unit","microvolts"); lsl_append_child_value(chn,"type","EEG"); } /* make a new outlet (chunking: default, buffering: 360 seconds) */ outlet = lsl_create_outlet(info,0,360); /* send data forever (note: this loop is keeping the CPU busy, normally one would sleep or yield here) */ printf("Now sending data...\n"); starttime = ((double)clock())/CLOCKS_PER_SEC; for(t=0;;t++) { for (c=0;c<8;c++) cursample[c] = (float)((rand()%1500)/500.0-1.5); lsl_push_sample_f(outlet,cursample); while (((double)clock())/CLOCKS_PER_SEC < starttime + t*0.01); } /* we never get here, buy anyway */ lsl_destroy_outlet(outlet); return 0; }
int _tmain(int argc, _TCHAR* argv[]) { int nChannels = 40; int nMarkers = nChannels/4; double samplesPerSec = 440; char *channels[40]; int t,c,m; /* time point and channel index */ lsl_streaminfo info; /* out stream declaration object */ lsl_xml_ptr desc, chn, chns; /* some xml element pointers */ lsl_outlet outlet; /* stream outlet */ double starttime; /* used for send timing */ float cursample[40]; /* the current sample */ char chanName[256]; /* declare a new streaminfo (8 channels, 100 Hz, float-formatted, some pseudo device id */ info = lsl_create_streaminfo("PhaseSpace","Mocap",nChannels,samplesPerSec,cft_float32,"76sfsfdsdfa67"); /* add some meta-data fields to it */ desc = lsl_get_desc(info); lsl_append_child_value(desc,"manufacturer","Phasespace"); chns = lsl_append_child(desc,"channels"); for (c=0;c<nMarkers;c++) { chn = lsl_append_child(chns,"channel"); sprintf(chanName, "Marker%d_X", c); lsl_append_child_value(chn, "label", chanName); lsl_append_child_value(chn,"type","PositionX"); lsl_append_child_value(chn,"unit","meters"); chn = lsl_append_child(chns,"channel"); sprintf(chanName, "Marker%d_Y", c); lsl_append_child_value(chn, "label", chanName); lsl_append_child_value(chn,"type","PositionY"); lsl_append_child_value(chn,"unit","meters"); chn = lsl_append_child(chns,"channel"); sprintf(chanName, "Marker%d_Z", c); lsl_append_child_value(chn, "label", chanName); lsl_append_child_value(chn,"type","PositionY"); lsl_append_child_value(chn,"unit","meters"); } /* make a new outlet */ outlet = lsl_create_outlet(info,0,360); /* send data forever */ printf("Now sending data...\n"); starttime = ((double)clock())/CLOCKS_PER_SEC; float x = 0; float y = 0; float z = 0; for(t=0;;t++) { for(m=0, c=0; m<nMarkers; m++) { x++; if(t%3 == 0) y++; if(t%5 == 0) z++; cursample[c++] = sin(degToRad((x-360*m)/10.0))*.1; cursample[c++] = sin(degToRad((y-360*m)/10.0))*.1; cursample[c++] = sin(degToRad((z-360*m)/10.0))*.1; cursample[c++] = (float)((rand()%1500)/500.0-1.5)*.001; } lsl_push_sample_f(outlet,cursample); while (((double)clock())/CLOCKS_PER_SEC < starttime + t/samplesPerSec) { Sleep(1); } // printf("here %d\n", t); } /* we never get here, but anyway */ lsl_destroy_outlet(outlet); return 0; }