Skip to content
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

Trouble using preset_save #18

Open
kjyv opened this issue Jun 27, 2017 · 14 comments
Open

Trouble using preset_save #18

kjyv opened this issue Jun 27, 2017 · 14 comments

Comments

@kjyv
Copy link

kjyv commented Jun 27, 2017

I've run into a few issues using preset_save and consecutive preset_load:
Saving the current state into a new preset using preset_save 0 "Preset Name" <home>/.lv2/helm.lv2 preset_name.ttl successfully creates files. But in manifest.ttl, the tag is <preset_name.ttl> instead of e.g. <http://url#preset_name>. In preset_name.ttl, the tag is empty <>. If I want to load this preset, I didn't succeed using something like preset_load 0 preset_name or preset_load 0 http://url#preset_name like it works for the factory presets of the synth. I can load the preset if I manually change the titles to the url form.
The other big issue is that I can't read a preset I just saved unless I restart mod-host as it seems to have cached the values/files. It also takes a bit of time to load the first preset, so it appears to get everything once when the first preset_load is called? I'd be ok if it could at least re-read the values from the file every time (with cached preset names).

@falkTX
Copy link
Member

falkTX commented Jun 27, 2017

preset_save takes a bundle and filename, but preset_load takes a URI.
you need to construct the URI like this "file://" + bundlepath + filename.ttl

the new preset is not automatically added to the lv2 world, as you can save it in any random location for any reason.
to make the new preset work without restart, use bundle_add command.

@kjyv
Copy link
Author

kjyv commented Jun 27, 2017

Ah, ok. File-url works for loading (thought I tried that before) but bundle_add doesn't help. The path itself is already found at start since it's within ~/.lv2 but adding it again with bundle_add should re-read the files? It does not seem to have any effect.

@falkTX
Copy link
Member

falkTX commented Jun 27, 2017

The presets are likely cached in mod-host.
If you use bundle_add you should be able to load the new preset, even if when asking mod-host it does not return it.
Since you're the one saving the preset, you know of its existence.

@kjyv
Copy link
Author

kjyv commented Jun 27, 2017

Oh I sure can load the preset, but I wan't to overwrite previous presets and reload them (hence "re-read"). But the values as you say seem to be cached, so I always get the first set of parameters even if the preset has been saved again with different values. How is that handled for mod-ui, as the use case should be the same?

@falkTX
Copy link
Member

falkTX commented Jun 28, 2017

mod-ui does not use mod-host for getting plugin data.
you can invalidating the effect presets data on preset_save. the next call requesting presets will then rescan them.

@kjyv
Copy link
Author

kjyv commented Jun 28, 2017

Ah, ok. I saw that in mod-ui/host.py preset_load and preset_save is called, maybe that is not what I thought. Can you be a bit more specific on how I can invalidate preset data? I'm obviously calling preset_save already to save the preset. A subsequent load does not load the previously saved values. I can also see in host.py (preset_save_replace()) that the previous preset is removed, the lilv function rescan_plugin_presets is called and then after saving, the bundle is added again. Is that what you mean?

@falkTX
Copy link
Member

falkTX commented Jun 28, 2017

invalidate preset data by modifying mod-host code so it deletes the old presets when you save a new one.
that might work for your case, but you'd have to reload the preset list everytime you save.

in mod-ui's case, it never asks mod-host about parameters or presets.
it has its own list, which gets invalidated and rescanned as needed.

@kjyv
Copy link
Author

kjyv commented Jun 28, 2017

Hm, I'd consider it the job of mod-host to be able to save and load parameters without restarting, don't you agree? Also I would prefer not to run a modified version of mod-host. Otherwise I could also read the file directly and set the parameter values using param_set, but thats equally ugly.
A command in mod-host like presets_reload would be fine. I can try adding it and create a pull request if you'd be fine with that.

For mod-ui, I didn't talk about asking about parameters or presets (I don't need that either), just about calling preset_load and save so that a previously saved state becomes active again. Without using those you'd have to set each parameter separately which apparently is not being done.

@falkTX
Copy link
Member

falkTX commented Jun 28, 2017

but mod-host can save and load presets without restarting. mod-ui managing it is the proof of that.
what mod-host doesn't do right now is update its presets cache when asked about which presets are available.

not sure what's the best solution for this. either presets_reload command or automatically delete cached content... or perhaps a new argument to preset_save...

@kjyv
Copy link
Author

kjyv commented Jun 28, 2017

Well, but the problem I experience is exactly this: I can't make mod-host save a preset a) (lets say it already existed), change some parameters and load preset a) again obtaining the previously saved values. What I get instead is the values that preset a) had at the time of starting mod-host. The files are saved fine and after restart, I get the values that were saved last. I have never intended to read a list of preset names, I don't need that.

@kjyv
Copy link
Author

kjyv commented Jul 12, 2017

As per your previous comment, I should not have any issues but I do. Actually, it seems as if the preset itself is cached since I can save to a preset, change some values and then load the new one again if I didn't load this preset name before. After it was loaded once, I can not save new values to it and then load these again, it will always give the values of the initially loaded one.
Looking at effects.c, I can't really find any caching of the presets or parameter values though. Is maybe lilv doing that?
I guess reloading all presets would be unnecessary. I think an option for preset_load that does not read from the cache (but then writes the loaded preset to it) is the most straightforward solution.

@falkTX
Copy link
Member

falkTX commented Jul 12, 2017

Did you use bundle_remove + bundle_add when you re-saved a preset?
That would be the only way to make lilv drop the old values, otherwise yes expect it to have the old values in some kind of cache (in this case I think it's loaded lv2 resources)

@kjyv
Copy link
Author

kjyv commented Jul 13, 2017

I guess I misunderstood you previously (I tried it) but it works fine now. First bundle_remove, then bundle_add then preset_load. Thanks!

@kjyv
Copy link
Author

kjyv commented Jul 18, 2017

Ok, taking back what I said, I got confused a bit about sometimes working, sometimes not.
bundle_remove + bundle_add works only when the preset is loaded through its name including the plugin url (url#preset) like is usually done. When I load them directly through file urls, the bundle doesn't matter and in fact I don't add it usually. The preset cache is invalidated by bundle_remove and the preset can still be loaded after bundle_remove.
I couldn't find out how to load these presets if the path was added as a bundle as they all have an empty tag as described in my initial report. I'm therefore back to zero not being able to load presets again after saving. A proper way to fix this would be to make mod-host save the presets including the uri of the referenced effect instance so the bundle method works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants