basic-reverb

Crates.iobasic-reverb
lib.rsbasic-reverb
version0.1.3
sourcesrc
created_at2023-11-23 23:35:39.161237
updated_at2023-11-28 14:27:31.435153
descriptionA Rust implementation of the reverb presented at "Let's Write A Reverb"
homepagehttps://github.com/yolisses/basic-reverb
repositoryhttps://github.com/yolisses/basic-reverb
max_upload_size
id1046605
size14,520
Ulisses Albuquerque (yolisses)

documentation

README

Basic Reverb

A Rust implementation of the reverb presented at Let's Write A Reverb. It was made basically translating the reverb example code.
It has differences tough:

  • It has a fixed number of channels
  • It does not include the examples of intermediary steps to come up with the final reverb.
  • It uses a simpler delay (the original it is part of a separate library).
  • It doesn't have the configure functions so the sample rate can't be changed once set.

Usage example

use basic_reverb::MonoBasicReverb;
use std::path::Path;
// wavers is not included on basic-reverb
use wavers::{write, Wav};

fn main() {
    let fp: &Path = &Path::new("path/to/the/input.wav");
    let out_fp: &Path = &Path::new("path/to/the/output.wav");

    let mut wav: Wav<f32> = Wav::from_path(fp).unwrap();
    let input_samples: &mut [f32] = &mut wav.read().unwrap();
    let sample_rate = wav.sample_rate();
    // to simplify, just mono audio
    let n_channels = 1;

    let room_size_ms = 100.;
    let rt60 = 10.;
    let dry = 0.;
    let wet = 1.;

    // a fixed sample rate is used to improve performance
    const SAMPLE_RATE: u32 = 44100;

    // should be a power of 2
    const CHANNELS: usize = 8;

    let mut basic_reverb: MonoBasicReverb<CHANNELS, SAMPLE_RATE> =
        MonoBasicReverb::new(room_size_ms, rt60, dry, wet);

    for i in 0..input_samples.len() {
        let input_sample = input_samples[i];
        let output_sample = basic_reverb.process_sample(input_sample as f64);
        input_samples[i] = output_sample as f32;
    }

    write(out_fp, input_samples, sample_rate, n_channels).unwrap();
}
Commit count: 74

cargo fmt