Skip to main content

Advanced Realtime Software Mixer

Project description

PyAudioMixer

Advanced Realtime Software Mixer

Copyright 2008, Nathan Whitehead Released under the LGPL

Portions Copyright 2014, Nick Vahalik (KF5ZQE) Released under the LGPL v2.1

Portions Copyright 2020, Jean-Pierre Coetzee Release under the LGPL v2.1

This module implements a realtime sound mixer suitable for use in games or other audio applications. It supports loading sounds in uncompressed WAV format and also MP3 format. It can mix several sounds together during playback. The volume and position of each sound can be finely controlled. Sounds are automatically resampled and stereo converted for correct playback. Samples can also be looped any number of times. Longer sounds can be streamed from a file to save memory. In addition, the mixer supports audio input during playback (if supported in pyaudio with your sound card).

It has been further extended to support multiple simultaneous mixers which can be controlled independently, frequency and DTMF generators as well as multiple Microphone input support.

This code is a work in progress!

Interfaces and objects are going to be changing drastically as work progresses! Use at your own risk!

Patches welcome!

Requirements

PyAudio 0.2.0 (or more recent) http://people.csail.mit.edu/hubert/pyaudio/

NumPy 1.0 (or more recent) http://numpy.scipy.org/

ffmpeg installed and in your path https://ffmpeg.org/

Documentation

This README file along with the pydoc documentation in the doc/ directory are the documentation for SWMixer.

How can it possibly work in Python?

Realtime mixing of sample data is done entirely in Python using the high performance of array operations in NumPy. Converting between sound formats (e.g. mono->stereo) is done using various NumPy operations. Resampling is done using the linear interpolation function of NumPy. Simultaneous playback and recording is possibly using PyAudio.

At time of current writing, the latency and CPU utilization of PyAudioMixer is slightly better than Audacity running on my test machine (a 2013 Retina MacBook Pro).

How do I use it?

Unfortunately you will need to read the code, there is a function at the bottom of the code showing how to play a file and how to get mic input.

Bugs and Limitations

Always outputs in 16-bit mode.

Cannot deal with 24-bit WAV files, but CAN handle 32-bit ones (limitation of NumPy).

Resampling can be slow for longer files.

Does not detect samplerates that differ from requested samplerates. I.e. if you request a rate your card cannot handle, you might get incorrect playback rates.

Currently there is no way to limit the number of sounds mixed at once to prevent excessive CPU usage.

No way to pan mono sounds to different positions in stereo output.

Threading behavior may not be optimal on some platforms.

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

PyAudioMixer-0.0.1.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

PyAudioMixer-0.0.1-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file PyAudioMixer-0.0.1.tar.gz.

File metadata

  • Download URL: PyAudioMixer-0.0.1.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.3.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.8

File hashes

Hashes for PyAudioMixer-0.0.1.tar.gz
Algorithm Hash digest
SHA256 7ef583bf8ab94692a0298851236978b06f0981aab20f0f008979b6424b5b635e
MD5 e072087844fadebdb4b4b5e6b65e1cad
BLAKE2b-256 171c9e48bcca0abe420ecba005e96ccc075fab4f19a6b252294dbdaf8a3f0dad

See more details on using hashes here.

File details

Details for the file PyAudioMixer-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: PyAudioMixer-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.3.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.8

File hashes

Hashes for PyAudioMixer-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0b7bc33453e7b0184f31e534b0a1601595f8504107fe94b56dbfcf46545abcc0
MD5 8b737eb1f81e2f4fed0c41df4d3c035f
BLAKE2b-256 a22ee8b0e2a50c5a956c7c973618f4975ab8cab0c633f540c82626bf01d7e4bb

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