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.3.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.3-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: PyAudioMixer-0.0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 bfb4a17c52f93c87af47cc55797f96350afe97eee55b324b4ba055d07fc0ba4f
MD5 a251b18b20ce3c80b6342de08515c486
BLAKE2b-256 dd44af1dad1d9dcb0e5b7792b61374040d1358a079b5136e44c4e99cac7b7569

See more details on using hashes here.

File details

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

File metadata

  • Download URL: PyAudioMixer-0.0.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e2fa05754237e51865f9a6a3e69d714f6d787841e173e58587b1ae2ebebb2e45
MD5 c865560b9cccef3b151bfe3875b499cf
BLAKE2b-256 9152c9bea57147374a039e64bebfa7c8572e11df1a6b02f87243c4ac8ba667d4

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