Skip to content

Commit

Permalink
fix initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
mscheltienne committed Aug 30, 2024
1 parent 29c4459 commit 1b42e12
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions stimuli/audio/_backend/sounddevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ def __init__(
"The data array provided to the 'SoundSD' backend is not C-contiguous."
)
data = np.ascontiguousarray(data)
if data.ndim == 2 and device["max_output_channels"] < data.shape[1]:
raise ValueError(
f"Device '{device_idx}: {device['name']}' does not support the number "
f"of output channels ({data.shape[1]})."
)
if sample_rate != device["default_samplerate"]:
warn(
f"The sample rate provided to the 'SoundSD' backend ({sample_rate}) "
Expand All @@ -92,6 +97,7 @@ def __init__(
samplerate=sample_rate,
blocksize=block_size,
device=device_idx,
channels=data.shape[1] if data.ndim == 2 else 1,
dtype=data.dtype,
)
self._stream.start()
Expand Down

0 comments on commit 1b42e12

Please sign in to comment.