import pylsl
import time

# on my M3 MacBook I had to recompile the LSL library and then this is needed
# export DYLD_LIBRARY_PATH=/Users/roboos/matlab/liblsl-maca64/bin

time.sleep(3)  # wait a bit to make sure the LSL library is ready

# first resolve a marker stream on the lab network
print("looking for a marker stream...")
streams = pylsl.resolve_byprop('type', 'Markers')
print(streams)

inlets = []
if len(streams)==0:
    print("there are no marker streams")
else:
    for stream in streams:
        print(stream)
        # create a new inlet to read from the stream
        inlets.append(pylsl.StreamInlet(stream))

while True:
    for stream, inlet in zip(streams,inlets):
        sample, timestamp = inlet.pull_sample()
        print(f"received {sample[0]} from {stream.name()} on {stream.hostname()}")



