2015-06-30 20:49:36 +00:00
|
|
|
# libsoundio
|
|
|
|
|
|
|
|
C library which provides cross-platform audio input and output. The API is
|
|
|
|
suitable for real-time software such as digital audio workstations as well
|
|
|
|
as consumer software such as music players.
|
|
|
|
|
2015-07-01 08:02:44 +00:00
|
|
|
This library is an abstraction; however it prioritizes performance and power
|
|
|
|
over API convenience. Features that only exist in some sound backends are
|
|
|
|
exposed.
|
|
|
|
|
2015-07-06 06:42:56 +00:00
|
|
|
**This library is a work-in-progress.**
|
|
|
|
|
|
|
|
## Why libsoundio?
|
|
|
|
|
|
|
|
* [PortAudio](http://www.portaudio.com/)
|
|
|
|
- It does not support [PulseAudio](http://www.freedesktop.org/wiki/Software/PulseAudio/).
|
|
|
|
- It logs messages to stdio and you can't turn that off.
|
|
|
|
- It is not written by me.
|
|
|
|
* [rtaudio](https://www.music.mcgill.ca/~gary/rtaudio/)
|
|
|
|
- It is not a C library.
|
|
|
|
- It uses [exceptions](http://stackoverflow.com/questions/1736146/why-is-exception-handling-bad).
|
|
|
|
- It is not written by me.
|
|
|
|
* [SDL](https://www.libsdl.org/)
|
|
|
|
- It comes with a bunch of other baggage - display, windowing, input
|
|
|
|
handling, and lots more.
|
|
|
|
- It is not designed with real-time low latency audio in mind.
|
|
|
|
- Listing audio devices is [broken](https://github.com/andrewrk/node-groove/issues/13).
|
|
|
|
- It does not support recording devices.
|
|
|
|
- It is not written by me.
|
2015-06-30 21:13:44 +00:00
|
|
|
|
2015-06-30 20:49:36 +00:00
|
|
|
## How It Works
|
|
|
|
|
2015-07-01 08:02:44 +00:00
|
|
|
libsoundio tries these backends in order. If unable to connect to that backend,
|
|
|
|
due to the backend not being installed, or the server not running, or the
|
|
|
|
platform is wrong, the next backend is tried.
|
|
|
|
|
|
|
|
0. JACK
|
|
|
|
0. PulseAudio
|
|
|
|
0. ALSA (Linux)
|
|
|
|
0. CoreAudio (OSX)
|
|
|
|
0. ASIO (Windows)
|
|
|
|
0. DirectSound (Windows)
|
|
|
|
0. OSS (BSD)
|
|
|
|
0. Dummy
|
|
|
|
|
|
|
|
## Contributing
|
|
|
|
|
2015-07-02 22:54:36 +00:00
|
|
|
libsoundio is programmed in a tiny subset of C++11:
|
2015-07-01 08:02:44 +00:00
|
|
|
|
|
|
|
* No STL.
|
|
|
|
* No `new` or `delete`.
|
|
|
|
* No `class`. All fields in structs are `public`.
|
|
|
|
* No exceptions or run-time type information.
|
|
|
|
* No references.
|
|
|
|
* No linking against libstdc++.
|
2015-06-30 20:49:36 +00:00
|
|
|
|
2015-07-02 22:54:36 +00:00
|
|
|
Don't get tricked - this is a *C library*, not a C++ library. We just take
|
|
|
|
advantage of a select few C++11 compiler features such as templates, and then
|
|
|
|
link against libc.
|
|
|
|
|
2015-07-02 10:48:27 +00:00
|
|
|
### Building
|
|
|
|
|
2015-07-02 22:54:36 +00:00
|
|
|
Install the dependencies:
|
|
|
|
|
|
|
|
* cmake
|
|
|
|
* ALSA library (optional)
|
|
|
|
* libjack2 (optional)
|
|
|
|
* libpulseaudio (optional)
|
|
|
|
|
2015-07-02 10:48:27 +00:00
|
|
|
```
|
2015-07-02 22:54:36 +00:00
|
|
|
mkdir build
|
|
|
|
cd build
|
|
|
|
cmake ..
|
|
|
|
make
|
|
|
|
sudo make install
|
2015-07-02 10:48:27 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
### Building With MXE
|
|
|
|
|
|
|
|
You can build libsoundio with [mxe](http://mxe.cc/). Follow the
|
|
|
|
[requirements](http://mxe.cc/#requirements) section to install the
|
|
|
|
packages necessary on your system. Then somewhere on your file system:
|
|
|
|
|
|
|
|
```
|
2015-07-02 22:54:36 +00:00
|
|
|
git clone https://github.com/mxe/mxe
|
|
|
|
cd mxe
|
|
|
|
make gcc
|
2015-07-02 10:48:27 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Then in the libsoundio source directory (replace "/path/to/mxe" with the
|
|
|
|
appropriate path):
|
|
|
|
|
|
|
|
```
|
2015-07-02 22:54:36 +00:00
|
|
|
mkdir build-win
|
|
|
|
cd build-win
|
|
|
|
cmake .. -DCMAKE_TOOLCHAIN_FILE=/path/to/mxe/usr/i686-w64-mingw32.static/share/cmake/mxe-conf.cmake
|
|
|
|
make
|
2015-07-02 10:48:27 +00:00
|
|
|
```
|
|
|
|
|
2015-06-30 20:49:36 +00:00
|
|
|
## Roadmap
|
|
|
|
|
2015-07-04 10:08:15 +00:00
|
|
|
0. pipe record to playback example working with dummy linux, osx, windows
|
|
|
|
0. pipe record to playback example working with pulseaudio linux
|
|
|
|
0. implement CoreAudio (OSX) backend, get examples working
|
|
|
|
0. implement DirectSound (Windows) backend, get examples working
|
|
|
|
0. implement ALSA (Linux) backend, get examples working
|
|
|
|
0. implement JACK backend, get examples working
|
2015-07-02 09:53:08 +00:00
|
|
|
0. Avoid calling `panic` in PulseAudio.
|
2015-07-04 10:08:15 +00:00
|
|
|
0. implement ASIO (Windows) backend, get examples working
|
2015-07-02 22:54:36 +00:00
|
|
|
0. clean up API and improve documentation
|
|
|
|
0. use a documentation generator and host the docs somewhere
|
2015-07-03 02:15:09 +00:00
|
|
|
0. -fvisibility=hidden and then explicitly export stuff
|
2015-07-04 10:08:15 +00:00
|
|
|
0. Integrate into libgroove and test with Groove Basin
|
|
|
|
0. Consider testing on FreeBSD
|
2015-07-01 08:02:44 +00:00
|
|
|
|
|
|
|
## Planned Uses for libsoundio
|
|
|
|
|
|
|
|
* [Genesis](https://github.com/andrewrk/genesis)
|
|
|
|
* [libgroove](https://github.com/andrewrk/libgroove) ([Groove Basin](https://github.com/andrewrk/groovebasin))
|