Minimal examples for streaming microphone and webcam to Lab Streaming Layer (LSL) and for quickly validating recorded XDF files.
.
├─ mic_to_lsl.py # Microphone → LSL (Audio)
├─ webcam_to_lsl.py # Webcam → LSL (Video)
├─ paradigm_session_marker.py # Marker → LSL
├─ read_xdf_check.py # Quick sanity check for XDF files
└─ requirements.txt # Dependencies
- Microphone
type="Audio",channel_count=1(sampling rate depends on OS/device) - Webcam_External
type="Video",channel_count=1(frame rate depends on device/codec) - BCI_Markers (optional, from a paradigm app)
type="Markers", single string channel (codes sent as strings)
When recording with LabRecorder, you’ll typically see:
BCI_Markers (Markers), Webcam_External (Video), Microphone (Audio)
python -m venv .venvpip install -r requirements.txt
python mic_to_lsl.py- Logs device info and sampling rate.
- Stream name:
Microphone, type:Audio.
python webcam_to_lsl.py- Sends frames from the default camera.
- Stream name:
Webcam_External, type:Video.
If multiple devices are present, edit
device_index/camera_indexat the top of each script.
- Open LabRecorder → Refresh → select the streams (include markers if available)
- Click Start to record → Stop to save
*.xdf
python read_xdf_check.py path/to/recording.xdfExample output:
Stream 0: BCI_Markers (Markers)
samples: 9
channels: 1
Stream 1: Webcam_External (Video)
samples: 711
channels: 1
Stream 2: Microphone (Audio)
samples: 3131379
channels: 1