An audio decoding and manipulation library, with bindings for C, Python, and WebAssembly.
Project description
Babycat is an audio decoding and manipulation library
Intro
Babycat is a library that makes it easy to decode and manipulate many audio files at once.
Use Babycat with C, Python, Rust, or JavaScript/WebAssembly.
Babycat is written in Rust, has generated bindings for C, Python, and WebAssembly, and can be compiled to many different target architectures.
Babycat's bindings to Python allow for the concurrent decoding of many audio files without being slowed down by the Python Global Interpreter Lock (GIL), allowing you to get work done faster than you could in pure Python.
Babycat is permissively-licensed.
Babycat is licensed under the MIT license. Unlike many other libraries in the audio ecosystem,you can use Babycat in any project you want without any restrictions.
Babycat is battle-tested in industry.
Babycat was built at and is actively maintained by Neocrym, a record label that use artificial intelligence to find and promote the world's greatest musicians. Neocrym uses Babycat to decode millions of songs as part of audio feature engineering pipelines for training machine learning models.
Terminology
Babycat uses the same audio terminology as the Apple Core Audio API:
- An audio stream is a continuous series of data that represents a sound, such as a song.
- A channel is a discrete track of monophonic audio. A monophonic stream has one channel. A stereo stream has two channels. An audio stream that contains 5.1 surround sound will have five normal channels and one Low Frequency Enhancement (LFE) channel.
- A sample is single numerical value in a single audio channel in an audio stream.
- A frame is a collection of samples from the same point in time--one sample for each channel.
- The frame rate (or sample rate) for a stream is the number of frames per second (hertz) of uncompressed audio.
Babycat stores audio as a single array of interleaved samples from channels. A waveform with two channels (e.g. left and right) are stored as:
[L R L R L R...]
We give every sample a two-dimensional index--first by frame and then by channel.
System requirements for compiling Babycat
Here is the software you will need if you want to compile your own changes to Babycat:
Rust 1.50 or newer
Babycat is written for stable Rust, targeting version 1.50.0 or newer.
GNU Make
GNU Make is a build system that Babycat uses to coordinate tasks.
If you are building Babycat on Windows, you should make sure that you have a Bash-compatible shell and GNU Make to run Babycat build commands with. On Windows, you can install GNU Make from the GNUWin32 project.
Many MacOS computers have the BSD version of Make, which might not parse Babycat's Makefile. To see which version of Make you have installed, run the command make --version
. You should see GNU
on the first line.
CMake
The CMake build system is necessary to compile Babycat with libsamplerate and other C/C++ dependencies.
A C compiler
Babycat is written in Rust, but a C compiler is needed to:
- compile certain Babycat dependencies, such as libsamplerate.
- compile and run the tests for Babycat's C bindings.
Any recent C compiler should work, but we prefer Clang/LLVM.
You can install a C compiler and build tools from your system package manager:
- Ubuntu:
apt-get install build-essential
- Fedora:
dnf install @development-tools
- MacOS:
xcode-select --install
On Windows, try installing the LLVM toolchain. There are Windows installers listed on the Pre-Built Binaries section of the LLVM releases page.
Python 3.6 or newer
Python 3.6 or newer is necessary for the following tasks:
- Compiling the Babycat Python bindings
- Using Babycat Python bindings
- Linting and formatting Python code
- Generating documentation using Sphinx
Node.js and NPM
Node.js and NPM are only necessary for running the Babycat WebAssembly tests. You should have Node.JS version 14 or newer. Node.js and NPM are only necessary for the following tasks:
- Testing the Babycat WebAssembly bindings.
- Linting and formatting the WebAssembly binding test source code.
OpenSSL development headers
wasm-pack and other dependencies need these headers. You can install these headers from your system package manager:
- Ubuntu:
apt-get install libssl-dev
- Fedora:
dnf install openssl-devel
- MacOS:
brew install openssl
libffi development headers
The CPython runtime, the Python cryptography package, and various other bits of code depend on the libffi development headers. You can install them from your system package manager:
- Ubuntu:
apt-get install libffi-dev
- Fedora:
dnf install libffi-devel
- MacOS:
brew install libffi
pkg-config (Linux only)
On Linux, the program pkg-config helps compilers find shared libraries. You can install pkg-config from your system package manager:
- Ubuntu:
apt-get install pkg-config
- Fedora:
dnf install pkgconf-pkg-config
- MacOS:
brew install pkg-config
ALSA headers (Linux only)
The Babycat command line program has the ability to paly audio through your system speakers. In order to compile this program on Linux, you will need the development headers for Advanced Linux Sound Architecture (ALSA).
You can install the ALSA development headers using your system package manager:
- Ubuntu:
apt-get install libasound2-dev
- Fedora:
dnf install alsa-lib-devel
cbindgen
cbindgen is a tool that we use to generate Babycat's C bindings. You can install it with the command cargo install cbindgen
.
wasm-pack
wasm-pack is a tool that we use to generate Babycat's WebAssembly bindings. You can install it with the command cargo install wasm-pack
.
Before you install wasm-pack, make sure you have already installed the OpenSSL development headers (see above).
Docker and Docker Compose
Docker is not necessary to build or use Babycat, but the Babycat repository contains a few Docker images that are useful for testing.
Docker is also required for building a Babycat Python wheel that obeys the manylinux
protocol--which is a requirement for building a binary Python wheel that is compatible with most Linux systems.
To use these images, install Docker and Docker Compose. The Docker website has installers for Docker Desktop here and Docker Compose here.
clang-format
clang-format is a tool that ships with the Clang compiler. Babycat uses it to automatically format the code for our C binding tests. If you already use Clang, you might already have clang-format installed. If not, you can install clang-format from your system package manager:
- Ubuntu:
apt-get install clang-format
- Fedora:
dnf install clang-tools
- MacOS:
brew install clang-format
On Windows, the best way to get clang-format is to download and install the LLVM toolchain. You can find Windows installers under the Pre-Built Binaries section of the LLVM releases page.
Acknowledgements
The first version of Babycat was an internal project at Neocrym written by Ritik Mishra. Since then, the code has been extended and open-sourced by James Mishra.
Babycat is built on top of many high-quality open source packages, including:
- Symphonia by Philip Deljanov
- libsamplerate by Erik de Castro Lopo
- Hound by Ruud van Asseldonk
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for babycat-0.0.5-cp36-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a169b875da0d87c14eb43516b0ece3fbea222c7276153931bf13c141d1e2bfd |
|
MD5 | 84f0084733109690f76769a644fc35b3 |
|
BLAKE2b-256 | 55fc68c0a19d9a8679a794f54f89be31f1f0e707025ea6346ee27b02f31e14fb |
Hashes for babycat-0.0.5-cp36-abi3-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c311830e0224a1e06c3dbf9208c6ba5720c7c4f8d94ec1efb39a03e46c33cd4 |
|
MD5 | 8637d7c40e7d7f7d4a1701ba0fcd6434 |
|
BLAKE2b-256 | e2ec5081bf132b96dc082874ac3633f76c1b4d016270102dcbc146f062e2504c |
Hashes for babycat-0.0.5-cp36-abi3-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc14e55b5af13d9c101abf84ffffc3ca439fba4c75ff1ab37629780fea71d469 |
|
MD5 | 9d4d58a6cad1747d7513f755fb427067 |
|
BLAKE2b-256 | eea73f422c9c1be0f51da3d33676fa19e55c0227d0bb9016dc88ffb7e09892b0 |