#capture #desktop #pcm #pulse-audio #seconds #devices

simple-pulse-desktop-capture

Easily capture PulseAudio PCM audio from the default playback device

2 releases

0.1.1 Feb 12, 2023
0.1.0 Feb 12, 2023

#792 in Audio

24 downloads per month

MIT license

11KB
227 lines

Simple pulse desktop audio capture

Capture PulseAudio desktop audio with ease.

Getting started

This crate exports the DesktopAudioRecorder struct, simply instantiate it with new and call .read_frame() in a loop to start recieving PCM audio data.

Example

This example captures desktop audio and prints the PCM data for 5 seconds before quitting.

use std::time::Instant;
let mut recorder = DesktopAudioRecorder::new("Experiment").unwrap();

let start = Instant::now();

loop {
    match recorder.read_frame() {
        Ok(data) => println!("{:?}", data),
        Err(e) => eprintln!("{}", e)
    };

    if Instant::now().duration_since(start).as_millis() > 5000 {
        break;
    }
}

Dependencies

~2.5MB
~50K SLoC