Skip to content

Commit 701820e

Browse files
authored
chore(nam): update nam-rs to 0.3.0 from crates.io (#256)
1 parent b173635 commit 701820e

8 files changed

Lines changed: 46 additions & 17 deletions

File tree

CLAUDE.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,16 @@ Input → [Tuner bypass] → Input Filters (HP/LP) → [Upsample] → Amp Chain
7373

7474
#### rustortion-core
7575
- **`src/amp/chain.rs`** — Ordered list of processing stages.
76-
- **`src/amp/stages/`**10 registered DSP stages: preamp, compressor, noise_gate, tonestack, poweramp, multiband_saturator, level, delay, reverb, eq. Plus utilities: `clipper`, `filter`, `common`.
76+
- **`src/amp/stages/`**11 registered DSP stages: preamp, compressor, noise_gate, tonestack, poweramp, multiband_saturator, level, nam, delay, reverb, eq. Plus utilities: `clipper`, `filter`, `common`.
7777
- **`src/audio/engine.rs`** — Core audio processing loop. Controlled via crossbeam channels.
7878
- **`src/ir/`** — IR cabinet, convolver (FIR/FFT), loader.
79-
- **`src/preset/`** — Preset save/load/delete, `StageConfig` enum, `InputFilterConfig`.
79+
- **`src/nam/`** — NAM model loader and process-global registry (models resolved by name in `NamConfig::to_stage`).
80+
- **`src/preset/`** — Preset save/load/delete, `StageConfig` enum, `InputFilterConfig`. Note: core's `StageConfig` in `stage_config.rs` is **hand-maintained** (the variant list repeats across ~9 match sites) — it is NOT generated by the UI macro.
8081

8182
#### rustortion-ui
8283
- **`src/app.rs`**`SharedApp<B>` — shared state, update(), view(), subscription().
8384
- **`src/backend.rs`**`ParamBackend` trait, `Capabilities`, `ExternalEvent`.
84-
- **`src/stages/mod.rs`**`gui_stage_registry!` macro, `ParamUpdate`, all 10 stage view modules.
85+
- **`src/stages/mod.rs`**`gui_stage_registry!` macro, `ParamUpdate`, all 11 stage view modules.
8586
- **`src/components/`** — Reusable UI components: widgets, dialogs, preset_bar, peak_meter, ir_cabinet_control, minimap, etc.
8687
- **`src/handlers/`** — Portable handlers: preset, hotkey.
8788
- **`src/messages/`** — Message enums for Iced event-driven updates.
@@ -99,16 +100,17 @@ Input → [Tuner bypass] → Input Filters (HP/LP) → [Upsample] → Amp Chain
99100
- **`src/lib.rs`** — nih-plug `Plugin` impl, audio processing, initialization.
100101
- **`src/editor.rs`**`PluginEditor` (nih-plug `Editor` trait) + `PluginApp` (iced_baseview `Application`).
101102
- **`src/backend.rs`**`PluginBackend` implementing `ParamBackend` via `EngineHandle` + `GuiContext`.
102-
- **`src/params.rs`** — Full nih-plug parameter set: global params + 8 slots × 10 stage types.
103+
- **`src/params.rs`** — Full nih-plug parameter set: global params + 8 slots × 11 stage types. (Note: the per-slot stage params are not yet read by `process()` — see REF-Q3/REV-4 in `claude/tasks.md`.)
103104

104105
### Stage Registration (`rustortion-ui/src/stages/mod.rs`)
105106

106-
The `gui_stage_registry!` macro generates `StageType`, `StageConfig`, and `StageMessage` enums plus all boilerplate. Adding a new stage requires:
107+
The `gui_stage_registry!` macro generates the **UI-side** `StageType`, `StageConfig`, and `StageMessage` enums plus boilerplate. Core's `StageConfig` (`rustortion-core/src/preset/stage_config.rs`) is hand-maintained. Adding a new stage requires:
107108
1. Add one line to the macro invocation
108109
2. Create `rustortion-ui/src/stages/new_stage.rs` with config, message, and view implementations
109110
3. Create `rustortion-core/src/amp/stages/new_stage.rs` implementing the `Stage` trait
110-
4. Add i18n keys to EN and ZH_CN in `rustortion-ui/src/i18n/mod.rs`
111-
5. Add slot params to `rustortion-plugin/src/params.rs`
111+
4. Add the variant to `rustortion-core/src/preset/stage_config.rs` (every match site — the compiler will point at them)
112+
5. Add i18n keys to EN and ZH_CN in `rustortion-ui/src/i18n/mod.rs`
113+
6. Add slot params to `rustortion-plugin/src/params.rs`
112114

113115
### Thread Model
114116

@@ -121,6 +123,7 @@ The JACK process callback (standalone) or nih-plug `process()` (plugin) runs on
121123
- **The `gui_stage_registry!` macro** in `rustortion-ui/src/stages/mod.rs` generates boilerplate. Do not hand-write — add one line to the macro invocation instead.
122124
- **Preset JSON format** — each preset is a JSON file in `~/.config/rustortion/presets/`. Structure: `{ "name": "...", "stages": [...], "ir_name": "...", "ir_gain": N, "pitch_shift_semitones": N, "input_filters": {...} }`.
123125
- **IR files** are in `impulse_responses/` and `~/.config/rustortion/impulse_responses/`. Loading is async (off RT thread).
126+
- **NAM models** (`.nam`, WaveNet + LSTM via the `nam-rs` crate) load from a user-configurable folder with rescan; loaded models live in a process-global registry and stages resolve them by name. No rfd file-picker (rfd/gtk3 breaks CI).
124127
- **Clippy is strict** — CI runs `-D warnings -D clippy::all -D clippy::pedantic -D clippy::nursery`.
125128
- **iced_baseview** is a fork at `github.com/OpenSauce/iced_baseview`, upgraded to iced 0.14 crates.io.
126129

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
English | [简体中文](README.zh-CN.md)
55

6-
A guitar amp simulator built in Rust using JACK.
6+
![CI](https://github.com/OpenSauce/rustortion/actions/workflows/ci.yaml/badge.svg)
7+
8+
A guitar and bass amp simulator built in Rust. Runs standalone with JACK, or as a VST3/CLAP plugin in your DAW.
79

810
## Screenshot
911

@@ -12,14 +14,16 @@ A guitar amp simulator built in Rust using JACK.
1214
## Features
1315

1416
- Low-latency audio processing with configurable oversampling (1x–16x)
15-
- 10 DSP stages: preamp (with 12AX7 triode clipper), compressor, tone stack, power amp, noise gate, level, multi-band saturator, delay, reverb, and 16-band graphic EQ
17+
- 11 DSP stages: preamp (with 12AX7 triode clipper), compressor, tone stack, power amp, noise gate, level, multi-band saturator, delay, reverb, 16-band graphic EQ, and NAM (Neural Amp Modeler) model loading (WaveNet + LSTM `.nam` files)
1618
- Impulse response cabinet simulation for both guitar and bass
1719
- Saving and loading presets with keyboard hotkey switching
1820
- Real-time recording capability
1921
- Built-in tuner
2022
- FFT-based pitch shifting for alternate tunings without retuning your instrument
2123
- MIDI controller support
24+
- VST3 and CLAP plugin builds for DAW use (experimental — see [Plugin](#vst3clap-plugin))
2225
- Tabbed GUI with minimap, collapsible stage cards, and input filter controls - built with [Iced](https://github.com/iced-rs/iced)
26+
- English and Simplified Chinese UI
2327

2428
## Requirements
2529

@@ -57,6 +61,15 @@ cargo run --release
5761
> pw-jack cargo run --release
5862
> ```
5963
64+
### VST3/CLAP Plugin
65+
66+
The plugin is experimental and not yet included in releases — build it from source:
67+
68+
```bash
69+
make plugin # builds target/bundled/Rustortion.{clap,vst3}
70+
make plugin-install # copies them into ~/.clap and ~/.vst3
71+
```
72+
6073
## Contributing
6174

6275
This is an experimental project. Feel free to open issues or submit pull requests.

README.zh-CN.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
[English](README.md) | 简体中文
44

5-
一款使用 Rust 和 JACK 构建的吉他音箱模拟器。
5+
![CI](https://github.com/OpenSauce/rustortion/actions/workflows/ci.yaml/badge.svg)
6+
7+
一款使用 Rust 构建的吉他/贝斯音箱模拟器。可作为 JACK 独立应用运行,也可作为 VST3/CLAP 插件在 DAW 中使用。
68

79
## 截图
810

@@ -11,14 +13,16 @@
1113
## 功能特性
1214

1315
- 低延迟音频处理,支持可配置的过采样(1x–16x)
14-
- 10 个 DSP 处理级:前级放大(含 12AX7 三极管削波器)、压缩器、音色堆栈、后级放大、噪声门、电平、多频段饱和器、延迟、混响、16 频段图形均衡器
16+
- 11 个 DSP 处理级:前级放大(含 12AX7 三极管削波器)、压缩器、音色堆栈、后级放大、噪声门、电平、多频段饱和器、延迟、混响、16 频段图形均衡器,以及 NAM(Neural Amp Modeler)模型加载(支持 WaveNet 与 LSTM 的 `.nam` 文件)
1517
- 支持吉他和贝斯的脉冲响应箱体模拟
1618
- 预设的保存与加载,支持键盘快捷键切换
1719
- 实时录音功能
1820
- 内置调音器
1921
- 基于 FFT 的变调功能,无需重新调弦即可切换至不同调音
2022
- MIDI 控制器支持
23+
- VST3 与 CLAP 插件构建,可在 DAW 中使用(实验性 — 参见[插件](#vst3clap-插件)
2124
- 标签式界面,支持缩略图、可折叠级卡片和输入滤波器控制 - 使用 [Iced](https://github.com/iced-rs/iced) 构建
25+
- 界面支持英文与简体中文
2226

2327
## 系统要求
2428

@@ -57,6 +61,15 @@ cargo run --release
5761
> pw-jack cargo run --release
5862
> ```
5963
64+
### VST3/CLAP 插件
65+
66+
插件目前为实验性功能,尚未包含在发布版本中——需从源码构建:
67+
68+
```bash
69+
make plugin # 构建 target/bundled/Rustortion.{clap,vst3}
70+
make plugin-install # 复制到 ~/.clap 与 ~/.vst3
71+
```
72+
6073
## 参与贡献
6174

6275
这是一个实验性项目。欢迎提交 issue 或 pull request。

rustortion-core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ anyhow = "1.0"
1616
rustfft = "6.4"
1717
realfft = "3.5"
1818
arc-swap = "1.8"
19-
nam-rs = "0.2.0"
19+
nam-rs = "0.3.0"
2020

2121
[dev-dependencies]
2222
criterion = { version = "0.8", features = ["html_reports"] }

rustortion-core/src/amp/stages/nam.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ impl NamConfig {
194194
return NamStage::passthrough(input_gain, output_gain, mix);
195195
};
196196

197-
let native_sample_rate = model.sample_rate() as f32;
197+
let native_sample_rate = model.expected_sample_rate() as f32;
198198
if (native_sample_rate - sample_rate).abs() > 1.0 {
199199
// Resampling is intentionally avoided (too expensive on the RT path), so a
200200
// rate mismatch bypasses the model entirely: pass the dry signal through.

rustortion-core/src/nam/loader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl NamLoader {
5858
Ok(model) => {
5959
info!(
6060
"Loaded NAM model '{name}' ({} Hz)",
61-
model.sample_rate() as u32
61+
model.expected_sample_rate() as u32
6262
);
6363
models.insert(name, Arc::new(model));
6464
}

rustortion-ui/src/stages/nam.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pub fn view(idx: usize, cfg: &NamConfig, state: StageViewState) -> Element<'_, M
118118
let info_line: Element<'_, Message> = match model_name.as_deref() {
119119
Some(name) => match registry::get(name) {
120120
Some(model) => {
121-
let native_rate = model.sample_rate() as u32;
121+
let native_rate = model.expected_sample_rate() as u32;
122122
if native_rate.abs_diff(engine_rate) > 1 {
123123
text(format!(
124124
"{}: {native_rate} Hz · {engine_rate} Hz",

0 commit comments

Comments
 (0)