Skip to content

Commit

Permalink
cleaned up io. There is still no way to access effects though
Browse files Browse the repository at this point in the history
  • Loading branch information
subalterngames committed Dec 11, 2023
1 parent 2c719f1 commit cfcba04
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 33 deletions.
35 changes: 2 additions & 33 deletions io/src/effects_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl EffectsPanel {
// Increment by an extra delta.
if let EffectType::PitchBend(_) = effect.effect {
let mut incremented = false;
for i in 0..10 {
for i in 0..self.pitch_bend_sensitivity {
if !effect.effect.increment(up) {
if i > 0 {
incremented = true;
Expand Down Expand Up @@ -165,38 +165,7 @@ impl EffectsPanel {
}
}
}

/// Remove an existing effect.
fn remove_effect(state: &mut State) -> Option<Snapshot> {
let s0 = state.clone();
match Self::get_effect_copy(state) {
Some(effect) => {
state
.music
.get_selected_track_mut()
.unwrap()
.effects
.retain(|e| *e != effect);
Some(Snapshot::from_states(s0, state))
}
None => None,
}
}

/// Get a copied of the selected effect.
fn get_effect_copy(state: &State) -> Option<Effect> {
let ve = state.effect_types.get();
match state.music.get_selected_track() {
Some(track) => track
.effects
.iter()
.filter(|e| e.time == state.time.cursor && ve.eq(&e.effect))
.copied()
.next(),
None => None,
}
}


/// Get the selected effect.
fn get_effect(state: &mut State) -> Option<&mut Effect> {
let ve = state.effect_types.get();
Expand Down
6 changes: 6 additions & 0 deletions io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use audio::export::ExportState;
use audio::Conn;
use common::{InputState, Music, PanelType, Paths, PathsState, State};
use edit::edit_file;
use effects_panel::EffectsPanel;
use hashbrown::HashMap;
use ini::Ini;
use input::{Input, InputEvent};
Expand Down Expand Up @@ -87,6 +88,8 @@ pub struct IO {
quit_panel: QuitPanel,
/// The links panel.
links_panel: LinksPanel,
// The effects panel.
effects_panel: EffectsPanel,
/// The active panels prior to exporting audio.
pre_export_panels: Vec<PanelType>,
/// The index of the focused panel prior to exporting audio.
Expand Down Expand Up @@ -174,6 +177,7 @@ impl IO {
let export_settings_panel = ExportSettingsPanel::default();
let quit_panel = QuitPanel::default();
let links_panel = LinksPanel::default();
let effects_panel = EffectsPanel::new(config);
Self {
tts,
music_panel,
Expand All @@ -184,6 +188,7 @@ impl IO {
export_settings_panel,
quit_panel,
links_panel,
effects_panel,
redo: vec![],
undo: vec![],
pre_export_panels: vec![],
Expand Down Expand Up @@ -446,6 +451,7 @@ impl IO {
PanelType::Tracks => &mut self.tracks_panel,
PanelType::Quit => &mut self.quit_panel,
PanelType::Links => &mut self.links_panel,
PanelType::Effects => &mut self.effects_panel
}
}

Expand Down

0 comments on commit cfcba04

Please sign in to comment.