277277_snd = _ffi .dlopen ('sndfile' )
278278
279279
280- def read (file , samplerate = None , channels = None , subtype = None , endian = None ,
281- format = None , closefd = True , start = 0 , stop = None , frames = - 1 ,
282- dtype = 'float64' , always_2d = True , fill_value = None , out = None ):
280+ def read (file , frames = - 1 , start = 0 , stop = None , dtype = 'float64' , always_2d = True ,
281+ fill_value = None , out = None , samplerate = None , channels = None ,
282+ format = None , subtype = None , endian = None , closefd = True ):
283283 """Read a sound file and return its contents as NumPy array.
284284
285285 The number of frames to read can be specified with ``frames``, the
@@ -309,16 +309,16 @@ def read(file, samplerate=None, channels=None, subtype=None, endian=None,
309309 ----------
310310 file : A filename or a ``file`` object or file descriptor
311311 The file to open.
312+ frames : int, optional
313+ The number of frames to read. If ``-1``, the whole rest of the
314+ file is read. Only two of ``start``, ``stop``, and ``frames``
315+ can be given.
312316 start : int, optional
313317 Where to start reading. Only two of ``start``, ``stop``, and
314318 ``frames`` can be given.
315319 stop : int, optional
316320 Where to stop reading. Only two of ``start``, ``stop``, and
317321 ``frames`` can be given. Ignored if ``None``.
318- frames : int, optional
319- The number of frames to read. If ``-1``, the whole rest of the
320- file is read. Only two of ``start``, ``stop``, and ``frames``
321- can be given.
322322 dtype : {'float64', 'float32', 'int32', 'int16'}, optional
323323 The data type to read. Floating point data is typically in
324324 the range -1..1, and integer data is always in the range
@@ -362,7 +362,7 @@ def read(file, samplerate=None, channels=None, subtype=None, endian=None,
362362
363363 with SoundFile (file , 'r' , samplerate , channels ,
364364 subtype , endian , format , closefd ) as f :
365- start , frames = _get_read_range (start , stop , frames , f .frames )
365+ start , frames = _get_read_range (frames , start , stop , f .frames )
366366 f .seek (start , SEEK_SET )
367367 data = f .read (frames , dtype , always_2d , fill_value , out )
368368 return data , f .samplerate
@@ -410,10 +410,10 @@ def write(data, file, samplerate,
410410 f .write (data )
411411
412412
413- def blocks (file , samplerate = None , channels = None ,
414- subtype = None , endian = None , format = None , closefd = True ,
415- blocksize = None , overlap = 0 , start = 0 , stop = None , frames = - 1 ,
416- dtype = 'float64' , always_2d = True , fill_value = None , out = None ):
413+ def blocks (file , blocksize = None , overlap = 0 , frames = - 1 , start = 0 , stop = None ,
414+ dtype = 'float64' , always_2d = True , fill_value = None , out = None ,
415+ samplerate = None , channels = None ,
416+ format = None , subtype = None , endian = None , closefd = True ):
417417 """Return a generator for block-wise processing.
418418
419419 All keyword arguments of :meth:`SoundFile.blocks` are
@@ -437,7 +437,7 @@ def blocks(file, samplerate=None, channels=None,
437437 must be given.
438438 overlap : int, optional
439439 The number of frames to rewind between each block.
440- start, stop, frames
440+ frames, start, stop
441441 See :func:`read`.
442442 dtype : {'float64', 'float32', 'int32', 'int16'}, optional
443443 See :func:`read`.
@@ -452,10 +452,10 @@ def blocks(file, samplerate=None, channels=None,
452452
453453 Other Parameters
454454 ----------------
455- samplerate, channels, format, subtype, endian, closefd
456- See :class:`SoundFile`.
457455 always_2d, fill_value, out
458456 See :func:`read`.
457+ samplerate, channels, format, subtype, endian, closefd
458+ See :class:`SoundFile`.
459459
460460 Examples
461461 --------
@@ -470,7 +470,7 @@ def blocks(file, samplerate=None, channels=None,
470470
471471 with SoundFile (file , 'r' , samplerate , channels ,
472472 subtype , endian , format , closefd ) as f :
473- start , frames = _get_read_range (start , stop , frames , f .frames )
473+ start , frames = _get_read_range (frames , start , stop , f .frames )
474474 f .seek (start , SEEK_SET )
475475 for block in f .blocks (blocksize , overlap , frames ,
476476 dtype , always_2d , fill_value , out ):
@@ -1211,7 +1211,7 @@ def _read_or_write(self, funcname, array, frames):
12111211 return frames
12121212
12131213
1214- def _get_read_range (start , stop , frames , total_frames ):
1214+ def _get_read_range (frames , start , stop , total_frames ):
12151215 # Calculate start frame and length
12161216 start , stop , _ = slice (start , stop ).indices (total_frames )
12171217 if stop < start :
0 commit comments