aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mumd/Cargo.toml7
-rw-r--r--mumd/src/audio.rs22
2 files changed, 16 insertions, 13 deletions
diff --git a/mumd/Cargo.toml b/mumd/Cargo.toml
index f497524..936353a 100644
--- a/mumd/Cargo.toml
+++ b/mumd/Cargo.toml
@@ -13,7 +13,7 @@ default = ["notifications", "sound-effects"]
notifications = ["libnotify"]
-sound-effects = ["hound", "samplerate"]
+sound-effects = ["hound", "dasp_signal", "dasp_interpolate"]
[dependencies]
mumlib = { path = "../mumlib" }
@@ -36,8 +36,9 @@ tokio-util = { version = "0.3", features = ["codec", "udp"] }
libnotify = { version = "1.0", optional = true }
-hound = { version = "3.4.0", optional = true }
-samplerate = { version = "0.2.2", optional = true }
+dasp_signal = { version = "0.11", optional = true }
+dasp_interpolate = { version = "0.11", features = ["linear"], optional = true }
+hound = { version = "3.4", optional = true }
#compressor = "0.3"
#daemonize = "0.4"
diff --git a/mumd/src/audio.rs b/mumd/src/audio.rs
index d86cb84..2c7eead 100644
--- a/mumd/src/audio.rs
+++ b/mumd/src/audio.rs
@@ -5,11 +5,14 @@ pub mod output;
use crate::audio::output::SaturatingAdd;
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
use cpal::{SampleFormat, SampleRate, Stream, StreamConfig};
+#[cfg(feature = "sound-effects")]
+use {
+ dasp_interpolate::linear::Linear,
+ dasp_signal::{self as signal, Signal, interpolate::Converter},
+};
use log::*;
use mumble_protocol::voice::VoicePacketPayload;
use opus::Channels;
-#[cfg(feature = "sound-effects")]
-use samplerate::ConverterType;
use std::collections::hash_map::Entry;
use std::collections::{HashMap, VecDeque};
use std::sync::{Arc, Mutex};
@@ -236,14 +239,13 @@ impl Audio {
.map(|e| cpal::Sample::to_f32(&e.unwrap()))
.collect::<Vec<_>>(),
};
- let samples = samplerate::convert(
- spec.sample_rate,
- SAMPLE_RATE,
- spec.channels as usize,
- ConverterType::SincBestQuality,
- &samples,
- )
- .unwrap();
+ let mut signal = signal::from_iter(samples.iter().cloned());
+ let interp = Linear::new(signal.next(), signal.next());
+ let converter = Converter::from_hz_to_hz(signal,
+ interp,
+ spec.sample_rate.into(),
+ SAMPLE_RATE.into());
+ let samples = converter.until_exhausted().collect::<Vec<_>>();
(*event, samples)
})
.collect();