-
Notifications
You must be signed in to change notification settings - Fork 188
Add support for embedding NAM models and IR files in session data #595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
ba35a5e to
974ec7d
Compare
|
macOS version was tested with Fix missing path separator in prepare_resources-mac.py and it seems that it works. |
|
Thanks for your patience with my review. High-level question: what happens when the required files are gone (so the model is loaded from the serialized state), then you try to use the arrows? It feels like this is a new dimension that has to be handled. I don't really like the idea of being responsible for it in this repo. A high-level criticism of the benefits of this: It seems to me that this gives half of what needs to be a whole solution to make sense--all of the cited benefits may be solved for the model files, but they remain unsolved for the main part of a DAW session--the audio (track) files? I don't really agree that a DAW session can truly be called "portable" if these two different file inputs aren't both handled. I'll look at the lines and provide detailed feedback there. [There are a considerable number of changes in this PR.] |
sdatkinson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My overall impression after reading the code is that this is too complicated for what it brings.
The changes below are probably good pieces of advice if you want to use them to improve your fork, but it's sort of surprising how many different places are touched in this PR. Unexpected things may be happening--for example, the sample rate validation.
If that's a problem in the existing code aside from the feature this is trying to introduce, then it'd be worth it to PR those fixes separately (i.e. validate inputs and demonstrate that those validations are failing). But if this is introducing invalid usage of those existing pieces of code, then it's not immediately clear to me how that's happening, and that feels risky for the stability of the plugin.
You definitely want to re-do the unserialization code to follow the existing pattern because that part definitely isn't following the pattern so far and risks breaking existing projects--which would be ironic, given the goal of this PR 🙂
| { | ||
| const auto irData = mStagedIR->GetData(); | ||
| mStagedIR = std::make_unique<dsp::ImpulseResponse>(irData, sampleRate); | ||
| // IR is in error state - discard it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this wise? Feels wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed unnecessary safety checks
| std::unique_ptr<nam::DSP> model = nam::get_dsp(dspPath); | ||
| std::unique_ptr<ResamplingNAM> temp = std::make_unique<ResamplingNAM>(std::move(model), GetSampleRate()); | ||
| temp->Reset(GetSampleRate(), GetBlockSize()); | ||
| std::unique_ptr<ResamplingNAM> temp = std::make_unique<ResamplingNAM>(std::move(model), sampleRate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was there an issue here? Or is this function being called from a different state from before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, there was an issue - sample rate could be 0 during unserialization causing division by zero.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double checked and removed - reverted to use [GetSampleRate()] directly like upstream. No issue, this was an unnecessary change.
NeuralAmpModeler/Unserialization.cpp
Outdated
| mIRPath.Set(static_cast<std::string>(config["IRPath"]).c_str()); | ||
|
|
||
| if (mNAMPath.GetLength()) | ||
| // NEW: Prefer embedded data over file paths |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd like the opposite, but I'm willing to hear your rationale for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. It will check for file first and revert to embedded data if not found.
|
|
||
| mNAMPath.Set(static_cast<std::string>(config["NAMPath"]).c_str()); | ||
| mIRPath.Set(static_cast<std::string>(config["IRPath"]).c_str()); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's going on here is being done wrong. Since you're defining new logic on how to deserialize for the next version, you should be adding new functions for v0.7.14 similar to how the ones for 0.7.12 were added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
created proper _GetConfigFrom_0_7_13() and _UpdateConfigFrom_0_7_13().
cac9298 to
1233630
Compare
|
dc05b69 to
4996eaf
Compare
This enables DAW sessions to be fully portable by storing the actual NAM model and IR file data in the session, not just file paths. Changes: - SerializeState: Embed NAM/IR file data in session chunk - UnserializeState: Load from embedded data if file path not found - New _StageModelFromData/_StageIRFromData functions - Version bump to 0.7.13 with backward-compatible serialization Behavior: - Prefers loading from file path if available (for easy model updates) - Falls back to embedded data if file is missing (for portability) - Fully backward compatible with older session formats
4996eaf to
e3a830d
Compare
|
All review feedback addressed: Removed test-release.yml and prepare_resources-mac.py changes |
…- Store NAM model and IR file contents in plugin state for full preset recall - Add right-click context menu to save embedded data back to disk - Support loading embedded data from serialized state - Maintain backward compatibility with existing presets Changes in submodules: - AudioDSPTools: Add IR memory loading and WAV export - NeuralAmpModelerCore: Add string-based NAM model loading
Description
This PR adds the ability to embed NAM model files (.nam) and impulse response files (.wav) directly into DAW session/project files, making sessions fully portable and self-contained.
Features
Benefits
Implementation
SerializeState()to embed file contents in session dataUnserializeState()to detect and extract embedded files automatically_StageModelFromData()and_StageIRFromData()helper methods for loading from memoryPR Checklist
format.bash?Testing Notes
Windows (Validated ✅)
macOS (Limited Testing⚠️ )
Note: Local macOS testing was not possible due to environmental constraints:
The embedding code itself is platform-independent and uses standard C++ file I/O. The implementation should work on macOS, but comprehensive validation via CI is recommended.
Files Changed
NeuralAmpModeler.cpp: Embedding/extraction logic and helper methods (+260 lines)
NeuralAmpModeler.h: Added mNAMData and mIRData member variables (+8 lines)
Unserialization.cpp: Added embedded data extraction with versioned functions for 0.7.13 (+134 lines)