3 releases

✓ Uses Rust 2018 edition

0.1.2 May 13, 2019
0.1.1 May 13, 2019
0.1.0 Mar 22, 2019

#43 in Audio

17 downloads per month
Used in 2 crates

MIT / BSL-1.0

24KB
511 lines

Wavy

Cross-platform real-time audio recording & playback.

The sound waves are so wavy!

Getting Started

This example records audio and plays it back in real time as it's being recorded. (Make sure to wear headphones to avoid feedback).

use wavy::*;

use std::collections::VecDeque;

fn main() -> Result<(), AudioError> {
    // Connect to the speaker and microphone systems.
    let mut mic = MicrophoneSystem::new(SampleRate::Normal)?;
    let mut speaker = SpeakerSystem::new(SampleRate::Normal)?;

    let mut buffer = VecDeque::new();

    loop {
        // Record some sound.
        mic.record(&mut |_whichmic, l, r| {
            buffer.push_back((l, r));
        });

        // Play that sound.
        speaker.play(&mut || {
            if let Some((lsample, rsample)) = buffer.pop_front() {
                AudioSample::stereo(lsample, rsample)
            } else {
                // Play silence if not enough has been recorded yet.
                AudioSample::stereo(0, 0)
            }
        });
    }
}

Features

  • Linux (ALSA) support.
  • Microphone audio recording.
  • Speaker audio playback.

TODO

  • Audio channel mixing.
  • Windows support.
  • MacOS and iOS support.
  • WASM support.
  • Test on Android.
  • Nintendo Switch support (And other game consoles).
  • Sound from specific direction (Radians) and volume for video games.
  • Surround sound 5.1 support.
  • Audio Resampling.

Links

Dependencies

~193KB