Skip to content

Commit 006c6c6

Browse files
committed
Create subprojects for examples, add to solution
1 parent d358b71 commit 006c6c6

23 files changed

Lines changed: 362 additions & 0 deletions

Directory.Build.props

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project>
2+
<PropertyGroup>
3+
<Authors>Christian Kothe</Authors>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
<Version>1.1.2</Version>
6+
</PropertyGroup>
7+
</Project>
8+
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using System;
2+
using System.Threading;
3+
using LSL;
4+
5+
6+
{
7+
class Program
8+
{
9+
static void Main(string[] args)
10+
{
11+
// create a new StreamInfo and declare some meta-data (in accordance with XDF format)
12+
liblsl.StreamInfo info = new liblsl.StreamInfo("MetaTester","EEG",8,100,liblsl.channel_format_t.cf_float32,"myuid323457");
13+
liblsl.XMLElement chns = info.desc().append_child("channels");
14+
String[] labels = {"C3","C4","Cz","FPz","POz","CPz","O1","O2"};
15+
for (int k=0;k<labels.Length;k++)
16+
chns.append_child("channel")
17+
.append_child_value("label", labels[k])
18+
.append_child_value("unit", "microvolts")
19+
.append_child_value("type","EEG");
20+
info.desc().append_child_value("manufacturer","SCCN");
21+
info.desc().append_child("cap")
22+
.append_child_value("name","EasyCap")
23+
.append_child_value("size","54")
24+
.append_child_value("labelscheme","10-20");
25+
26+
// create outlet for the stream
27+
liblsl.StreamOutlet outlet = new liblsl.StreamOutlet(info);
28+
29+
// === the following could run on another computer ===
30+
31+
// resolve the stream and open an inlet
32+
liblsl.StreamInfo[] results = liblsl.resolve_stream("name","MetaTester");
33+
liblsl.StreamInlet inlet = new liblsl.StreamInlet(results[0]);
34+
// get the full stream info (including custom meta-data) and dissect it
35+
liblsl.StreamInfo inf = inlet.info();
36+
Console.WriteLine("The stream's XML meta-data is: ");
37+
Console.WriteLine(inf.as_xml());
38+
Console.WriteLine("The manufacturer is: " + inf.desc().child_value("manufacturer"));
39+
Console.WriteLine("The cap circumference is: " + inf.desc().child("cap").child_value("size"));
40+
Console.WriteLine("The channel labels are as follows:");
41+
liblsl.XMLElement ch = inf.desc().child("channels").child("channel");
42+
for (int k=0;k<info.channel_count();k++) {
43+
Console.WriteLine(" " + ch.child_value("label"));
44+
ch = ch.next_sibling();
45+
}
46+
Console.ReadKey();
47+
}
48+
}
49+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Project Sdk="Microsoft.NET.Sdk"><ItemGroup>
2+
<ProjectReference Include="..\..\liblsl.csproj" />
3+
</ItemGroup><PropertyGroup><Product>HandleMetaData</Product></PropertyGroup></Project>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System;
2+
using System.Threading;
3+
using LSL;
4+
5+
6+
{
7+
class Program
8+
{
9+
static void Main(string[] args)
10+
{
11+
// wait until an EEG stream shows up
12+
liblsl.StreamInfo[] results = liblsl.resolve_stream("type", "EEG");
13+
14+
// open an inlet and print some interesting info about the stream (meta-data, etc.)
15+
liblsl.StreamInlet inlet = new liblsl.StreamInlet(results[0]);
16+
System.Console.Write(inlet.info().as_xml());
17+
18+
// read samples
19+
float[] sample = new float[8];
20+
while (true)
21+
{
22+
inlet.pull_sample(sample);
23+
foreach (float f in sample)
24+
System.Console.Write("\t{0}",f);
25+
System.Console.WriteLine();
26+
}
27+
28+
System.Console.ReadKey();
29+
}
30+
}
31+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Project Sdk="Microsoft.NET.Sdk"><ItemGroup>
2+
<ProjectReference Include="..\..\liblsl.csproj" />
3+
</ItemGroup><PropertyGroup><Product>ReceiveData</Product></PropertyGroup></Project>
File renamed without changes.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
using System.Threading;
3+
using LSL;
4+
5+
6+
{
7+
class Program
8+
{
9+
static void Main(string[] args)
10+
{
11+
// wait until an EEG stream shows up
12+
liblsl.StreamInfo[] results = liblsl.resolve_stream("type", "EEG");
13+
14+
// open an inlet and print meta-data
15+
liblsl.StreamInlet inlet = new liblsl.StreamInlet(results[0]);
16+
System.Console.Write(inlet.info().as_xml());
17+
18+
// read samples
19+
float[,] buffer = new float[512, 8];
20+
double[] timestamps = new double[512];
21+
while (true)
22+
{
23+
int num = inlet.pull_chunk(buffer,timestamps);
24+
for (int s = 0; s < num; s++)
25+
{
26+
for (int c = 0; c < 8; c++)
27+
Console.Write("\t{0}", buffer[s, c]);
28+
Console.WriteLine();
29+
}
30+
}
31+
}
32+
}
33+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Project Sdk="Microsoft.NET.Sdk"><ItemGroup>
2+
<ProjectReference Include="..\..\liblsl.csproj" />
3+
</ItemGroup><PropertyGroup><Product>ReceiveDataInChunks</Product></PropertyGroup></Project>

0 commit comments

Comments
 (0)