Skip to content

Commit

Permalink
fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Igigog committed Oct 23, 2023
1 parent eeb50d6 commit d61ceca
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src-tauri/resources/oratory_15.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"preprocessing": {
"preamp": -4.1,
"postEQGain": 3.0,
"post_eq_gain": 3.0,
"reverse_stereo": true
},
"filters": [
Expand Down
4 changes: 2 additions & 2 deletions src-tauri/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ pub trait Command {
#[allow(dead_code)]
pub enum StructureTypes {
// Commands/Responses, these are container TLVs. The Value will be a set of TLV structures.
OK = 0, // Standard response when a command was successful
NOK, // Standard error response
Ok = 0, // Standard response when a command was successful
Nok, // Standard error response
FlashHeader, // A special container for the config stored in flash. Hopefully there is some useful
// metadata in here to allow us to migrate an old config to a new version.
GetVersion, // Returns the current config version, and the minimum supported version so clients
Expand Down
16 changes: 10 additions & 6 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ use std::time::Duration;
use tauri::State;
// Window shadow support
use tauri::Manager;

#[allow(unused_imports)]
use window_shadows::set_shadow;

// Logging
Expand Down Expand Up @@ -123,15 +125,15 @@ fn find_configuration_endpoints<T: UsbContext>(
#[derive(Serialize, Deserialize, Default, Debug)]
pub struct Preprocessing {
preamp: f32,
postEQGain: f32,
post_eq_gain: f32,
reverse_stereo: bool,
}

impl Preprocessing {
fn new(preamp: f32, postEQGain: f32, reverse_stereo: bool) -> Self {
fn new(preamp: f32, post_eq_gain: f32, reverse_stereo: bool) -> Self {
Preprocessing {
preamp: preamp.log10() * 20.0,
postEQGain: postEQGain.log10() * 20.0,
post_eq_gain: post_eq_gain.log10() * 20.0,
reverse_stereo,
}
}
Expand All @@ -146,7 +148,7 @@ impl Preprocessing {

/* Send the post-EQ gain value from the UI. */
preprocessing_payload
.extend_from_slice(&(f32::powf(10.0, self.postEQGain / 20.0) - 1.0).to_le_bytes());
.extend_from_slice(&(f32::powf(10.0, self.post_eq_gain / 20.0) - 1.0).to_le_bytes());

preprocessing_payload.push(self.reverse_stereo as u8);
preprocessing_payload.extend_from_slice(&[0u8; 3]);
Expand Down Expand Up @@ -342,10 +344,10 @@ fn load_config(connection_state: State<'_, Mutex<ConnectionState>>) -> Result<Co
x if x == StructureTypes::PreProcessingConfiguration as u16 => {
// +1 to maintain compatability with old firmwares
let preamp = cur.read_f32::<LittleEndian>().unwrap() + 1.0;
let postEQGain = cur.read_f32::<LittleEndian>().unwrap() + 1.0;
let post_eq_gain = cur.read_f32::<LittleEndian>().unwrap() + 1.0;
let reverse_stereo = cur.read_u8().unwrap() != 0;

cfg.preprocessing = Preprocessing::new(preamp, postEQGain, reverse_stereo);
cfg.preprocessing = Preprocessing::new(preamp, post_eq_gain, reverse_stereo);
let _ = cur.seek(SeekFrom::Current(3)); // reserved bytes
}
x if x == StructureTypes::FilterConfiguration as u16 => {
Expand Down Expand Up @@ -563,6 +565,8 @@ fn main() {
),
])
.unwrap();

#[allow(unused_variables)]
let window = app.get_window("main").unwrap();
#[cfg(any(windows, target_os = "macos"))]
set_shadow(&window, true).expect("Unsupported platform!");
Expand Down
13 changes: 9 additions & 4 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,13 @@ export default {
config.preprocessing.reverse_stereo = config.preprocessing.reverseStereo
delete config.preprocessing.reverseStereo
}
if (!("postEQGain" in config.preprocessing)) {
config.preprocessing.postEQGain = 0;
if ("postEQGain" in config.preprocessing) {
config.preprocessing.post_eq_gain = config.preprocessing.postEQGain;
delete config.preprocessing.postEQGain;
}
if (!("post_eq_gain" in config.preprocessing)) {
config.preprocessing.post_eq_gain = 0;
}
if (semver.lt(config.version, "0.0.4")) {
// Migrate preamp to db value
Expand Down Expand Up @@ -232,7 +237,7 @@ export default {
var sendConfig = {
"preprocessing": {
"preamp": this.tabs[this.tab].preprocessing.preamp,
"postEQGain": this.tabs[this.tab].preprocessing.postEQGain,
"post_eq_gain": this.tabs[this.tab].preprocessing.post_eq_gain,
"reverse_stereo": this.tabs[this.tab].preprocessing.reverse_stereo
},
"filters": this.tabs[this.tab].filters,
Expand Down Expand Up @@ -546,7 +551,7 @@ export default {
<div class="column q-gutter-md q-ma-none">
<PreProcessingCardVue
v-model:preamp="t.preprocessing.preamp"
v-model:postEQGain="t.preprocessing.postEQGain"
v-model:post_eq_gain="t.preprocessing.post_eq_gain"
v-model:reverse_stereo="t.preprocessing.reverse_stereo"
v-model:expansion="t.state.expanded[0]"
/>
Expand Down
8 changes: 4 additions & 4 deletions src/components/PreProcessingCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ export default {
},
props: {
preamp: ref(0),
postEQGain: ref(0),
post_eq_gain: ref(0),
reverse_stereo: ref(false),
expansion: ref(Boolean)
},
emits: ['update:preamp', 'update:postEQGain', 'update:reverse_stereo', 'update:expansion']
emits: ['update:preamp', 'update:post_eq_gain', 'update:reverse_stereo', 'update:expansion']
}
</script>
<template>
Expand Down Expand Up @@ -46,9 +46,9 @@ export default {
<div class="row justify-start items-center q-gutter-sm">
<q-chip icon="volume_up" class="control-label" color=secondary text-color=white>Post-EQ Gain</q-chip>
</div>
<q-slider :model-value="postEQGain" @update:model-value="(value) => $emit('update:postEQGain', value)"
<q-slider :model-value="post_eq_gain" @update:model-value="(value) => $emit('update:post_eq_gain', value)"
:min="0" :max="9" :step="0.1" :markers="3" :marker-labels="postEQGainMarkerLabel"
:label-value="postEQGain + 'dB'" label />
:label-value="post_eq_gain + 'dB'" label />
</q-item-section>
</q-item>
<q-checkbox label="Reverse Stereo" :model-value="reverse_stereo"
Expand Down

0 comments on commit d61ceca

Please sign in to comment.