audio-recorder-rs

Crates.ioaudio-recorder-rs
lib.rsaudio-recorder-rs
version0.1.0
created_at2025-07-13 20:14:05.666332+00
updated_at2025-07-13 20:14:05.666332+00
descriptionCross platform system audio / microphone recording library in Rust
homepagehttps://github.com/DrSh4dow/audio-recorder-rs
repositoryhttps://github.com/DrSh4dow/audio-recorder-rs
max_upload_size
id1750758
size95,322
Daniel Moretti V. (DrSh4dow)

documentation

README

Rust System Audio & Mic audio Recorder (audio-recorder-rs)

Core library for cross-OS system + input audio recording.

Overview

The audio-recorder-rs library provides functionality for recording audio using various configurations. It supports recording from multiple devices, with or without resampling, and is designed to be used in a singleton pattern to ensure only one instance of the recorder is active at any time.

Features

  • Cross-platform support (Windows, macOS, Linux)
  • Auto Resampling
  • Background thread for non-blocking recording

Usage

To use the recorder, create an instance of the Recorder struct and call its start method to begin recording. This will start a background thread that will record audio from the default input device. The start function will return a receiver which acts as a stream to receive the audio data in f32. Call the stop method to stop recording.

use audio_recorder_rs::Recorder;

fn main() {
    let mut recorder = Recorder::new();
    let receiver = recorder.start().expect("Failed to start recording");

    thread::spawn(move || {
      while let Ok(d) = receiver.recv() {
        for sample in d {
          writer.write_sample(sample).ok();
        }
      }
    });

    sleep(Duration::from_secs(5));
    recorder.stop().expect("Failed to stop recording");
}

API

Recorder

  • new() -> Recorder

    • Creates a new instance of the Recorder.
  • start() -> Result<Receiver<TargetFormat>, RecorderError>

    • Starts the recording process and returns a receiver for the audio data stream.
  • stop() -> Result<(), RecorderError>

    • Stops the recording process.
  • get_is_recording() -> bool

    • Returns whether the recorder is currently recording.
  • get_config() -> RecorderConfig

    • Returns the current configuration of the audio output stream.
Commit count: 0

cargo fmt