Metadata-Version: 2.4
Name: sndfileio
Version: 2.1.0
Summary: Simple API for reading / writing soundfiles
Author-email: Eduardo Moguillansky <eduardo.moguillansky@gmail.com>
License: Copyright (c) 2011-2017 GitHub Inc.
        
        Permission is hereby granted, free of charge, to any person obtaining
        a copy of this software and associated documentation files (the
        "Software"), to deal in the Software without restriction, including
        without limitation the rights to use, copy, modify, merge, publish,
        distribute, sublicense, and/or sell copies of the Software, and to
        permit persons to whom the Software is furnished to do so, subject to
        the following conditions:
        
        The above copyright notice and this permission notice shall be
        included in all copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
        EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
        MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
        NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
        LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
        OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
        WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
        
Project-URL: Homepage, https://github.com/gesellkammer/sndfileio
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/x-rst
License-File: LICENSE.md
Requires-Dist: numpy>1.8
Requires-Dist: scipy
Requires-Dist: soundfile
Requires-Dist: nnresample
Requires-Dist: numpyx>=0.4.1
Requires-Dist: tinytag
Requires-Dist: filetype
Requires-Dist: lameenc
Dynamic: license-file

*********
SNDFILEIO
*********

This package provides a simple and unified API to read and write sound-files to
and from numpy arrays. 

Documentation
-------------

https://sndfileio.readthedocs.io/en/latest/

------------------

API
---

sndread
~~~~~~~

-  reads all the samples (or a fragment) from a soundfile and returns a 
   tuplet (data, samplerate)
-  Data will always be as a ``numpy.float64``, between -1 and 1,
   independently of bit-rate

sndread_chunked
~~~~~~~~~~~~~~~

-  reads chunks of frames, avoiding the allocation of all the samples in
   memory

sndinfo
~~~~~~~

-  returns ``SndInfo``, a namedtuple with all the information of the
   sound-file

sndwrite
~~~~~~~~

-  writes the samples.
-  samples need to be a numpy.float64 array with data between -1 and 1

sndwrite_chunked
~~~~~~~~~~~~~~~~

-  allows you to write to the file as samples become available

resample
~~~~~~~~

Resample a numpy array to a new samplerate


Examples
--------


.. code-block:: python

    # Normalize and save as flac
    from sndfileio import sndread, sndwrite
    samples, sr = sndread("in.wav")
    maxvalue = max(samples.max(), -samples.min())
    samples *= 1/maxvalue
    sndwrite(samples, sr, "out.flac")


.. code-block:: python

    # Process a file in chunks
    from sndfileio import *
    from sndfileio.dsp import
    with sndwrite_chunked(44100, "out.flac") as writer:
        for buf in sndread_chunked("in.flac"):
            # do some processing, like changing the gain
            buf *= 0.5
            writer.write(buf)


Installation
------------


.. code-block:: bash


    pip install sndfileio
    

External dependencies
---------------------

- ``libsndfile`` (Debian/Ubuntu: ``apt install libsndfile1-dev``)

.. note::

    In windows and macos all external dependencies are installed automatically


License
-------

See the `LICENSE <LICENSE.md>`__ file for license rights and limitations
(MIT).
