NeuralAmpModelerPlugin icon indicating copy to clipboard operation
NeuralAmpModelerPlugin copied to clipboard

Add support for embedding NAM models and IR files in session data

Open damiangr opened this issue 3 months ago • 0 comments

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

  • Automatic Embedding: When saving a session, NAM models and IR files are encoded and embedded in the plugin state
  • Automatic Extraction: When loading a session, embedded files are extracted to temporary files and loaded automatically
  • Backward Compatible: Sessions without embedded data continue to work with file paths as before
  • Cross-Platform: Designed to work on Windows, macOS, and Linux

Benefits

  • Share sessions without worrying about missing model/IR files
  • Old projects remain playable even if original files are moved/deleted
  • Team members can open sessions without manual file management

Implementation

  • Modified SerializeState() to embed file contents in session data
  • Modified UnserializeState() to detect and extract embedded files automatically
  • Added _StageModelFromData() and _StageIRFromData() helper methods for loading from memory
  • Maintain backward compatibility with file path references
  • Update AudioDSPTools submodule to include SIGFPE fix (depends on sdatkinson/AudioDSPTools#24)

PR Checklist

  • [x] Did you format your code using format.bash?
  • [x] Does the VST3 plugin pass all of the unit tests in the VST3PluginTestHost?
    • [x] Windows - Validated with pluginval (strictness level 5) - SUCCESS
    • [ ] macOS - Unable to test: VMware Sonoma 14.7.2 + Xcode 16.2 environment has NanoVG/Metal incompatibility issues. Recommend testing via GitHub Actions CI which uses Xcode 15.x.
  • [x] Does your PR add, remove, or rename any plugin parameters? No
  • [x] Does your PR add or remove any graphical assets? No

Testing Notes

Windows (Validated ✅)

  • Build: Visual Studio 2022, x64 Release
  • Validation: pluginval v1.x, strictness level 5
  • Results: All tests passed (audio processing, automation, state save/restore, editor, bus configuration)

macOS (Limited Testing ⚠️)

Note: Local macOS testing was not possible due to environmental constraints:

  • Test environment: VMware Sonoma 14.7.2 + Xcode 16.2
  • Issue: NanoVG/Metal incompatibility causing image loading crashes (not related to this PR)
  • Official v0.7.13 release also crashes in this environment
  • Recommendation: Please test via GitHub Actions CI, which uses Xcode 15.x and should work correctly

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.

Dependencies

  • Depends on sdatkinson/AudioDSPTools#24 (SIGFPE crash fix)

Files Changed

  • AudioDSPTools: Updated submodule to include SIGFPE fix from PR #24
  • NeuralAmpModeler.cpp: Embedding/extraction logic and helper methods (333 lines added)
  • NeuralAmpModeler.h: Added mNAMData and mIRData member variables
  • Unserialization.cpp: Added embedded data extraction logic (75 lines added)

damiangr avatar Nov 05 '25 13:11 damiangr