Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,21 @@ RAW Files
---------

Pysoundfile can usually auto-detect the file type of sound files. This
is not possible for RAW files, though. This is a useful idiom for
opening RAW files without having to provide all the format for every
file:
is not possible for RAW files, though:

.. code:: python

import soundfile as sf

format = {'format':'RAW', 'subtype':'FLOAT', 'endian':'FILE'}
data = sf.read('myfile.raw', dtype='float32', **format)
sf.write('otherfile.raw', data, **format)
data, samplerate = sf.read('myfile.raw', channels=1, samplerate=44100,
subtype='FLOAT')

Note that on x86, this defaults to ``endian='LITTLE'``. If you are
reading big endian data (mostly old PowerPC/6800-based files), you
have to set ``endian='BIG'`` accordingly.

You can write RAW files in a similar way, but be advised that in most
cases, a more expressive format is better and should be used instead.

Virtual IO
----------
Expand All @@ -144,7 +148,7 @@ Here is an example using an HTTP request:
import io
import soundfile as sf
from urllib.request import urlopen

url = "http://tinyurl.com/shepard-risset"
data, samplerate = sf.read(io.BytesIO(urlopen(url).read()))

Expand Down