aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml2
-rw-r--r--src/main.rs3
-rw-r--r--src/music.rs16
3 files changed, 21 insertions, 0 deletions
diff --git a/Cargo.toml b/Cargo.toml
index e7c8dd5..4cb93ee 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -30,3 +30,5 @@ resizable = []
music = []
# Compiles to <=32k on linux after UPX with --brute
32k = []
+# Use Stereo Audio
+stereo = ["music"]
diff --git a/src/main.rs b/src/main.rs
index d12447d..714d540 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -32,7 +32,10 @@ pub fn main() {
let desired_spec = AudioSpecDesired {
freq: Some(48_000),
+ #[cfg(feature = "stereo")]
channels: Some(2),
+ #[cfg(not(feature = "stereo"))]
+ channels: Some(1),
samples: Some(8192 as u16),
};
diff --git a/src/music.rs b/src/music.rs
index fe48989..5a33d84 100644
--- a/src/music.rs
+++ b/src/music.rs
@@ -38,6 +38,22 @@ pub fn mmc2r_to_pcm(state: &mut MmC2r) -> Vec<i16> {
destination.push(sample);
}
}
+ // #[cfg(not(feature = "stereo"))]
+ // let destination = {
+ // let stereo = destination;
+ // let mut mono = Vec::<i16>::new();
+ // let mut is_first_stereo_pair = true;
+ // let mut stereo_pair_val = 0 as i16;
+ // for sample in stereo {
+ // if is_first_stereo_pair {
+ // stereo_pair_val = sample;
+ // } else {
+ // mono.push(((sample as i32 + stereo_pair_val as i32) / 2) as i16);
+ // }
+ // is_first_stereo_pair = !is_first_stereo_pair;
+ // }
+ // mono
+ // };
destination
}