File tree 1 file changed +12
-4
lines changed
1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -429,15 +429,23 @@ def _get_slice_bounds(self, frame):
429
429
return start , stop
430
430
431
431
def __getitem__ (self , frame ):
432
- # access the file as if it where a one-dimensional Numpy
433
- # array. Data must be in the form (frames x channels).
434
- # Both open slice bounds and negative values are allowed.
432
+ # access the file as if it where a Numpy array. The data is
433
+ # returned as numpy array.
434
+ second_frame = None
435
+ if isinstance (frame , tuple ):
436
+ if len (frame ) > 2 :
437
+ raise AttributeError (
438
+ "SoundFile can only be accessed in one or two dimensions" )
439
+ frame , second_frame = frame
435
440
start , stop = self ._get_slice_bounds (frame )
436
441
curr = self .seek (0 )
437
442
self .seek_absolute (start )
438
443
data = self .read (stop - start )
439
444
self .seek_absolute (curr )
440
- return data
445
+ if second_frame :
446
+ return data [(slice (None ), second_frame )]
447
+ else :
448
+ return data
441
449
442
450
def __setitem__ (self , frame , data ):
443
451
# access the file as if it where a one-dimensional Numpy
You can’t perform that action at this time.
0 commit comments