void Start()
        {
            var channelDefinitions = SetupChannels();

            dataRate = LSLUtils.GetSamplingRateFor(sampling);

            channelCount = channelDefinitions.Count;

            // initialize the array once
            currentSample = new float[channelCount];

            streamInfo = new liblsl.StreamInfo(StreamName, StreamType, channelCount, dataRate, liblsl.channel_format_t.cf_float32, unique_source_id);

            // it's not possible to create a XMLElement before and append it.
            liblsl.XMLElement chns = streamInfo.desc().append_child("channels");
            // so this workaround has been introduced.
            foreach (var def in channelDefinitions)
            {
                chns.append_child("channel")
                .append_child_value("label", def.label)
                .append_child_value("unit", def.unit)
                .append_child_value("type", def.type);
            }

            outlet = new liblsl.StreamOutlet(streamInfo);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            // Check for command line arguments
            if (args.Length > 0)
            {
                hrDeviceName = args[0];
                // To print the command line
                // arguments using foreach loop
                foreach (Object obj in args)
                {
                    Console.WriteLine("Attempting to connect to " + obj);
                }
            }

            // create LSL stream info and outlet
            info = new liblsl.StreamInfo("Polar", "HRV", 2, 10);

            // add descriptions of
            liblsl.XMLElement chns = info.desc().append_child("channels");
            chns.append_child("hr");
            chns.append_child("rr");

            //chns.append_child("channel")
            //    .append_child_value("label", "hr")
            //    .append_child_value("unit", "bpm")
            //    .append_child_value("type", "HR");

            //chns.append_child("channel")
            //    .append_child_value("label", "rr")
            //    .append_child_value("unit", "ms")
            //    .append_child_value("type", "HR");

            outlet = new liblsl.StreamOutlet(info);

            // Run main loop
            MainAsync(args).Wait();

            Console.ReadLine();

            // Return exit code to the shell
            // For scripting/batch processing, it's an ERRORLEVEL cmd.exe shell variable
            Environment.Exit(_exitCode);
        }
Exemple #3
0
 // Start is called before the first frame update
 void Start()
 {
     liblsl.StreamInfo streamInfo = new liblsl.StreamInfo(StreamName, StreamType, 7, 72, liblsl.channel_format_t.cf_float32);
     liblsl.XMLElement chans      = streamInfo.desc().append_child("channels");
     chans.append_child("channel").append_child_value("label", "PosX");
     chans.append_child("channel").append_child_value("label", "PosY");
     chans.append_child("channel").append_child_value("label", "PosZ");
     chans.append_child("channel").append_child_value("label", "RotW");
     chans.append_child("channel").append_child_value("label", "RotX");
     chans.append_child("channel").append_child_value("label", "RotY");
     chans.append_child("channel").append_child_value("label", "RotZ");
     outlet        = new liblsl.StreamOutlet(streamInfo);
     currentSample = new float[7];
 }
        /// <summary>
        /// Setup LSL outlet for the board
        /// </summary>
        void SetupLslOutletForBoard()
        {
            var numChannels       = BrainhatBoardShim.GetNumberOfExgChannels(BoardId);
            var numAccelChannels  = BrainhatBoardShim.GetNumberOfAccelChannels(BoardId);
            var numOtherChannels  = BrainhatBoardShim.GetNumberOfOtherChannels(BoardId);
            var numAnalogChannels = BrainhatBoardShim.GetNumberOfAnalogChannels(BoardId);

            SampleSize = 2 + numChannels + numAccelChannels + numOtherChannels + numAnalogChannels;

            StreamInfo = new liblsl.StreamInfo(BoardId.GetSampleName(), "BFSample", SampleSize, SampleRate, liblsl.channel_format_t.cf_double64, BrainHatNetwork.NetworkUtilities.GetHostName());

            StreamInfo.desc().append_child_value("manufacturer", "OpenBCI");
            StreamInfo.desc().append_child_value("boardId", $"{BoardId}");
            liblsl.XMLElement chns = StreamInfo.desc().append_child("channels");

            chns.append_child("channel")
            .append_child_value("label", "SampleIndex")
            .append_child_value("unit", "0-255")
            .append_child_value("type", "index");

            for (int k = 0; k < numChannels; k++)
            {
                chns.append_child("channel")
                .append_child_value("label", $"ExgCh{k}")
                .append_child_value("unit", "uV")
                .append_child_value("type", "EEG");
            }

            for (int k = 0; k < numAccelChannels; k++)
            {
                chns.append_child("channel")
                .append_child_value("label", $"AcelCh{k}")
                .append_child_value("unit", "1.0")
                .append_child_value("type", "Accelerometer");
            }

            for (int k = 0; k < numOtherChannels; k++)
            {
                chns.append_child("channel")
                .append_child_value("label", $"Other{k}");
            }

            for (int k = 0; k < numAnalogChannels; k++)
            {
                chns.append_child("channel")
                .append_child_value("label", $"AngCh{k}");
            }

            chns.append_child("channel")
            .append_child_value("label", "TimeStamp")
            .append_child_value("unit", "s");
        }
        static void Main(string[] args)
        {
            // create a new StreamInfo and declare some meta-data (in accordance with XDF format)
            liblsl.StreamInfo info   = new liblsl.StreamInfo("MetaTester", "EEG", 8, 100, liblsl.channel_format_t.cf_float32, "myuid323457");
            liblsl.XMLElement chns   = info.desc().append_child("channels");
            String[]          labels = { "C3", "C4", "Cz", "FPz", "POz", "CPz", "O1", "O2" };
            for (int k = 0; k < labels.Length; k++)
            {
                chns.append_child("channel")
                .append_child_value("label", labels[k])
                .append_child_value("unit", "microvolts")
                .append_child_value("type", "EEG");
            }
            info.desc().append_child_value("manufacturer", "SCCN");
            info.desc().append_child("cap")
            .append_child_value("name", "EasyCap")
            .append_child_value("size", "54")
            .append_child_value("labelscheme", "10-20");

            // create outlet for the stream
            liblsl.StreamOutlet outlet = new liblsl.StreamOutlet(info);

            // === the following could run on another computer ===

            // resolve the stream and open an inlet
            liblsl.StreamInfo[] results = liblsl.resolve_stream("name", "MetaTester");
            liblsl.StreamInlet  inlet   = new liblsl.StreamInlet(results[0]);
            // get the full stream info (including custom meta-data) and dissect it
            liblsl.StreamInfo inf = inlet.info();
            Console.WriteLine("The stream's XML meta-data is: ");
            Console.WriteLine(inf.as_xml());
            Console.WriteLine("The manufacturer is: " + inf.desc().child_value("manufacturer"));
            Console.WriteLine("The cap circumference is: " + inf.desc().child("cap").child_value("size"));
            Console.WriteLine("The channel labels are as follows:");
            liblsl.XMLElement ch = inf.desc().child("channels").child("channel");
            for (int k = 0; k < info.channel_count(); k++)
            {
                Console.WriteLine("  " + ch.child_value("label"));
                ch = ch.next_sibling();
            }
            Console.ReadKey();
        }
        void Awake()
        {
            UnityEngine.Debug.Log("LSLMarkerStream");

            sample = new double[lslChannelCount];

            lslStreamInfo = new liblsl.StreamInfo(
                lslStreamName,
                lslStreamType,
                lslChannelCount,
                nominal_srate,
                lslChannelFormat,
                unique_source_id);
            lslStreamInfo.desc().append_child_value("manufacturer", "UnityLSL");
            liblsl.XMLElement chns     = lslStreamInfo.desc().append_child("channels");
            string[]          channels = { "MarkerTime", "MarkerValue", "CurrentTime" };
            foreach (string chanName in channels)
            {
                chns.append_child("channel").append_child_value("label", chanName).append_child_value("type", "Marker");
            }

            lslOutlet = new liblsl.StreamOutlet(lslStreamInfo);
        }
    // Use this for initialization
    void Start()
    {
        head = GameObject.Find("Camera (eye)");

        if (head != null)
        {
            // initialize the array once
            currentSample = new float[ChannelCount];

            //dataRate = LSLUtils.GetSamplingRateFor(sampling);

            streamInfo = new liblsl.StreamInfo(StreamName, StreamType, ChannelCount, dataRate, liblsl.channel_format_t.cf_float32, uid);

            //setup LSL stream metadata (code from vizard)
            //streamInfo.desc().append_child("synchronization").append_child_value("can_drop_samples", "true");
            var setup = streamInfo.desc().append_child("setup");
            setup.append_child_value("name", StreamName);
            // channels with position and orientation in quaternions
            objs = setup.append_child("objects");
            obj  = objs.append_child("object");
            obj.append_child_value("label", StreamName);
            obj.append_child_value("id", StreamName);
            obj.append_child_value("type", "Mocap");

            channels = streamInfo.desc().append_child("channels");
            chan     = channels.append_child("channel");
            chan.append_child_value("label", StreamName + "_X");
            chan.append_child_value("object", StreamName);
            chan.append_child_value("type", "PositionX");
            chan.append_child_value("unit", "meters");

            chan = channels.append_child("channel");
            chan.append_child_value("label", StreamName + "_Y");
            chan.append_child_value("object", StreamName);
            chan.append_child_value("type", "PositionY");
            chan.append_child_value("unit", "meters");

            chan = channels.append_child("channel");
            chan.append_child_value("label", StreamName + "_Z");
            chan.append_child_value("object", StreamName);
            chan.append_child_value("type", "PositionZ");
            chan.append_child_value("unit", "meters");

            chan = channels.append_child("channel");
            chan.append_child_value("label", StreamName + "_quat_X");
            chan.append_child_value("object", StreamName);
            chan.append_child_value("type", "OrientationX");
            chan.append_child_value("unit", "quaternion");

            chan = channels.append_child("channel");
            chan.append_child_value("label", StreamName + "_quat_Y");
            chan.append_child_value("object", StreamName);
            chan.append_child_value("type", "OrientationY");
            chan.append_child_value("unit", "quaternion");

            chan = channels.append_child("channel");
            chan.append_child_value("label", StreamName + "_quat_Z");
            chan.append_child_value("object", StreamName);
            chan.append_child_value("type", "OrientationZ");
            chan.append_child_value("unit", "quaternion");

            chan = channels.append_child("channel");
            chan.append_child_value("label", StreamName + "_quat_W");
            chan.append_child_value("object", StreamName);
            chan.append_child_value("type", "OrientationW");
            chan.append_child_value("unit", "quaternion");

            outlet = new liblsl.StreamOutlet(streamInfo);
        }
    }
 // Start is called before the first frame update
 void Start()
 {
     liblsl.StreamInfo streamInfo = new liblsl.StreamInfo(StreamName, StreamType, 12, 1 / Time.fixedDeltaTime, liblsl.channel_format_t.cf_float32, StreamId);
     liblsl.XMLElement chans      = streamInfo.desc().append_child("channels");
     chans.append_child("channel").append_child_value("label", "Timestamp");
     chans.append_child("channel").append_child_value("label", "ConvergenceDistance");
     chans.append_child("channel").append_child_value("label", "ConvergenceDistanceIsValid");
     chans.append_child("channel").append_child_value("label", "GazeRayOriginX");
     chans.append_child("channel").append_child_value("label", "GazeRayOriginY");
     chans.append_child("channel").append_child_value("label", "GazeRayOriginZ");
     chans.append_child("channel").append_child_value("label", "GazeRayDirectionX");
     chans.append_child("channel").append_child_value("label", "GazeRayDirectionY");
     chans.append_child("channel").append_child_value("label", "GazeRayDirectionZ");
     chans.append_child("channel").append_child_value("label", "GazeRayIsValid");
     chans.append_child("channel").append_child_value("label", "IsLeftEyeBlinking");
     chans.append_child("channel").append_child_value("label", "IsRightEyeBlinking");
     outlet        = new liblsl.StreamOutlet(streamInfo);
     currentSample = new float[12];
 }