Skip to main content

Audio signal processing library

Project description

Copyright (c) 2013 Ronny Andersson

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.

Download-URL: https://pypi.python.org/pypi/zignal Description: # zignal

This is a python audio signal processing library.

Python 2 is no longer supported, the last version to support python 2 is 0.2.0

## Example usage

>>> import zignal
>>>
>>> x = zignal.Sinetone(fs=44100, f0=997, duration=0.1, gaindb=-20)
>>> print(x)
=======================================
classname        : Sinetone
sample rate      : 44100.0 [Hz]
channels         : 1
duration         : 0.100 [s]
datatype         : float64
samples per ch   : 4410
data size        : 0.034 [Mb]
has comment      : no
peak             : [ 0.1]
RMS              : [ 0.0707]
crestfactor      : [ 1.4147]
-----------------:---------------------
frequency        : 997.0 [Hz]
phase            : 0.0 [deg]
-----------------:---------------------
>>> x.fade_out(millisec=10)
>>> x.convert_to_float(targetbits=32)
>>> x.write_wav_file("sinetone.wav")
>>> x.plot()
>>> x.plot_fft()
>>>
>>> f = zignal.filters.biquads.RBJ(filtertype="peak", gaindb=-6, f0=997, Q=0.707, fs=96000)
>>> print(f)
=======================================
classname        : RBJ
sample rate      : 96000.0 [Hz]
feedforward  (B) : [ 0.96949457 -1.87369167  0.90819329]
feedback     (A) : [ 1.         -1.87369167  0.87768787]
number of zeros  : 2
number of poles  : 2
minimum phase?   : Yes
-----------------:---------------------
stable?          : Yes
type             : peak
gain             : -6.00 [dB]
f0               : 997.0 [Hz]
Q                : 0.7070
>>> f.plot_mag_phase()
>>> f.plot_pole_zero()
>>>

See the examples folder for more examples.

## Requirements

This library relies on numpy, scipy, matplotlib and optionally pyaudio (and nose for unit testing). It is recommended to create a virtual environment and let pip install the dependencies automatically.

python3 -m venv <name-of-virtualenv> . <name-of-virtualenv>/bin/activate pip install zignal

Optionally, to be able to use a soundcard, first install the python development headers and the portaudio development files. On debian/ubuntu,

sudo apt install python3-dev portaudio19-dev

then run

pip install zignal[sndcard]

which will automatically build the portaudio library and then pyaudio.

## Local development

Create a python3 virtualenv and install from the requirements.txt file to make the zignal library editable. Note that the python development headers (python3-dev) and portaudio19-dev must be installed first.

python3 -m venv zignaldev . zignaldev/bin/activate pip install -r requirements.txt

## Design goals

  1. Readability over efficiency. This is a python library for development and understanding of audio signal processing.

  2. The initial goal is to write the functionality in pure python, with the use of numpy, scipy and matplotlib. See rule 1. If efficiency becomes an issue a c/c++ library might be implemented but the pure python code must remain the default choice.

  3. Design for non real-time processing. Functionality to do real-time processing can be added if it does not break rule 1.

  4. Self documentation. The code should aim to be well documented, in the source code itself.

Keywords: audio,sound,card,soundcard,pyaudio,portaudio,playback,recording,digital,signal,processing,DSP,signalprocessing,fourier,FFT,filter,filtering,parametric,eq,equaliser,equalizer,biquad,cookbook,sine,generator,mls,mlssa,maximum,length,sequence,maximumlengthsequence,pseudo,random,pseudorandom,measure,measurement,impulse,response,impulseresponse,frequency,frequencyresponse,magnitude,magnituderesponse,piano,midi,tuning,scale,pitch,notation,equal,temperament,12TET,spn Platform: any Classifier: Development Status :: 3 - Alpha Classifier: Environment :: Console Classifier: Intended Audience :: Developers Classifier: Intended Audience :: Education Classifier: Intended Audience :: Science/Research Classifier: License :: OSI Approved :: MIT License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3.6 Classifier: Topic :: Education Classifier: Topic :: Multimedia :: Sound/Audio :: Analysis Classifier: Topic :: Multimedia :: Sound/Audio :: Capture/Recording Classifier: Topic :: Multimedia :: Sound/Audio :: Editors Classifier: Topic :: Multimedia :: Sound/Audio :: MIDI Classifier: Topic :: Multimedia :: Sound/Audio :: Mixers Classifier: Topic :: Multimedia :: Sound/Audio :: Players Classifier: Topic :: Multimedia :: Sound/Audio :: Sound Synthesis Classifier: Topic :: Scientific/Engineering :: Mathematics Classifier: Topic :: Software Development :: Quality Assurance Classifier: Topic :: Software Development :: Testing Provides-Extra: sndcard Provides-Extra: testing

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zignal-0.5.0.tar.gz (37.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zignal-0.5.0-py3-none-any.whl (41.5 kB view details)

Uploaded Python 3

File details

Details for the file zignal-0.5.0.tar.gz.

File metadata

  • Download URL: zignal-0.5.0.tar.gz
  • Upload date:
  • Size: 37.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.5.2

File hashes

Hashes for zignal-0.5.0.tar.gz
Algorithm Hash digest
SHA256 538dae524096f5a928c1feb61c2076f662a0a24f84738978fffdabb1fbce0ca8
MD5 c3fe6d6992cd09aefd32cb7dfa315d86
BLAKE2b-256 22580d1be7ce164041ff4486af4620d0988b855e9146afd5fbfce1eda0f4f0c9

See more details on using hashes here.

File details

Details for the file zignal-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: zignal-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 41.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.5.2

File hashes

Hashes for zignal-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 079eef58b69c9a90ac2114d9e32f07f5fc083dd1854b5e6f7d61a67ae5b10019
MD5 f1e5185ce411b3976a87568489288a6d
BLAKE2b-256 6f4a8ed674f1f860b26ad00d8fa7d5a5298eff2c2ef9537680b7ca2294579dcc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page