Updates for evolving LV2 spec. Fixes atom calls (now have atom in name) and state interface
This commit is contained in:
parent
8da1de3091
commit
8a0bcb4610
104
drmr.c
104
drmr.c
@ -280,8 +280,7 @@ static void run(LV2_Handle instance, uint32_t n_samples) {
|
|||||||
LV2_Atom_Forge_Frame seq_frame;
|
LV2_Atom_Forge_Frame seq_frame;
|
||||||
lv2_atom_forge_sequence_head(&drmr->forge, &seq_frame, 0);
|
lv2_atom_forge_sequence_head(&drmr->forge, &seq_frame, 0);
|
||||||
|
|
||||||
LV2_SEQUENCE_FOREACH(drmr->control_port, i) {
|
LV2_ATOM_SEQUENCE_FOREACH(drmr->control_port, ev) {
|
||||||
LV2_Atom_Event* const ev = lv2_sequence_iter_get(i);
|
|
||||||
if (ev->body.type == drmr->uris.midi_event) {
|
if (ev->body.type == drmr->uris.midi_event) {
|
||||||
uint8_t nn;
|
uint8_t nn;
|
||||||
uint8_t* const data = (uint8_t* const)(ev + 1);
|
uint8_t* const data = (uint8_t* const)(ev + 1);
|
||||||
@ -312,13 +311,13 @@ static void run(LV2_Handle instance, uint32_t n_samples) {
|
|||||||
const LV2_Atom* ignvel = NULL;
|
const LV2_Atom* ignvel = NULL;
|
||||||
const LV2_Atom* ignno = NULL;
|
const LV2_Atom* ignno = NULL;
|
||||||
const LV2_Atom* zerop = NULL;
|
const LV2_Atom* zerop = NULL;
|
||||||
lv2_object_get(obj,
|
lv2_atom_object_get(obj,
|
||||||
drmr->uris.kit_path, &path,
|
drmr->uris.kit_path, &path,
|
||||||
drmr->uris.sample_trigger, &trigger,
|
drmr->uris.sample_trigger, &trigger,
|
||||||
drmr->uris.velocity_toggle, &ignvel,
|
drmr->uris.velocity_toggle, &ignvel,
|
||||||
drmr->uris.note_off_toggle, &ignno,
|
drmr->uris.note_off_toggle, &ignno,
|
||||||
drmr->uris.zero_position, &zerop,
|
drmr->uris.zero_position, &zerop,
|
||||||
0);
|
0);
|
||||||
if (path) {
|
if (path) {
|
||||||
int reqPos = (drmr->curReq+1)%REQ_BUF_SIZE;
|
int reqPos = (drmr->curReq+1)%REQ_BUF_SIZE;
|
||||||
char *tmp = NULL;
|
char *tmp = NULL;
|
||||||
@ -419,14 +418,16 @@ static void cleanup(LV2_Handle instance) {
|
|||||||
free(instance);
|
free(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
void save_state(LV2_Handle instance,
|
static LV2_State_Status
|
||||||
LV2_State_Store_Function store,
|
save_state(LV2_Handle instance,
|
||||||
void* handle,
|
LV2_State_Store_Function store,
|
||||||
uint32_t flags,
|
void* handle,
|
||||||
const LV2_Feature *const * features) {
|
uint32_t flags,
|
||||||
|
const LV2_Feature *const * features) {
|
||||||
DrMr *drmr = (DrMr*)instance;
|
DrMr *drmr = (DrMr*)instance;
|
||||||
LV2_State_Map_Path* map_path = NULL;
|
LV2_State_Map_Path* map_path = NULL;
|
||||||
int32_t flag;
|
int32_t flag;
|
||||||
|
LV2_State_Status stat = LV2_STATE_SUCCESS;
|
||||||
|
|
||||||
while(*features) {
|
while(*features) {
|
||||||
if (!strcmp((*features)->URI, LV2_STATE__mapPath))
|
if (!strcmp((*features)->URI, LV2_STATE__mapPath))
|
||||||
@ -436,52 +437,53 @@ void save_state(LV2_Handle instance,
|
|||||||
|
|
||||||
if (map_path == NULL) {
|
if (map_path == NULL) {
|
||||||
fprintf(stderr,"Host does not support map_path, cannot save state\n");
|
fprintf(stderr,"Host does not support map_path, cannot save state\n");
|
||||||
return;
|
return LV2_STATE_ERR_NO_FEATURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* mapped_path = map_path->abstract_path(map_path->handle,
|
char* mapped_path = map_path->abstract_path(map_path->handle,
|
||||||
drmr->current_path);
|
drmr->current_path);
|
||||||
|
|
||||||
if (store(handle,
|
stat = store(handle,
|
||||||
drmr->uris.kit_path,
|
drmr->uris.kit_path,
|
||||||
mapped_path,
|
mapped_path,
|
||||||
strlen(mapped_path) + 1,
|
strlen(mapped_path) + 1,
|
||||||
drmr->uris.string_urid,
|
drmr->uris.string_urid,
|
||||||
LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE))
|
LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
|
||||||
fprintf(stderr,"Store of kit path failed\n");
|
if (stat) return stat;
|
||||||
|
|
||||||
flag = drmr->ignore_velocity?1:0;
|
flag = drmr->ignore_velocity?1:0;
|
||||||
if (store(handle,
|
stat = store(handle,
|
||||||
drmr->uris.velocity_toggle,
|
drmr->uris.velocity_toggle,
|
||||||
&flag,
|
&flag,
|
||||||
sizeof(int32_t),
|
sizeof(int32_t),
|
||||||
drmr->uris.bool_urid,
|
drmr->uris.bool_urid,
|
||||||
LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE))
|
LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
|
||||||
fprintf(stderr,"Store of ignore velocity failed\n");
|
if (stat) return stat;
|
||||||
|
|
||||||
flag = drmr->ignore_note_off?1:0;
|
flag = drmr->ignore_note_off?1:0;
|
||||||
if (store(handle,
|
stat = store(handle,
|
||||||
drmr->uris.note_off_toggle,
|
drmr->uris.note_off_toggle,
|
||||||
&flag,
|
&flag,
|
||||||
sizeof(uint32_t),
|
sizeof(uint32_t),
|
||||||
drmr->uris.bool_urid,
|
drmr->uris.bool_urid,
|
||||||
LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE))
|
LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
|
||||||
fprintf(stderr,"Store of ignore note off failed\n");
|
if (stat) return stat;
|
||||||
|
|
||||||
if (store(handle,
|
stat = store(handle,
|
||||||
drmr->uris.zero_position,
|
drmr->uris.zero_position,
|
||||||
&drmr->zero_position,
|
&drmr->zero_position,
|
||||||
sizeof(int),
|
sizeof(int),
|
||||||
drmr->uris.int_urid,
|
drmr->uris.int_urid,
|
||||||
LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE))
|
LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
|
||||||
fprintf(stderr,"Store of sample zero position failed\n");
|
return stat;
|
||||||
}
|
}
|
||||||
|
|
||||||
void restore_state(LV2_Handle instance,
|
static LV2_State_Status
|
||||||
LV2_State_Retrieve_Function retrieve,
|
restore_state(LV2_Handle instance,
|
||||||
void* handle,
|
LV2_State_Retrieve_Function retrieve,
|
||||||
uint32_t flags,
|
void* handle,
|
||||||
const LV2_Feature *const * features) {
|
uint32_t flags,
|
||||||
|
const LV2_Feature *const * features) {
|
||||||
DrMr* drmr = (DrMr*)instance;
|
DrMr* drmr = (DrMr*)instance;
|
||||||
size_t size;
|
size_t size;
|
||||||
uint32_t type;
|
uint32_t type;
|
||||||
@ -496,7 +498,7 @@ void restore_state(LV2_Handle instance,
|
|||||||
|
|
||||||
if (map_path == NULL) {
|
if (map_path == NULL) {
|
||||||
fprintf(stderr,"Host does not support map_path, cannot restore state\n");
|
fprintf(stderr,"Host does not support map_path, cannot restore state\n");
|
||||||
return;
|
return LV2_STATE_ERR_NO_FEATURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -505,7 +507,7 @@ void restore_state(LV2_Handle instance,
|
|||||||
|
|
||||||
if (!abstract_path) {
|
if (!abstract_path) {
|
||||||
fprintf(stderr,"Found no path in state, not restoring\n");
|
fprintf(stderr,"Found no path in state, not restoring\n");
|
||||||
return;
|
return LV2_STATE_ERR_NO_PROPERTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *kit_path = map_path->absolute_path(map_path->handle,abstract_path);
|
char *kit_path = map_path->absolute_path(map_path->handle,abstract_path);
|
||||||
@ -534,6 +536,8 @@ void restore_state(LV2_Handle instance,
|
|||||||
retrieve(handle, drmr->uris.zero_position, &size, &type, &fgs);
|
retrieve(handle, drmr->uris.zero_position, &size, &type, &fgs);
|
||||||
if (zero_position)
|
if (zero_position)
|
||||||
drmr->zero_position = *zero_position;
|
drmr->zero_position = *zero_position;
|
||||||
|
|
||||||
|
return LV2_STATE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -716,7 +716,7 @@ port_event(LV2UI_Handle handle,
|
|||||||
obj->body.otype == ui->uris.ui_msg) {
|
obj->body.otype == ui->uris.ui_msg) {
|
||||||
// both state and ui_msg are the same at the moment
|
// both state and ui_msg are the same at the moment
|
||||||
const LV2_Atom* path = NULL;
|
const LV2_Atom* path = NULL;
|
||||||
lv2_object_get(obj, ui->uris.kit_path, &path, 0);
|
lv2_atom_object_get(obj, ui->uris.kit_path, &path, 0);
|
||||||
if (path) {
|
if (path) {
|
||||||
char *kitpath = LV2_ATOM_BODY(path);
|
char *kitpath = LV2_ATOM_BODY(path);
|
||||||
char *realp = realpath(kitpath,NULL);
|
char *realp = realpath(kitpath,NULL);
|
||||||
@ -739,7 +739,7 @@ port_event(LV2UI_Handle handle,
|
|||||||
const LV2_Atom* ignvel = NULL;
|
const LV2_Atom* ignvel = NULL;
|
||||||
const LV2_Atom* ignno = NULL;
|
const LV2_Atom* ignno = NULL;
|
||||||
const LV2_Atom* zerop = NULL;
|
const LV2_Atom* zerop = NULL;
|
||||||
lv2_object_get(obj,
|
lv2_atom_object_get(obj,
|
||||||
ui->uris.velocity_toggle, &ignvel,
|
ui->uris.velocity_toggle, &ignvel,
|
||||||
ui->uris.note_off_toggle, &ignno,
|
ui->uris.note_off_toggle, &ignno,
|
||||||
ui->uris.zero_position, &zerop,
|
ui->uris.zero_position, &zerop,
|
||||||
@ -757,7 +757,7 @@ port_event(LV2UI_Handle handle,
|
|||||||
}
|
}
|
||||||
else if (obj->body.otype == ui->uris.midi_info) {
|
else if (obj->body.otype == ui->uris.midi_info) {
|
||||||
const LV2_Atom *midi_atom = NULL;
|
const LV2_Atom *midi_atom = NULL;
|
||||||
lv2_object_get(obj, ui->uris.midi_event, &midi_atom, 0);
|
lv2_atom_object_get(obj, ui->uris.midi_event, &midi_atom, 0);
|
||||||
if(!midi_atom) {
|
if(!midi_atom) {
|
||||||
fprintf(stderr,"Midi info with no midi data\n");
|
fprintf(stderr,"Midi info with no midi data\n");
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user