An open API service indexing awesome lists of open source software.

https://github.com/tinyalsa/tinyalsa-cxx

A pure C++14 ALSA library with no dependencies.
https://github.com/tinyalsa/tinyalsa-cxx

alsa audio cpp cpp-library cpp14 cpp14-library linux tinyalsa tinyalsa-cxx

Last synced: 8 months ago
JSON representation

A pure C++14 ALSA library with no dependencies.

Awesome Lists containing this project

README

          

# tinyalsa-cxx

A paper-thin C++ library for interfacing with ALSA.

### Examples

Reading information on a PCM:

```cxx
tinyalsa::pcm pcm;

auto open_result = pcm.open_capture_device();
if (open_result.failed()) {
std::cerr << open_result << std::endl;
return;
}

std::cout << pcm.get_info();
```

Reading audio data from a PCM:
```cxx
// This is a 16-bit integer stereo buffer.
unsigned short int frames[1024];
unsigned int frame_count = 2;

// Error checking omitted for brevity.
tinyalsa::interleaved_pcm_reader pcm_reader;
pcm_reader.open(); // Choose the device to open.
pcm_reader.setup(); // Apply hardware parameters
pcm_reader.prepare(); // Prepare the PCM to be started
pcm_reader.start(); // Begin recording
pcm_reader.read_unformatted(frames, frame_count); // Read recorded data
```