sdatkinson / NeuralAmpModelerPlugin

Plugin for Neural Amp Modeler
MIT License
1.9k stars 127 forks source link

[BUG] New instance does not remember the directories respectively #315

Open Suzuki-Re opened 1 year ago

Suzuki-Re commented 1 year ago

Describe the bug A new instance of the plugin does not remember the location of the directories respectively, so we need to go back from an IR folder to a NAM folder or vice versa.

To Reproduce Steps to reproduce the behavior:

  1. Load IR (or NAM file) in the Neural Amp Modeler plugin.
  2. Load NAM file (or IR).
  3. Open another NAM plugin.
  4. Select the folder icon leftside on the IR selector (or the folder icon on the NAM selector if you selected IR file in step 2) there.
  5. NAM plugin open the last directory, but not respectively. In this case, the NAM files directory shows up even though we selected the IR folder icon in step 4. In the latter example, IR directory opens.

Expected behavior NAM (including a new instance) should remember the path respectively. In step 5, IR directory need to open. Or is this an intended behavior?

Screenshots

Desktop (please complete the following information):

Sorry if I missed something, thanks!

sdatkinson commented 1 year ago

Thanks for the bug report.

I think that the root cause is because NAM picks its default directory based on where its current file loaded is. But, the plugin instances aren't "listening to each other"--each tracks this info separately.

So I'm not sure I'd call it "intended behavior" (frankly, I haven't considered what I'd intend to have happen cross-instance like this). But, it makes sense given what I recall of the code.

I can think of perhaps writing some information to a plugin cache that might solve this, but I'm not confident it wouldn't have other side-effects that I'm not thinking of at the moment. I need to think harder about it / I'd anticipate that whatever I do would cause someone to discover a bug, so I anticipate this taking more time to resolve than it'd seem.

ahcm commented 1 year ago

Is there a default path? Then it would be easy for the user to link this to where ever wanted to.

sdatkinson commented 1 year ago

When a new plugin instance is spun up, the first call to PromptForDirectory or PromptForFile receives an empty string for the path. iPlug2 defines what is done with that information.

Subsequent calls for the model/IR use the directory that was selected, respectively by getting it from GetSelectedFileDirectory

it would be easy for the user to link this to where ever wanted to.

Sort of true. If you want to re-build the plugin, you could add a line after this that checks if it got a blank answer and, if so, replace it with a default that you specify in the constructor of the object.

However, what I suspect you're asking for is for a way for the user to set this as an option from the GUI, in which case you're still up against the question of needing a place where the plugin has permission to write files on the user's computer so that it can remember, which I don't know the answer for currently.

I'd love to hear if you're able to do some digging to find that out.