[LV2] jalv hacking

Hanspeter Portner ventosus at airpost.net
Sat Aug 29 11:38:43 PDT 2015


On 29.08.2015 19:54, Hermann Meyer wrote:
> 
> 
> Am 29.08.2015 um 19:11 schrieb Hanspeter Portner:
>> On 29.08.2015 17:30, Hermann Meyer wrote:
>>> So what, lets save a state file form the preset to load, and I try:
>>>
>>>>      LILV_FOREACH(nodes, i, presets) {
>>>>          const LilvNode* preset = lilv_nodes_get(presets, i);
>>>>          lilv_world_load_resource(world, preset);
>>>>          LilvNodes* labels = lilv_world_find_nodes(
>>>>                  world, preset, lilv_new_uri(world, LILV_NS_RDFS
>>>> "label"), NULL);
>>>>              if (labels) {
>>>>                  const LilvNode* label = lilv_nodes_get_first(labels);
>>>>                  const char* set =  lilv_node_as_string(label);
>>>>                  if (strcmp
>>>> (set,row.get_value(psets.col_label).c_str()) == 0) {
>>>>                      state = lilv_state_new_from_world(world, &map,
>>>> preset);
>>>>   lilv_state_save(world,&map,&unmap,state,NULL,"tmp/","state.ttl");
>>>>                  }
>>>>                  lilv_nodes_free(labels);
>>>>              }
>>>>     }
>>> and fail. I tried the very same inside of jalv, hacking the required
>>> functions in, but, no avail.
>>> The saved state file remains empty, and jalv segfault, while it isn't a
>>> problem to load the same state  on startup when I didn't try to save it
>>> to file but just load it from the pointer (see my requested feature on
>>> dev.drobilla.net)
>> Here a wild guess:
>>
>> from lilv.h:1223 (v0.20)
>> @param save_dir Directory of files created by plugin during save (or
>>   NULL). If the state will be saved, this should be the bundle directory
>>   later passed to lilv_state_save.
>>
>> There may be a directory path mismatch, as 'lilv_state_from_world'
>> cannot know that (and where) you want to save the state.
>>
>> 'lilv_state_save' apart from writing the 'state.ttl' and 'manifest.ttl'
>> also seems to do some file linking based on the above mentioned path.
>>
>>> Now this is the point, were I need help, How the heck could I save a
>>> statefile from a LilvState* state pionter which otherwise work well, but
>>> is loaded with lilv_state_new_from_world() while the plugin itself isn't
>>> loaded.
>> Does this workaround work any better?
>> * 'lilv_state_new_from_world'
>> * 'lilv_state_to_string'
>> * 'fwrite'
>>
>> 'lilv_state_to_string' does obviously not do any such file linking and
>> thus cannot handle custom plugin state files.
>>
>> Hp
>> _______________________________________________
>>
> Hi Hanspeter
> 
> Jep, that brings me a step forward, I can save the state file this way,
> and it looks good so far.
> Only, jalv cant load it, fail with:
> error: failed to expand CURIE `pset:Preset'
> error: attempt to add quad with NULL field
> error: failed to expand CURIE `lv2:appliesTo'
> error: attempt to add quad with NULL field
> error: failed to expand CURIE `rdfs:label'
> error: attempt to add quad with NULL field
> looks like a manifest file is needed

You need to prepend some turtle prefixes manually,
'lilv_state_to_string' seems to not do this on its own...

* 'lilv_state_new_from_world'
* lilv_state_to_string
* fopen
* fwrite 'missing prefixes'
  @prefix atom: <http://lv2plug.in/ns/ext/atom#> .
  @prefix lv2: <http://lv2plug.in/ns/lv2core#> .
  @prefix pset: <http://lv2plug.in/ns/ext/presets#> .
  @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
  @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
  @prefix state: <http://lv2plug.in/ns/ext/state#> .
  @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
* fwrite 'state string'



More information about the Devel mailing list