diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 17 | ||||
-rw-r--r-- | src/parsing/equalizer_apo.lalrpop | 2 | ||||
-rw-r--r-- | src/parsing/equalizer_apo.rs | 4 | ||||
-rw-r--r-- | src/utils.rs | 2 |
4 files changed, 18 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs index 171fe3c..8edc760 100644 --- a/src/main.rs +++ b/src/main.rs | |||
@@ -9,6 +9,7 @@ extern crate failure; | |||
9 | extern crate clap; | 9 | extern crate clap; |
10 | extern crate clap_log_flag; | 10 | extern crate clap_log_flag; |
11 | extern crate clap_verbosity_flag; | 11 | extern crate clap_verbosity_flag; |
12 | #[macro_use] | ||
12 | extern crate structopt; | 13 | extern crate structopt; |
13 | 14 | ||
14 | mod dbus_api; | 15 | mod dbus_api; |
@@ -109,7 +110,17 @@ impl Filter { | |||
109 | } | 110 | } |
110 | } | 111 | } |
111 | 112 | ||
112 | fn main() -> Result<(), Error> { | 113 | fn main() { |
114 | match start() { | ||
115 | Ok(()) => (), | ||
116 | Err(err) => { | ||
117 | eprintln!("Error: {}", err); | ||
118 | std::process::exit(-1); | ||
119 | } | ||
120 | } | ||
121 | } | ||
122 | |||
123 | fn start() -> Result<(), Error> { | ||
113 | let args = Cli::from_args(); | 124 | let args = Cli::from_args(); |
114 | args.log.log_all(args.verbose.log_level())?; | 125 | args.log.log_all(args.verbose.log_level())?; |
115 | 126 | ||
@@ -142,8 +153,8 @@ fn load(args: LoadCli) -> Result<(), Error> { | |||
142 | 153 | ||
143 | let filter = if args.file == "-" { | 154 | let filter = if args.file == "-" { |
144 | let stdin = io::stdin(); | 155 | let stdin = io::stdin(); |
145 | let mut lock = stdin.lock(); | 156 | let mut handle = stdin.lock(); |
146 | read_filter(&mut lock)? | 157 | read_filter(&mut handle)? |
147 | } else { | 158 | } else { |
148 | let mut file = File::open(args.file)?; | 159 | let mut file = File::open(args.file)?; |
149 | read_filter(&mut file)? | 160 | read_filter(&mut file)? |
diff --git a/src/parsing/equalizer_apo.lalrpop b/src/parsing/equalizer_apo.lalrpop index b1faad9..39dda67 100644 --- a/src/parsing/equalizer_apo.lalrpop +++ b/src/parsing/equalizer_apo.lalrpop | |||
@@ -6,7 +6,7 @@ grammar; | |||
6 | 6 | ||
7 | pub Main: Filter = { | 7 | pub Main: Filter = { |
8 | <preamp: Preamp> <eq: Eq> => { | 8 | <preamp: Preamp> <eq: Eq> => { |
9 | let coefficients: Vec<_> = eq.1.iter().map(|decibel| 10f64.powf(decibel / 10f64)).collect(); | 9 | let coefficients: Vec<_> = eq.1.iter().map(|decibel| 10f64.powf(decibel / 10f64).sqrt()).collect(); |
10 | // TODO: add decibel_to_ratio conversion function | 10 | // TODO: add decibel_to_ratio conversion function |
11 | let preamp = 10f64.powf(preamp / 10f64); | 11 | let preamp = 10f64.powf(preamp / 10f64); |
12 | Filter { preamp, frequencies: eq.0, coefficients } | 12 | Filter { preamp, frequencies: eq.0, coefficients } |
diff --git a/src/parsing/equalizer_apo.rs b/src/parsing/equalizer_apo.rs index 3fab396..a24cf99 100644 --- a/src/parsing/equalizer_apo.rs +++ b/src/parsing/equalizer_apo.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | // auto-generated: "lalrpop 0.15.2" | 1 | // auto-generated: "lalrpop 0.15.2" |
2 | // sha256: 81b6fa5856d7887b20715c2c7f6137db1927ece087e2db9f4bf1fcd8943365c5 | 2 | // sha256: a735e8f9bd5cf5f3aac915d12b24752d366481c3952258e22871eef395f44 |
3 | use ::Filter; | 3 | use ::Filter; |
4 | use std::str::FromStr; | 4 | use std::str::FromStr; |
5 | #[allow(unused_extern_crates)] | 5 | #[allow(unused_extern_crates)] |
@@ -880,7 +880,7 @@ fn __action1< | |||
880 | ) -> Filter | 880 | ) -> Filter |
881 | { | 881 | { |
882 | { | 882 | { |
883 | let coefficients: Vec<_> = eq.1.iter().map(|decibel| 10f64.powf(decibel / 10f64)).collect(); | 883 | let coefficients: Vec<_> = eq.1.iter().map(|decibel| 10f64.powf(decibel / 10f64).sqrt()).collect(); |
884 | // TODO: add decibel_to_ratio conversion function | 884 | // TODO: add decibel_to_ratio conversion function |
885 | let preamp = 10f64.powf(preamp / 10f64); | 885 | let preamp = 10f64.powf(preamp / 10f64); |
886 | Filter { preamp, frequencies: eq.0, coefficients } | 886 | Filter { preamp, frequencies: eq.0, coefficients } |
diff --git a/src/utils.rs b/src/utils.rs index 6d7ae58..66ccae4 100644 --- a/src/utils.rs +++ b/src/utils.rs | |||
@@ -46,7 +46,7 @@ pub fn send_filter(conn_sink: &ConnPath<&Connection>, filter: Filter) -> Result< | |||
46 | Ok(()) | 46 | Ok(()) |
47 | } | 47 | } |
48 | 48 | ||
49 | pub fn read_filter(file: &mut impl io::Read) -> Result<Filter, Error> { | 49 | pub fn read_filter<T>(file: &mut T) -> Result<Filter, Error> where T: io::Read { |
50 | let mut buffer = String::new(); | 50 | let mut buffer = String::new(); |
51 | 51 | ||
52 | info!("Reading filter in GraphicEQ format from the command line"); | 52 | info!("Reading filter in GraphicEQ format from the command line"); |