summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/audio.rs1
-rw-r--r--src/lib.rs12
-rw-r--r--src/main.rs10
-rw-r--r--src/transforms.rs3
4 files changed, 19 insertions, 7 deletions
diff --git a/src/audio.rs b/src/audio.rs
index 421c131..e3100ae 100644
--- a/src/audio.rs
+++ b/src/audio.rs
@@ -1,4 +1,3 @@
-extern crate portaudio;
use portaudio as pa;
use std::sync::mpsc::*;
diff --git a/src/lib.rs b/src/lib.rs
index 45b1f91..3331f72 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,7 +1,13 @@
+pub mod transforms;
+
+#[cfg(not(target_os = "emscripten"))]
extern crate gtk;
+#[cfg(not(target_os = "emscripten"))]
extern crate cairo;
-extern crate portaudio;
-
-pub mod transforms;
+#[cfg(not(target_os = "emscripten"))]
pub mod gui;
+
+#[cfg(not(target_os = "emscripten"))]
+extern crate portaudio;
+#[cfg(not(target_os = "emscripten"))]
pub mod audio;
diff --git a/src/main.rs b/src/main.rs
index 91befca..cfc5629 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,11 +1,17 @@
extern crate rusty_microphone;
-use rusty_microphone::*;
-
+#[cfg(not(target_os = "emscripten"))]
fn main() {
+ use rusty_microphone::*;
+
let gui_result = gui::start_gui();
if gui_result.is_err() {
println!("Failed to initialize");
return;
}
}
+
+#[cfg(target_os = "emscripten")]
+fn main() {
+ println!("Hello Emscripten");
+}
diff --git a/src/transforms.rs b/src/transforms.rs
index ceb0bd3..ac83a32 100644
--- a/src/transforms.rs
+++ b/src/transforms.rs
@@ -1,3 +1,4 @@
+
pub fn remove_mean_offset(signal: &[f32]) -> Vec<f32> {
let mean = signal.iter().sum::<f32>()/signal.len() as f32;
signal.iter().map(|x| x - mean).collect()
@@ -169,7 +170,7 @@ pub fn hz_to_midi_number(hz: f32) -> f32 {
pub fn hz_to_cents_error(hz: f32) -> f32 {
let midi_number = hz_to_midi_number(hz);
- let cents = (midi_number * 100.0).round() % 100.0;
+ let cents = (midi_number % 1.0) * 100.0;
if cents >= 50.0 {
cents - 100.0
}