@@ -305,43 +305,10 @@ def read(file, samplerate=None, channels=None, subtype=None, endian=None,
305305 it is overwritten and a view containing all valid frames is
306306 returned.
307307
308- The keyword arguments ``samplerate``, ``channels``, ``format``,
309- ``subtype`` and endian are only needed for ``'RAW'`` files. See
310- :class:`pysoundfile.SoundFile` for details.
311-
312308 Parameters
313309 ----------
314310 file : A filename or a ``file`` object or file descriptor
315311 The file to open.
316- samplerate : int, sometimes optional
317- The samplerate of the file. Not necessary in ``'r'`` and
318- ``'r+'`` mode. Always necessary in ``'RAW'`` format.
319- channels : int, sometimes optional
320- The number of channels of the file. Not necessary in
321- ``'r'`` and ``'r+'`` mode. Always necessary in ``'RAW'``
322- format.
323- subtype : str, optional
324- The subtype of the sound file. Not necessary in ``'r'``
325- and ``'r+'`` mode. Always necessary in ``'RAW'`` format.
326- If not given, all formats except for ``'RAW'`` will use
327- their default subtype. See
328- :func:`pysoundfile.available_subtypes` for all possible
329- values.
330- endian : {'FILE', 'LITTLE', 'BIG', 'CPU'}, optional
331- The endianness of the sound file. Not necessary in ``'r'``
332- and ``'r+'`` mode. Always necessary in ``'RAW'`` format.
333- By default, this is set to ``'FILE'``, which is correct in
334- most cases.
335- format : str, optional
336- The format of the sound file. Not necessary in ``'r'`` and
337- ``'r+'`` mode. Always necessary in ``'RAW'`` format or
338- when no file extension is given. If not given, this will
339- be determined based on the file extension. See
340- :func:`pysoundfile.available_formats` for all possible
341- values.
342- closefd : bool, optional
343- Whether to close the file descriptor on destruction. Only
344- applicable to file descriptors.
345312 start : int, optional
346313 Where to start reading. Only two of ``start``, ``stop``, and
347314 ``frames`` can be given.
@@ -375,6 +342,11 @@ def read(file, samplerate=None, channels=None, subtype=None, endian=None,
375342 frames were requested than available in the file and
376343 ``out`` was given, this will be a view into ``out``.
377344
345+ Other Parameters
346+ ----------------
347+ samplerate, channels, format, subtype, endian, closefd
348+ See :class:`SoundFile`.
349+
378350 Examples
379351 --------
380352 Reading 3 frames from a stereo file:
@@ -405,8 +377,6 @@ def write(data, file, samplerate,
405377 If ``data`` is one-dimensional, a mono file is written. For
406378 two-dimensional ``data``, the columns are interpreted as channels.
407379
408- All further arguments are forwarded to :class:`pysoundfile.SoundFile`.
409-
410380 Parameters
411381 ----------
412382 data : ndarray
@@ -416,31 +386,11 @@ def write(data, file, samplerate,
416386 Must be (channels x frames) or a 1D-array for mono files.
417387 file : A filename or a ``file`` object or file descriptor
418388 The file to open.
419- samplerate : int, sometimes optional
420- The samplerate of the file. Not necessary in ``'r'`` and
421- ``'r+'`` mode. Always necessary in ``'RAW'`` format.
422- subtype : str, optional
423- The subtype of the sound file. Not necessary in ``'r'``
424- and ``'r+'`` mode. Always necessary in ``'RAW'`` format.
425- If not given, all formats except for ``'RAW'`` will use
426- their default subtype. See
427- :func:`pysoundfile.available_subtypes` for all possible
428- values.
429- endian : {'FILE', 'LITTLE', 'BIG', 'CPU'}, optional
430- The endianness of the sound file. Not necessary in ``'r'``
431- and ``'r+'`` mode. Always necessary in ``'RAW'`` format.
432- By default, this is set to ``'FILE'``, which is correct in
433- most cases.
434- format : str, optional
435- The format of the sound file. Not necessary in ``'r'`` and
436- ``'r+'`` mode. Always necessary in ``'RAW'`` format or
437- when no file extension is given. If not given, this will
438- be determined based on the file extension. See
439- :func:`pysoundfile.available_formats` for all possible
440- values.
441- closefd : bool, optional
442- Whether to close the file descriptor on destruction. Only
443- applicable to file descriptors.
389+
390+ Other Parameters
391+ ----------------
392+ samplerate, format, subtype, endian, closefd
393+ See :class:`SoundFile`.
444394
445395 Examples
446396 --------
@@ -482,65 +432,15 @@ def blocks(file, samplerate=None, channels=None,
482432 ----------
483433 file : A filename or a ``file`` object or file descriptor
484434 The file to open.
485- samplerate : int, sometimes optional
486- The samplerate of the file. Not necessary in ``'r'`` and
487- ``'r+'`` mode. Always necessary in ``'RAW'`` format.
488- channels : int, sometimes optional
489- The number of channels of the file. Not necessary in
490- ``'r'`` and ``'r+'`` mode. Always necessary in ``'RAW'``
491- format.
492- subtype : str, optional
493- The subtype of the sound file. Not necessary in ``'r'``
494- and ``'r+'`` mode. Always necessary in ``'RAW'`` format.
495- If not given, all formats except for ``'RAW'`` will use
496- their default subtype. See
497- :func:`pysoundfile.available_subtypes` for all possible
498- values.
499- endian : {'FILE', 'LITTLE', 'BIG', 'CPU'}, optional
500- The endianness of the sound file. Not necessary in ``'r'``
501- and ``'r+'`` mode. Always necessary in ``'RAW'`` format.
502- By default, this is set to ``'FILE'``, which is correct in
503- most cases.
504- format : str, optional
505- The format of the sound file. Not necessary in ``'r'`` and
506- ``'r+'`` mode. Always necessary in ``'RAW'`` format or
507- when no file extension is given. If not given, this will
508- be determined based on the file extension. See
509- :func:`pysoundfile.available_formats` for all possible
510- values.
511- closefd : bool, optional
512- Whether to close the file descriptor on destruction. Only
513- applicable to file descriptors.
514435 blocksize : int
515436 The number of frames to read per block. Either this or ``out``
516437 must be given.
517438 overlap : int, optional
518439 The number of frames to rewind between each block.
519- start : int, optional
520- Where to start reading. Only two of ``start``, ``stop``, and
521- ``frames`` can be given.
522- stop : int, optional
523- Where to stop reading. Only two of ``start``, ``stop``, and
524- ``frames`` can be given. Ignored if ``None``.
525- frames : int, optional
526- The number of frames to read. If ``-1``, the whole rest of the
527- file is read. Only two of ``start``, ``stop``, and ``frames``
528- can be given.
440+ start, stop, frames
441+ See :func:`read`.
529442 dtype : {'float64', 'float32', 'int32', 'int16'}, optional
530- The data type to read. Floating point data is always in
531- the range -1..1, and integer data is always in the range
532- ``INT16_MIN``..``INT16_MAX`` or
533- ``INT32_MIN``..``INT32_MAX``.
534- always_2d : bool, optional
535- Whether to always return a 2D array. If ``False``, single
536- channel reads will return 1D arrays.
537- fill_value : float, optional
538- If given and more frames were requested than available in
539- the file, the rest of the output will be filled with
540- ``fill_value``.
541- out : ndarray, optional
542- If given, the data will be read into this ``ndarray``
543- instead of creating a new ``ndarray``.
443+ See :func:`read`.
544444
545445 Returns
546446 -------
@@ -550,6 +450,13 @@ def blocks(file, samplerate=None, channels=None,
550450 the remaining frames are not cleanly divisible by
551451 ``blocksize``, the last block will be a view into ``out``.
552452
453+ Other Parameters
454+ ----------------
455+ samplerate, channels, format, subtype, endian, closefd
456+ See :class:`SoundFile`.
457+ always_2d, fill_value, out
458+ See :func:`read`.
459+
553460 Examples
554461 --------
555462
@@ -624,33 +531,6 @@ def available_subtypes(format=None):
624531def format_check (format , subtype = None , endian = None ):
625532 """Check if the combination of format/subtype/endian is valid.
626533
627- Parameters
628- ----------
629- format : str, optional
630- The format of the sound file. Not necessary in ``'r'`` and
631- ``'r+'`` mode. Always necessary in ``'RAW'`` format or
632- when no file extension is given. If not given, this will
633- be determined based on the file extension. See
634- :func:`pysoundfile.available_formats` for all possible
635- values.
636- subtype : str, optional
637- The subtype of the sound file. Not necessary in ``'r'``
638- and ``'r+'`` mode. Always necessary in ``'RAW'`` format.
639- If not given, all formats except for ``'RAW'`` will use
640- their default subtype. See
641- :func:`pysoundfile.available_subtypes` for all possible
642- values.
643- endian : {'FILE', 'LITTLE', 'BIG', 'CPU'}, optional
644- The endianness of the sound file. Not necessary in ``'r'``
645- and ``'r+'`` mode. Always necessary in ``'RAW'`` format.
646- By default, this is set to ``'FILE'``, which is correct in
647- most cases.
648-
649- Returns
650- -------
651- bool
652- Whether this combination is valid or not.
653-
654534 Examples
655535 --------
656536 >>> sf.format_check('WAV', 'INT_16')
@@ -669,16 +549,6 @@ def format_check(format, subtype=None, endian=None):
669549def default_subtype (format ):
670550 """Return the default subtype for a given format.
671551
672- Parameters
673- ----------
674- format : str
675- The name of a format.
676-
677- Returns
678- -------
679- str
680- The name of a subtype appropriate for ``format``.
681-
682552 Examples
683553 --------
684554 >>> sf.default_subtype('WAV')
@@ -998,49 +868,22 @@ def seek(self, frames, whence=SEEK_SET):
998868
999869 def read (self , frames = - 1 , dtype = 'float64' , always_2d = True ,
1000870 fill_value = None , out = None ):
1001- """Read from the file.
1002-
1003- Reads the given number of ``frames`` in the given data format
1004- from the current read/write position. This advances the
1005- read/write position by the same number of frames. Use
1006- ``frames=-1`` to read until the end of the file.
1007-
1008- A two-dimensional NumPy array is returned, where the channels
1009- are stored along the first dimension, i.e. as columns. A
1010- two-dimensional array is returned even if the sound file has
1011- only one channel. Use ``always_2d=False`` to return a
1012- one-dimensional array in this case.
871+ """Read from the file and return data as NumPy array.
1013872
1014- If ``out`` is specified, the data is written into the given
1015- NumPy array. In this case, the arguments ``dtype`` and
1016- ``always_2d`` are silently ignored!
1017-
1018- If there is less data left in the file than requested, the
1019- rest of the frames are filled with ``fill_value``. If
1020- ``fill_value=None``, a smaller array is returned. If ``out``
1021- is given, only a part of it is overwritten and a view
1022- containing all valid frames is returned.
873+ Reads the given number of frames in the given data format
874+ starting at the current read/write position. This advances the
875+ read/write position by the same number of frames.
876+ By default, all frames from the current read/write position to
877+ the end of the file are returned.
878+ Use :meth:`.seek` to move the current read/write position.
1023879
1024880 Parameters
1025881 ----------
1026882 frames : int, optional
1027883 The number of frames to read. If ``-1``, the whole rest of
1028884 the file is read.
1029885 dtype : {'float64', 'float32', 'int32', 'int16'}, optional
1030- The data type to read. Floating point data is always in
1031- the range -1..1, and integer data is always in the range
1032- ``INT16_MIN``..``INT16_MAX`` or
1033- ``INT32_MIN``..``INT32_MAX``.
1034- always_2d : bool, optional
1035- Whether to always return a 2D array. If ``False``, single
1036- channel reads will return 1D arrays.
1037- fill_value : float, optional
1038- If given and more frames were requested than available in
1039- the file, the rest of the output will be filled with
1040- ``fill_value``.
1041- out : ndarray, optional
1042- If given, the data will be read into this ``ndarray``
1043- instead of creating a new ``ndarray``.
886+ See :func:`read`.
1044887
1045888 Returns
1046889 -------
@@ -1049,6 +892,11 @@ def read(self, frames=-1, dtype='float64', always_2d=True,
1049892 frames were requested than available in the file and
1050893 ``out`` was given, this will be a view into ``out``.
1051894
895+ Other Parameters
896+ ----------------
897+ always_2d, fill_value, out
898+ See :func:`read`.
899+
1052900 Examples
1053901 --------
1054902 >>> soundFile = sf.SoundFile('stereo_file.wav')
@@ -1144,20 +992,7 @@ def blocks(self, blocksize=None, overlap=0, frames=-1, dtype='float64',
1144992 The maximum number of frames to read. This can be used
1145993 with the read/write pointer to read only part of a file.
1146994 dtype : {'float64', 'float32', 'int32', 'int16'}, optional
1147- The data type to read. Floating point data is always in
1148- the range -1..1, and integer data is always in the range
1149- ``INT16_MIN``..``INT16_MAX`` or
1150- ``INT32_MIN``..``INT32_MAX``.
1151- always_2d : bool, optional
1152- Whether to always return a 2D array. If ``False``, single
1153- channel reads will return 1D arrays.
1154- fill_value : float, optional
1155- If given and more frames were requested than available in
1156- the file, the rest of the output will be filled with
1157- ``fill_value``.
1158- out : ndarray, optional
1159- If given, the data will be read into this ``ndarray``
1160- instead of creating a new ``ndarray``.
995+ See :func:`read`.
1161996
1162997 Returns
1163998 -------
@@ -1167,6 +1002,11 @@ def blocks(self, blocksize=None, overlap=0, frames=-1, dtype='float64',
11671002 the remaining frames are not cleanly divisible by
11681003 ``blocksize``, the last block will be a view into ``out``.
11691004
1005+ Other Parameters
1006+ ----------------
1007+ always_2d, fill_value, out
1008+ See :func:`read`.
1009+
11701010 Examples
11711011 --------
11721012 >>> soundFile = sf.SoundFile('stereo_file.wav')
0 commit comments