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.

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.4.tar.gz (6.1 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.4-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: PyAudioMixer-0.0.4.tar.gz
  • Upload date:
  • Size: 6.1 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.4.tar.gz
Algorithm Hash digest
SHA256 91c16fe5a297b415c0c9935a40b481d823bdf1c3e7db501cf189205e7f8189c0
MD5 016c5f2affc80daddc5ccb8d360afe8e
BLAKE2b-256 aac8bbe091c1649064903017582d3b1f5a7a2cab615ea76d7ee36002938c703e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: PyAudioMixer-0.0.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ce6170232a1743401b7b511bcf14a5955775589f1a6d79a5871300ee266a76db
MD5 bd921706e177b4b3b8f9a7fab8233c8e
BLAKE2b-256 6d0faccb59d69c5f221d0817ee5513507753a6021ab0d1480b514ec3a02bbfd5

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