bsl.StreamPlayer

class bsl.StreamPlayer(stream_name, fif_file, repeat=inf, trigger_def=None, chunk_size=16, high_resolution=False)[source]

Class for playing a recorded file on LSL network in another process.

Parameters:
stream_namestr

Stream’s server name, displayed on LSL network.

fif_filefile-like

Path to the compatible raw .fif file to play.

repeatint | float('inf')

Number of times the stream player will loop on the FIF file before interrupting. Default float('inf') can be passed to never interrupt streaming.

trigger_defNone | file-like | TriggerDef

If not None, a TriggerDef instance is used to log events with a descriptive string instead of their ID. If not None, either a TriggerDef instance or the path to a valid .ini file passed to TriggerDef.

chunk_sizeint

Number of samples to send at once (usually 16-32 is good enough).

high_resolutionbool

If True, it uses perf_counter instead of sleep for higher time resolution. However, it uses more CPU.

Attributes

chunk_size

Number of samples to send at once (usually 16-32 is good enough).

fif_file

Path to the compatible raw .fif file to play.

high_resolution

If True, it uses perf_counter instead of sleep.

process

Launched streaming process.

repeat

Number of times the stream player will loop.

state

Streaming state of the player.

stream_name

Stream's server name, displayed on LSL network.

trigger_def

Either None or TriggerDef instance.

Methods

start([blocking])

Start streaming data on LSL network in a new process.

stop()

Stop the streaming by terminating the process.

start(blocking=True)[source]

Start streaming data on LSL network in a new process.

Parameters:
blockingbool

If True, waits for the child process to start streaming data.

stop()[source]

Stop the streaming by terminating the process.

property chunk_size

Number of samples to send at once (usually 16-32 is good enough).

Type:

int

property fif_file

Path to the compatible raw .fif file to play.

Type:

str | Path

property high_resolution

If True, it uses perf_counter instead of sleep.

Type:

bool

property process

Launched streaming process.

Type:

Process

property repeat

Number of times the stream player will loop.

Default float('inf') can be passed to never interrupt streaming.

Type:

int | float('ìnf')

property state

Streaming state of the player.

  • 0: Not streaming.

  • 1: Streaming.

Type:

Value

property stream_name

Stream’s server name, displayed on LSL network.

Type:

str

property trigger_def

Either None or TriggerDef instance.

Used to convert event numbers into event strings.

Type:

TriggerDef

Examples using bsl.StreamPlayer

StreamPlayer: simulate an LSL stream

StreamPlayer: simulate an LSL stream

StreamRecorder: resting-state recording

StreamRecorder: resting-state recording

StreamReceiver: real-time buffer filtered with a causal filter

StreamReceiver: real-time buffer filtered with a causal filter

StreamReceiver: real-time alpha band power

StreamReceiver: real-time alpha band power