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.
- Host: GitHub
- URL: https://github.com/tinyalsa/tinyalsa-cxx
- Owner: tinyalsa
- License: mit
- Created: 2017-06-09T19:19:21.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-07-01T23:27:42.000Z (over 5 years ago)
- Last Synced: 2025-04-19T08:34:26.719Z (9 months ago)
- Topics: alsa, audio, cpp, cpp-library, cpp14, cpp14-library, linux, tinyalsa, tinyalsa-cxx
- Language: C++
- Homepage:
- Size: 41 KB
- Stars: 11
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
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
```