aboutsummaryrefslogtreecommitdiffstats
path: root/mumd
diff options
context:
space:
mode:
Diffstat (limited to 'mumd')
-rw-r--r--mumd/Cargo.toml14
-rw-r--r--mumd/src/audio.rs11
2 files changed, 17 insertions, 8 deletions
diff --git a/mumd/Cargo.toml b/mumd/Cargo.toml
index 4dfd515..8c6958c 100644
--- a/mumd/Cargo.toml
+++ b/mumd/Cargo.toml
@@ -1,12 +1,14 @@
[package]
name = "mumd"
-version = "0.2.0"
+version = "0.3.0"
authors = ["Gustav Sörnäs <gustav@sornas.net>",
"Eskil Queseth <eskilq@kth.se>"]
-license = "MIT"
edition = "2018"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+description = """
+Mumble client daemon.
+"""
+repository = "https://github.com/sornas/mum"
+license = "MIT"
[features]
default = ["notifications"]
@@ -14,11 +16,11 @@ default = ["notifications"]
notifications = ["libnotify"]
[dependencies]
-mumlib = { path = "../mumlib" }
+mumlib = { version = "0.3", path = "../mumlib" }
argparse = "0.2"
+cpal = "0.13"
bytes = "1.0"
-cpal = { git = "https://github.com/RustAudio/cpal" }
dasp_interpolate = { version = "0.11", features = ["linear"] }
dasp_signal = "0.11"
futures = "0.3"
diff --git a/mumd/src/audio.rs b/mumd/src/audio.rs
index 9e8bd6e..0666268 100644
--- a/mumd/src/audio.rs
+++ b/mumd/src/audio.rs
@@ -231,12 +231,19 @@ impl Audio {
.map(|e| cpal::Sample::to_f32(&e.unwrap()))
.collect::<Vec<_>>(),
};
- let mut signal = signal::from_iter(samples.iter().cloned());
+ let iter: Box<dyn Iterator<Item = f32>> = match spec.channels {
+ 1 => Box::new(samples.into_iter().flat_map(|e| vec![e, e])),
+ 2 => Box::new(samples.into_iter()),
+ _ => unimplemented!() // TODO handle gracefully (this might not even happen)
+ };
+ let mut signal = signal::from_interleaved_samples_iter::<_, [f32; 2]>(iter);
let interp = Linear::new(signal.next(), signal.next());
let samples = signal
.from_hz_to_hz(interp, spec.sample_rate as f64, SAMPLE_RATE as f64)
.until_exhausted()
- .collect::<Vec<_>>();
+ // if the source audio is stereo and is being played as mono, discard the right audio
+ .flat_map(|e| if output_config.channels == 1 { vec![e[0]] } else { e.to_vec() })
+ .collect::<Vec<f32>>();
(*event, samples)
})
.collect();