Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ Nothing to add in `rustortion-plugin/src/params.rs` — stage parameters are not
(REV-7 remainder).
- **NAM models** (`.nam`, WaveNet + LSTM via `nam-rs`) load from a user folder with rescan, into a
process-global registry; stages resolve them **by name**. No rfd file-picker — rfd/gtk3 breaks CI.
The NAM tab (`rustortion-ui/src/components/nam_browser/`) is a view over the `StageConfig::Nam`
stages in the chain; there is no separate NAM slot, and the Amp tab shows each NAM stage as a link row.
- **IR files** live in `impulse_responses/` and `~/.config/rustortion/impulse_responses/`; loading
is async, off the RT thread. Keep convolver type configurable — FIR beat FFT on the Pi in real
testing, and the TwoStage tail math is numerically wrong until REV-2 lands.
Expand Down
37 changes: 0 additions & 37 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rustortion-core/src/nam/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ mod tests {
assert_eq!(info.includes_cab, None, "{name} must not read as a cab");
}
// The dangerous class: names that mention a cab in order to say there
// isn't one. Reading these as "cab included" makes the card advise
// isn't one. Reading these as "cab included" makes the NAM tab advise
// bypassing the IR, leaving the signal with no cab at all. Note that the
// `-`/`_` normalization is what turns "cab-less" into a bare `cab` token,
// so this is a trap the normalization itself creates.
Expand Down
41 changes: 41 additions & 0 deletions rustortion-core/src/nam/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,44 @@ pub fn available_names() -> Vec<String> {
names.sort();
names
}

/// Every registered model's key and native sample rate in Hz, sorted by key.
///
/// One lock acquisition, so a GUI list needn't call [`get`] per row.
#[must_use]
pub fn catalog() -> Vec<(String, u32)> {
let map = store()
.read()
.unwrap_or_else(std::sync::PoisonError::into_inner);
let mut entries: Vec<(String, u32)> = map
.iter()
.map(|(name, model)| (name.clone(), model.expected_sample_rate() as u32))
.collect();
drop(map);
entries.sort_by(|a, b| a.0.cmp(&b.0));
entries
}

#[cfg(test)]
mod tests {
use super::*;

/// Uses the same fixture dir as the NAM stage parity test, so the two tests
/// leave the process-global registry in the same state whichever runs first.
#[test]
fn catalog_lists_every_model_with_its_native_rate_sorted_by_key() {
let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures");
let loader = NamLoader::new(&dir).expect("fixture dir loads");
init_from_loader(&loader);

let entries = catalog();

let names: Vec<&str> = entries.iter().map(|(k, _)| k.as_str()).collect();
assert_eq!(names, available_names());
assert!(!entries.is_empty(), "fixture model must be listed");
for (key, rate) in &entries {
let model = get(key).expect("listed model is registered");
assert_eq!(*rate, model.expected_sample_rate() as u32);
}
}
}
4 changes: 3 additions & 1 deletion rustortion-plugin/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::params::RustortionParams;
use rustortion_ui::app::{SharedApp, UpdateResult};
use rustortion_ui::backend::ParamBackend;
use rustortion_ui::components::ir_cabinet_control::IrCabinetControl;
use rustortion_ui::components::nam_browser::NamBrowser;
use rustortion_ui::components::peak_meter::PeakMeterDisplay;
use rustortion_ui::components::pitch_shift_control::PitchShiftControl;
use rustortion_ui::handlers::hotkey::HotkeyHandler;
Expand Down Expand Up @@ -150,7 +151,7 @@ impl iced_baseview::Application for PluginApp {
let factory_presets = crate::factory::load_factory_presets();
let mut preset_handler = PresetHandler::new_from_presets(factory_presets);

// Seeded from the params rather than `default()`: the NAM card renders the IR
// Seeded from the params rather than `default()`: the NAM tab renders the IR
// state as a coloured verdict about the signal chain, so a stale `false` here
// means reopening a project with the IR bypassed shows a warning that the
// audio contradicts — and the button offered to fix it would write the value
Expand Down Expand Up @@ -210,6 +211,7 @@ impl iced_baseview::Application for PluginApp {
input_filter_config: params.input_filters(),
oversampling_factor,
is_recording: false,
nam_browser: NamBrowser::default(),
};

// If we have stored stages, restore them directly.
Expand Down
8 changes: 4 additions & 4 deletions rustortion-standalone/src/audio/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ pub struct Manager {
xrun_count: Arc<AtomicU64>,
available_irs: Vec<String>,
ir_load_handle: Option<IrLoadHandle>,
/// Live NAM models directory — the single source of truth the NAM stage
/// card displays and rescans. Updated whenever a rescan succeeds (from the
/// settings dialog or the stage card) so the displayed path never drifts.
/// Live NAM models directory — the single source of truth the NAM tab
/// displays and rescans. Updated whenever a rescan succeeds (from the
/// settings dialog or the NAM tab) so the displayed path never drifts.
nam_dir: Mutex<String>,
}

Expand Down Expand Up @@ -257,7 +257,7 @@ impl Manager {
match load_nam_models(dir) {
Ok(count) => {
// Keep the live directory in sync so `nam_dir()` (the source of
// truth the NAM stage card displays/rescans) reflects the path
// truth the NAM tab displays/rescans) reflects the path
// that was just scanned.
if let Ok(mut d) = self.nam_dir.lock() {
*d = dir.to_string();
Expand Down
63 changes: 53 additions & 10 deletions rustortion-standalone/src/gui/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ use crate::settings::Settings;
use rustortion_ui::app::{SharedApp, UpdateResult};
use rustortion_ui::backend::ParamBackend;
use rustortion_ui::components::ir_cabinet_control::IrCabinetControl;
use rustortion_ui::components::nam_browser::NamBrowser;
use rustortion_ui::components::peak_meter::PeakMeterDisplay;
use rustortion_ui::components::pitch_shift_control::PitchShiftControl;
use rustortion_ui::handlers::hotkey::HotkeyHandler;
use rustortion_ui::handlers::preset::PresetHandler;
use rustortion_ui::i18n;
use rustortion_ui::messages::{HotkeyMessage, Message, MidiMessage, PresetMessage, TunerMessage};
use rustortion_ui::messages::{
HotkeyMessage, Message, MidiMessage, NamTabMessage, PresetMessage, TunerMessage,
};
use rustortion_ui::stages::StageType;
use rustortion_ui::tabs::Tab;

Expand Down Expand Up @@ -149,6 +152,7 @@ impl AmplifierApp {
input_filter_config,
oversampling_factor,
is_recording: false,
nam_browser: NamBrowser::default(),
};

Ok(Self {
Expand Down Expand Up @@ -207,15 +211,7 @@ impl AmplifierApp {
pub fn update(&mut self, message: Message) -> Task<Message> {
// Detect messages that need standalone-side persistence *before*
// shared handles them (because shared may consume the variant).
let needs_collapse_persist = matches!(
message,
Message::AddStage
| Message::RemoveStage(_)
| Message::MoveStageUp(_)
| Message::MoveStageDown(_)
| Message::ToggleStageCollapse(_)
| Message::ToggleAllStagesCollapse
);
let needs_collapse_persist = needs_collapse_persist(&message);

let ir_bypassed_value = match &message {
Message::IrBypassed(b) => Some(*b),
Expand Down Expand Up @@ -432,3 +428,50 @@ impl AmplifierApp {
}
}
}

const fn needs_collapse_persist(message: &Message) -> bool {
matches!(
message,
Message::AddStage
| Message::RemoveStage(_)
| Message::MoveStageUp(_)
| Message::MoveStageDown(_)
| Message::ToggleStageCollapse(_)
| Message::ToggleAllStagesCollapse
| Message::Nam(NamTabMessage::ModelClicked(_))
)
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn chain_layout_changes_persist_the_collapsed_state() {
use rustortion_ui::messages::NamTabMessage;
for message in [
Message::AddStage,
Message::RemoveStage(0),
Message::MoveStageUp(0),
Message::MoveStageDown(0),
Message::ToggleStageCollapse(0),
Message::ToggleAllStagesCollapse,
Message::Nam(NamTabMessage::ModelClicked("a".to_owned())),
] {
assert!(
needs_collapse_persist(&message),
"{message:?} changes the chain layout"
);
}
for message in [
Message::Nam(NamTabMessage::FilterChanged("x".to_owned())),
Message::Nam(NamTabMessage::Rescan),
Message::RebuildTick,
] {
assert!(
!needs_collapse_persist(&message),
"{message:?} does not change the chain layout"
);
}
}
}
1 change: 0 additions & 1 deletion rustortion-ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ edition = "2024"

[dependencies]
iced = { version = "0.14", features = ["tokio"] }
iced_aw = { version = "0.14.1", default-features = false, features = ["menu"] }
rustortion-core = { path = "../rustortion-core" }
serde = { version = "1.0", features = ["derive"] }
anyhow = "1.0"
Expand Down
Loading
Loading