diff --git a/.gitignore b/.gitignore
index 9cef7ee..6c315c6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,4 +21,8 @@ Cargo.lock
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
-out/
\ No newline at end of file
+out/
+
+# Flamegraph
+*.old
+*.data
\ No newline at end of file
diff --git a/flamegraph.svg b/flamegraph.svg
new file mode 100644
index 0000000..1b92faf
--- /dev/null
+++ b/flamegraph.svg
@@ -0,0 +1,491 @@
+
\ No newline at end of file
diff --git a/src/cli/cli.rs b/src/cli/cli.rs
index 9e9a027..43e9b0e 100644
--- a/src/cli/cli.rs
+++ b/src/cli/cli.rs
@@ -32,8 +32,7 @@ use thiserror::Error;
const DEFAULT_INSTRUMENT: &str = "sin(2*pi()*(442+442*((n+1)/N))*t)";
const DEFAULT_LENGTH: &str = "2^(2-log(2, l))*(60/T)";
-#[derive(Parser)]
-#[cfg_attr(debug_assertions, derive(Debug))]
+#[derive(Debug, Parser)]
#[command(version, author, about)]
pub(super) enum Cli {
/// Play a song
@@ -45,8 +44,7 @@ pub(super) enum Cli {
Memo(Memo),
}
-#[derive(Parser, Clone, Getters)]
-#[cfg_attr(debug_assertions, derive(Debug))]
+#[derive(Debug, Parser, Clone, Getters)]
#[getset(get = "pub(super)")]
pub(super) struct PlayOpts {
/// Use this sheet music [default: stdin]
@@ -104,8 +102,7 @@ impl InputGroup {
}
}
-#[derive(Clone, Copy, AsRef)]
-#[cfg_attr(debug_assertions, derive(Debug))]
+#[derive(Debug, Clone, Copy, AsRef)]
struct Letter(char);
#[derive(Debug, Error)]
@@ -127,8 +124,7 @@ impl FromStr for Letter {
}
}
-#[derive(Clone, Copy, AsRef)]
-#[cfg_attr(debug_assertions, derive(Debug))]
+#[derive(Debug, Clone, Copy, AsRef)]
struct NotALetter(char);
#[derive(Debug, Error)]
@@ -151,8 +147,7 @@ impl FromStr for NotALetter {
}
}
-#[derive(Clone, AsRef)]
-#[cfg_attr(debug_assertions, derive(Debug))]
+#[derive(Debug, Clone, AsRef)]
struct LetterString(String);
#[derive(Debug, Error)]
@@ -218,8 +213,7 @@ where
))
}
-#[derive(Parser, Clone)]
-#[cfg_attr(debug_assertions, derive(Debug))]
+#[derive(Debug, Parser, Clone)]
#[group(required = false, multiple = false)]
pub(super) struct InputGroup {
/// Set the path to your sheet music file [default: stdin]
@@ -245,8 +239,7 @@ impl FromStr for ClonableFile {
}
}
-#[derive(Parser, Clone)]
-#[cfg_attr(debug_assertions, derive(Debug))]
+#[derive(Debug, Parser, Clone)]
pub(super) struct ExportOpts {
#[command(flatten)]
playopts: PlayOpts,
@@ -282,7 +275,6 @@ enum AudioFormat {
Raw(RawAudioFormat),
}
-#[cfg(debug_assertions)]
impl Debug for AudioFormat {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
@@ -403,8 +395,7 @@ fn audio_format_parser(input: &str) -> Result {
.map_err(|e| anyhow!("{e:?}"))
}
-#[derive(Parser, Clone, EnumString, Default)]
-#[cfg_attr(debug_assertions, derive(Debug))]
+#[derive(Debug, Parser, Clone, EnumString, Default)]
#[strum(ascii_case_insensitive)]
enum RawAudioFormat {
ALaw,
@@ -430,8 +421,7 @@ enum RawAudioFormat {
U32Le,
}
-#[derive(Parser, Clone)]
-#[cfg_attr(debug_assertions, derive(Debug))]
+#[derive(Debug, Parser, Clone)]
pub(super) enum Memo {
Syntax,
#[command(subcommand)]
@@ -439,8 +429,7 @@ pub(super) enum Memo {
Formats,
}
-#[derive(Parser, Clone)]
-#[cfg_attr(debug_assertions, derive(Debug))]
+#[derive(Debug, Parser, Clone)]
pub(super) enum Example {
List,
N { id: u8 },
diff --git a/src/cli/main.rs b/src/cli/main.rs
index 81b3f51..470988f 100644
--- a/src/cli/main.rs
+++ b/src/cli/main.rs
@@ -1,5 +1,5 @@
mod cli;
-use std::{collections::HashMap, io::read_to_string};
+use std::{collections::HashMap, io::read_to_string, iter::once};
use anyhow::{Context as _, anyhow};
use bliplib::{
@@ -25,7 +25,13 @@ fn main() -> anyhow::Result<()> {
let sink = Sink::try_new(&stream_handle).context("Epic audio playback failure")?;
debug!("audio sink acquired");
- let default_variables = HashMap::from([('l', 4f64), ('L', 0.0), ('t', 0.0)]);
+ let default_variables = HashMap::from([
+ ('l', 4f64),
+ ('L', 0.0),
+ ('t', 0.0),
+ ('T', 60.0),
+ ('N', opts.notes().len() as f64),
+ ]);
debug!("building parser");
let parser = Parser::new(
@@ -58,7 +64,9 @@ fn main() -> anyhow::Result<()> {
.map(|(a, b)| (*a, *b))
.chain(default_variables),
opts.instrument().clone(),
- opts.slopes().map(|(_, (a, b))| (*a, b.clone())),
+ opts.slopes()
+ .map(|(_, (a, b))| (*a, b.clone()))
+ .chain(once(('L', opts.length().clone()))),
));
debug!("compiling to samples");
let samples: Vec = compiler