Audio

Cross-platform audio playback using PyAudio and numpy.

This module provides reliable audio playback that works regardless of which display backend (pygame, pyglet, psychopy) is being used. It uses PyAudio and numpy for lightweight, backend-independent audio.

Usage:

from pyelink.audio import AudioPlayer

# Create player player = AudioPlayer()

# Play beeps player.beep_target() # 800 Hz player.beep_done() # 1200 Hz player.beep_error() # 400 Hz

class pyelink.audio.AudioPlayer(sample_rate=44100)[source]

Bases: object

Audio player using PyAudio for backend-independent audio playback.

Parameters:

sample_rate (int)

__init__(sample_rate=44100)[source]

Initialize the audio player with PyAudio.

Parameters:

sample_rate (int) – Audio sample rate in Hz (default: 44100)

Return type:

None

beep_target()[source]

Play the target acquisition beep (800 Hz).

Return type:

None

beep_done()[source]

Play the calibration done beep (1200 Hz).

Return type:

None

beep_error()[source]

Play the error beep (400 Hz).

Return type:

None

pyelink.audio.get_player()[source]

Get a shared AudioPlayer instance.

Return type:

AudioPlayer

pyelink.audio.play_target_beep()[source]

Play the target acquisition beep (800 Hz).

Return type:

None

pyelink.audio.play_done_beep()[source]

Play the calibration done beep (1200 Hz).

Return type:

None

pyelink.audio.play_error_beep()[source]

Play the error beep (400 Hz).

Return type:

None