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

info = pylsl.StreamInfo(
    name='My EEG Stream',
    type='EEG',
    channel_count=4,
    nominal_srate=1000.0,
    channel_format=pylsl.cf_float32,
    source_id=None,
)

# Create a new outlet
outlet = pylsl.StreamOutlet(info)

# Print the stream info
print("Now publishing stream:", info.name(), info.type(), info.channel_count(), "channels at", info.nominal_srate(), "Hz")

# Create a sample data array
sample = [0.0] * chans
# Continuously send data

while True:
    # Fill the sample with random data
    for i in range(chans):
        sample[i] = i * 0.1  # Replace with actual data acquisition logic
    # Push the sample to the outlet
    outlet.push_sample(sample)
    # Print the sample for debugging
    print("Pushed sample:", sample)
    # Sleep for a short duration to simulate real-time data acquisition
    time.sleep(0.1)  # Adjust the sleep duration as needed

