diff options
| author | Matthias Geier <Matthias.Geier@gmail.com> | 2021-09-30 11:43:56 +0200 |
|---|---|---|
| committer | Matthias Geier <Matthias.Geier@gmail.com> | 2021-09-30 11:43:56 +0200 |
| commit | 631378d7bedc41e1d29133ae7fb5fdd8e45d82fd (patch) | |
| tree | 0e95e6c10db279f2ced57eed1f62c067cfb3a088 | |
| parent | 3c4ffbd91e2579b07c18106ce514b5af7b6c6ac6 (diff) | |
Fix dimension check in Stream.write()
| -rw-r--r-- | sounddevice.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sounddevice.py b/sounddevice.py index 9998264..5b567d9 100644 --- a/sounddevice.py +++ b/sounddevice.py @@ -1524,8 +1524,12 @@ class OutputStream(RawOutputStream): data = np.asarray(data) _, dtype = _split(self._dtype) _, channels = _split(self._channels) - if data.ndim > 1 and data.shape[1] != channels: - raise ValueError('Number of channels must match') + if data.ndim < 2: + data = data.reshape(-1, 1) + elif data.ndim > 2: + raise ValueError('data must be one- or two-dimensional') + if data.shape[1] != channels: + raise ValueError('number of channels must match') if data.dtype != dtype: raise TypeError('dtype mismatch: {!r} vs {!r}'.format( data.dtype.name, dtype)) |
