- Factorise DRT_Drummer_URIS & DR_LV2_Map_URIS into new common lv2 files lv2_utils.h & lv2_utils.c,

- Implement Kit_Update_Request & Kit_Update_Reply,
- Update Kit ComboBox on Kit_Update_Reply,
- Need to fix Kit_Update_Reply on async sample load...
This commit is contained in:
Arnaud G. GIBERT 2024-04-10 23:53:45 +02:00
parent 82df708879
commit 0082554711
8 changed files with 540 additions and 131 deletions

View File

@ -92,6 +92,7 @@ typedef short DRT_Status;
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
#include <datastruct.h> #include <datastruct.h>
#include <lv2_utils.h>
#include <lv2_plugin.h> #include <lv2_plugin.h>
#include <lv2_ui.h> #include <lv2_ui.h>

9
go.sh
View File

@ -1,14 +1,15 @@
#!/bin/bash #!/bin/bash
common_src_list="libnode.c datastruct.c" common_src_list="libnode.c datastruct.c"
main_src_list="drummer.c" main_src_list="drummer.c"
common_lv2_src_list="lv2_utils.c"
lv2_src_list="lv2_plugin.c lv2_ui.c" lv2_src_list="lv2_plugin.c lv2_ui.c"
# gtk_includes="-I/usr/include/gtk-3.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/atk-1.0" # gtk_includes="-I/usr/include/gtk-3.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/atk-1.0"
gtk_includes="-I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include/ -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/atk-1.0" gtk_includes="-I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include/ -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/atk-1.0"
includes="-I/usr/include/libxml2 ${gtk_includes}" includes="-I/usr/include/libxml2 ${gtk_includes}"
cflags="-DGTK_DISABLE_DEPRECATED" cflags="-DGTK_DISABLE_DEPRECATED"
for module in ${common_src_list} ${main_src_list} ${lv2_src_list} for module in ${common_src_list} ${main_src_list} ${common_lv2_src_list} ${lv2_src_list}
do do
cmd="gcc -g -c ${cflags} -I. ${includes} -o ${module//.c/.o} -fPIC ${module}" cmd="gcc -g -c ${cflags} -I. ${includes} -o ${module//.c/.o} -fPIC ${module}"
@ -25,12 +26,12 @@ cmd="gcc -g -o drummer ${common_src_list//.c/.o} ${main_src_list//.c/.o} -fPIC $
echo ${cmd} echo ${cmd}
eval ${cmd} eval ${cmd}
cmd="gcc -g -o drummer.so ${common_src_list//.c/.o} lv2_plugin.o -shared -fPIC ${common_libs} ${lv2_libs}" cmd="gcc -g -o drummer.so ${common_src_list//.c/.o} ${common_lv2_src_list//.c/.o} lv2_plugin.o -shared -fPIC ${common_libs} ${lv2_libs}"
echo ${cmd} echo ${cmd}
eval ${cmd} eval ${cmd}
cmd="gcc -g -o drummer_ui.so ${common_src_list//.c/.o} lv2_ui.o -shared -fPIC ${common_libs} ${lv2_libs}" cmd="gcc -g -o drummer_ui.so ${common_src_list//.c/.o} ${common_lv2_src_list//.c/.o} lv2_ui.o -shared -fPIC ${common_libs} ${lv2_libs}"
echo ${cmd} echo ${cmd}
eval ${cmd} eval ${cmd}

View File

@ -72,7 +72,7 @@ DRT_Status DR_LV2_Log_Write( DRT_Log_Type_Id Log_Type_Id, char *Out_Fmt, va_l
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* */ /* */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/*
static inline void DR_LV2_Map_URIS( LV2_URID_Map *Map_Ptr, DRT_Drummer_URIS *URIS) static inline void DR_LV2_Map_URIS( LV2_URID_Map *Map_Ptr, DRT_Drummer_URIS *URIS)
{ {
URIS->Atom_Object = Map_Ptr->map( Map_Ptr->handle, LV2_ATOM__Object); URIS->Atom_Object = Map_Ptr->map( Map_Ptr->handle, LV2_ATOM__Object);
@ -85,14 +85,15 @@ static inline void DR_LV2_Map_URIS( LV2_URID_Map *Map_Ptr, DRT_Drummer_URIS *
URIS->Midi_Event = Map_Ptr->map( Map_Ptr->handle, "http://lv2plug.in/ns/ext/midi#MidiEvent"); URIS->Midi_Event = Map_Ptr->map( Map_Ptr->handle, "http://lv2plug.in/ns/ext/midi#MidiEvent");
URIS->UI_Msg = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#uimsg");
URIS->Atom_EventTransfer = Map_Ptr->map( Map_Ptr->handle, LV2_ATOM__eventTransfer); URIS->Atom_EventTransfer = Map_Ptr->map( Map_Ptr->handle, LV2_ATOM__eventTransfer);
URIS->UI_Msg = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#uimsg");
URIS->UI_Enable = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#uienable"); URIS->UI_Enable = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#uienable");
URIS->UI_Disable = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#uidisable"); URIS->UI_Disable = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#uidisable");
URIS->Kit_Name_Update = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#kitnameupdate"); URIS->Kit_Update_Request = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#kitupdaterequest");
URIS->Kit_Update_Reply = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#kitupdatereply");
URIS->Velocity_Ignore_Flag_Toggle = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#velocitytoggle"); URIS->Velocity_Ignore_Flag_Toggle = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#velocitytoggle");
URIS->Note_Off_Ignore_Flag_Toggle = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#noteofftoggle"); URIS->Note_Off_Ignore_Flag_Toggle = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#noteofftoggle");
@ -109,9 +110,10 @@ static inline void DR_LV2_Map_URIS( LV2_URID_Map *Map_Ptr, DRT_Drummer_URIS *
URIS->sample_add = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#sampleadd"); URIS->sample_add = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#sampleadd");
URIS->sample_remove = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#sampleremove"); URIS->sample_remove = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#sampleremove");
*/ */
/*
} }
*/
@ -132,7 +134,7 @@ DRT_Status DR_LV2_Kit_Sample_Load( DRT_Kit *Kit_Ptr)
if( ( status = DR_Kit_Sample_Load( Kit_Ptr)) == DRS_OK) if( ( status = DR_Kit_Sample_Load( Kit_Ptr)) == DRS_OK)
{ {
DRG_LV2_Base.Kit_Cur_Ptr = Kit_Ptr; DRG_LV2_Base.Kit_Ptr = Kit_Ptr;
cur_node_ptr = Kit_Ptr->Instrument_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Head; cur_node_ptr = Kit_Ptr->Instrument_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Head;
@ -190,12 +192,19 @@ DRT_Status DR_LV2_CurKit_Sample_Load()
DRT_Kit_Id kit_id; DRT_Kit_Id kit_id;
if( DRG_LV2_Base.Kit_Id_New != DRG_LV2_Base.Kit_Id)
{
DRG_LV2_Base.Program_Id_New = DRG_LV2_Base.Kit_Id_New % 128;
DRG_LV2_Base.Bank_Id_MSB_New = ( DRG_LV2_Base.Kit_Id_New / 128) % 128;
DRG_LV2_Base.Bank_Id_LSB_New = ( DRG_LV2_Base.Kit_Id_New / 128) / 128;
}
kit_id = ( DRG_LV2_Base.Bank_Id_LSB_New * 128 + DRG_LV2_Base.Bank_Id_MSB_New) * 128 + DRG_LV2_Base.Program_Id_New; kit_id = ( DRG_LV2_Base.Bank_Id_LSB_New * 128 + DRG_LV2_Base.Bank_Id_MSB_New) * 128 + DRG_LV2_Base.Program_Id_New;
if( kit_id == DRG_LV2_Base.Kit_Id) if( kit_id == DRG_LV2_Base.Kit_Id)
{ {
DR_LOG_INFO_5( "Same kit id: (%d) Bank/Program: (%d/%d/%d) Name: [%s]!", DR_LOG_INFO_5( "Same kit id: (%d) Bank/Program: (%d/%d/%d) Name: [%s]!",
kit_id, DRG_LV2_Base.Bank_Id_LSB_New, DRG_LV2_Base.Bank_Id_MSB_New, DRG_LV2_Base.Program_Id_New, DRG_LV2_Base.Kit_Cur_Ptr->Name); kit_id, DRG_LV2_Base.Bank_Id_LSB_New, DRG_LV2_Base.Bank_Id_MSB_New, DRG_LV2_Base.Program_Id_New, DRG_LV2_Base.Kit_Ptr->Name);
status = DRS_OK; status = DRS_OK;
} }
else else
@ -208,12 +217,12 @@ DRT_Status DR_LV2_CurKit_Sample_Load()
if( DRG_LV2_Base.Kit_Id == DRD_ID_UNKNOWN) if( DRG_LV2_Base.Kit_Id == DRD_ID_UNKNOWN)
{ {
fprintf( stderr, "No Kit available!\n"); fprintf( stderr, "No Kit available!\n");
status=DRS_KO; status = DRS_KO;
} }
else else
{ {
DR_LOG_INFO_5( "Keep kit id: (%d) Bank/Program: (%d/%d/%d) Name: [%s]!", DR_LOG_INFO_5( "Keep kit id: (%d) Bank/Program: (%d/%d/%d) Name: [%s]!",
DRG_LV2_Base.Kit_Id, DRG_LV2_Base.Bank_Id_LSB, DRG_LV2_Base.Bank_Id_MSB, DRG_LV2_Base.Program_Id, DRG_LV2_Base.Kit_Cur_Ptr->Name); DRG_LV2_Base.Kit_Id, DRG_LV2_Base.Bank_Id_LSB, DRG_LV2_Base.Bank_Id_MSB, DRG_LV2_Base.Program_Id, DRG_LV2_Base.Kit_Ptr->Name);
} }
} }
else else
@ -225,9 +234,24 @@ DRT_Status DR_LV2_CurKit_Sample_Load()
DRG_LV2_Base.Bank_Id_MSB = DRG_LV2_Base.Bank_Id_MSB_New; DRG_LV2_Base.Bank_Id_MSB = DRG_LV2_Base.Bank_Id_MSB_New;
DRG_LV2_Base.Program_Id = DRG_LV2_Base.Program_Id_New; DRG_LV2_Base.Program_Id = DRG_LV2_Base.Program_Id_New;
DRG_LV2_Base.Kit_Id = kit_id; DRG_LV2_Base.Kit_Id = kit_id;
DRG_LV2_Base.Kit_Cur_Ptr = Kit_Ptr; DRG_LV2_Base.Kit_Id_New = kit_id;
DRG_LV2_Base.Kit_Ptr = Kit_Ptr;
status = DR_LV2_Kit_Sample_Load( Kit_Ptr); status = DR_LV2_Kit_Sample_Load( Kit_Ptr);
LV2_Atom_Forge_Frame obj_frame;
DR_LOG_INFO_0( "Sample loaded!");
lv2_atom_forge_frame_time( &( DRG_LV2_Base.Forge), 0);
lv2_atom_forge_object( &( DRG_LV2_Base.Forge), &obj_frame, 1, DRG_LV2_Base.URIS.UI_Msg);
lv2_atom_forge_property_head( &( DRG_LV2_Base.Forge), DRG_LV2_Base.URIS.Kit_Update_Reply, 0);
lv2_atom_forge_long( &( DRG_LV2_Base.Forge), DRG_LV2_Base.Kit_Id); // Cur kit Id
lv2_atom_forge_pop( &( DRG_LV2_Base.Forge), &obj_frame);
DR_LOG_INFO_2( "Kit Update Reply: Kit_Id: (%ld) Kit_Name: [%s]", DRG_LV2_Base.Kit_Id, DRG_LV2_Base.Kit_Ptr->Name);
} }
} }
@ -628,7 +652,7 @@ static LV2_Handle DR_LV2_Instantiate( const LV2_Descriptor *LV2_Descripto
DRG_LV2_Base.Map_Ptr = NULL; DRG_LV2_Base.Map_Ptr = NULL;
DRG_LV2_Base.Logger.log = NULL; DRG_LV2_Base.Logger.log = NULL;
DRG_LV2_Base.Kit_Cur_Ptr = NULL; DRG_LV2_Base.Kit_Ptr = NULL;
DRG_LV2_Base.Bank_Id_LSB = -1; DRG_LV2_Base.Bank_Id_LSB = -1;
DRG_LV2_Base.Bank_Id_LSB = -1; DRG_LV2_Base.Bank_Id_LSB = -1;
DRG_LV2_Base.Program_Id = -1; DRG_LV2_Base.Program_Id = -1;
@ -636,6 +660,7 @@ static LV2_Handle DR_LV2_Instantiate( const LV2_Descriptor *LV2_Descripto
DRG_LV2_Base.Bank_Id_MSB_New = 0; DRG_LV2_Base.Bank_Id_MSB_New = 0;
DRG_LV2_Base.Program_Id_New = 0; DRG_LV2_Base.Program_Id_New = 0;
DRG_LV2_Base.Kit_Id = DRD_ID_UNKNOWN; DRG_LV2_Base.Kit_Id = DRD_ID_UNKNOWN;
DRG_LV2_Base.Kit_Id_New = DRD_ID_UNKNOWN;
DRG_LV2_Base.Current_Path = NULL; DRG_LV2_Base.Current_Path = NULL;
DRG_LV2_Base.CurReq = -1; DRG_LV2_Base.CurReq = -1;
@ -1002,20 +1027,20 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples)
LV2_Atom_Forge_Frame set_frame; LV2_Atom_Forge_Frame set_frame;
DR_LOG_INFO_1( "Update Kit Name: [%d]", nn); DR_LOG_INFO_1( "Kit Update Reply: Kit_Id: (%d)", lv2_base_ptr->Kit_Id);
lv2_atom_forge_frame_time( &( DRG_LV2_Base.Forge), 0); lv2_atom_forge_frame_time( &( DRG_LV2_Base.Forge), 0);
lv2_atom_forge_object( &( DRG_LV2_Base.Forge), &set_frame, 1, DRG_LV2_Base.URIS.UI_Msg); lv2_atom_forge_object( &( DRG_LV2_Base.Forge), &set_frame, 1, DRG_LV2_Base.URIS.UI_Msg);
lv2_atom_forge_property_head( &( DRG_LV2_Base.Forge), DRG_LV2_Base.URIS.Kit_Name_Update, 0); lv2_atom_forge_property_head( &( DRG_LV2_Base.Forge), DRG_LV2_Base.URIS.Kit_Update_Reply, 0);
lv2_atom_forge_string( &( DRG_LV2_Base.Forge), "Hello World!", 13); lv2_atom_forge_long( &( DRG_LV2_Base.Forge), lv2_base_ptr->Kit_Id);
lv2_atom_forge_pop( &( DRG_LV2_Base.Forge), &set_frame); lv2_atom_forge_pop( &( DRG_LV2_Base.Forge), &set_frame);
} }
else else
{ {
DR_LOG_INFO_1( "ZZZ Update Kit Name Tab: [%d]", nn); // DR_LOG_INFO_1( "ZZZ Update Kit Name Tab: [%d]", nn);
nn -= base_note; nn -= base_note;
@ -1110,24 +1135,42 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples)
if( obj_ptr->body.otype == lv2_base_ptr->URIS.UI_Msg) if( obj_ptr->body.otype == lv2_base_ptr->URIS.UI_Msg)
{ {
const LV2_Atom *ui_enable = NULL; const LV2_Atom *ui_enable_ptr = NULL;
const LV2_Atom *ui_disable = NULL; const LV2_Atom *ui_disable_ptr = NULL;
const LV2_Atom *kit_update_request_ptr = NULL;
const LV2_Atom *kit_update_reply_ptr = NULL;
lv2_atom_object_get( obj_ptr, lv2_atom_object_get( obj_ptr,
lv2_base_ptr->URIS.UI_Enable, &ui_enable, lv2_base_ptr->URIS.UI_Enable, &ui_enable_ptr,
lv2_base_ptr->URIS.UI_Disable, &ui_disable, lv2_base_ptr->URIS.UI_Disable, &ui_disable_ptr,
lv2_base_ptr->URIS.Kit_Update_Request, &kit_update_request_ptr,
lv2_base_ptr->URIS.Kit_Update_Reply, &kit_update_reply_ptr,
0); 0);
if( ui_enable) if( ui_enable_ptr)
{ {
DRT_Kit_Name *kit_name_tab; LV2_Atom_Forge_Frame obj_frame;
long kit_number;
DR_LOG_INFO_0( "UI Enable!"); DR_LOG_INFO_0( "UI Enable!");
lv2_atom_forge_frame_time( &( DRG_LV2_Base.Forge), 0);
lv2_atom_forge_object( &( DRG_LV2_Base.Forge), &obj_frame, 1, DRG_LV2_Base.URIS.UI_Msg);
lv2_atom_forge_property_head( &( DRG_LV2_Base.Forge), DRG_LV2_Base.URIS.Kit_Update_Reply, 0);
lv2_atom_forge_long( &( DRG_LV2_Base.Forge), DRG_LV2_Base.Kit_Id); // Cur kit Id
lv2_atom_forge_pop( &( DRG_LV2_Base.Forge), &obj_frame);
DR_LOG_INFO_2( "Kit Update Reply: Kit_Id: (%ld) Kit_Name: [%s]", DRG_LV2_Base.Kit_Id, DRG_LV2_Base.Kit_Ptr->Name);
/*
DRT_Kit_Name *kit_name_tab;
long kit_number;
if( ( status = DR_Kits_Name_Get( &kit_name_tab, &kit_number)) != DRS_OK) if( ( status = DR_Kits_Name_Get( &kit_name_tab, &kit_number)) != DRS_OK)
{ {
DR_LOG_ERROR_1( "Can't get kit names: (%d)", status); DR_LOG_ERROR_1( "Can't get kit names: (%d)", status);
@ -1138,7 +1181,7 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples)
LV2_Atom_Forge_Ref ref; LV2_Atom_Forge_Ref ref;
DR_LOG_INFO_3( "Update Kit Name: Nb: (%d) First: [%s] Size: (%ld)", kit_number, kit_name_tab[0].Name, sizeof( DRT_Kit_Name) * kit_number); DR_LOG_INFO_3( "Update Kit Name: Nb: (%d) First: [%s] Size: (%ld)", kit_number, kit_name_tab[0].Name, sizeof( DRT_Kit_Name) * kit_number);
/*
lv2_atom_forge_frame_time( &( DRG_LV2_Base.Forge), 0); lv2_atom_forge_frame_time( &( DRG_LV2_Base.Forge), 0);
lv2_atom_forge_object( &( DRG_LV2_Base.Forge), &obj_frame, 1, DRG_LV2_Base.URIS.UI_Msg); lv2_atom_forge_object( &( DRG_LV2_Base.Forge), &obj_frame, 1, DRG_LV2_Base.URIS.UI_Msg);
@ -1146,7 +1189,7 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples)
lv2_atom_forge_tuple( &( DRG_LV2_Base.Forge), &tup_frame); lv2_atom_forge_tuple( &( DRG_LV2_Base.Forge), &tup_frame);
lv2_atom_forge_long( &( DRG_LV2_Base.Forge), kit_number); // Max number of kit lv2_atom_forge_long( &( DRG_LV2_Base.Forge), kit_number); // Max number of kit
lv2_atom_forge_long( &( DRG_LV2_Base.Forge), DRG_LV2_Base.Kit_Cur_Ptr->Id); // Cur kit Id lv2_atom_forge_long( &( DRG_LV2_Base.Forge), DRG_LV2_Base.Kit_Ptr->Id); // Cur kit Id
// ref = lv2_atom_forge_write( &( DRG_LV2_Base.Forge), &( kit_name_tab[i]), sizeof( DRT_Kit_Name) * kit_number); // ref = lv2_atom_forge_write( &( DRG_LV2_Base.Forge), &( kit_name_tab[i]), sizeof( DRT_Kit_Name) * kit_number);
// DR_LOG_INFO_1( "Forge: KNT Ref: (%lx)", ref); // DR_LOG_INFO_1( "Forge: KNT Ref: (%lx)", ref);
@ -1154,15 +1197,33 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples)
lv2_atom_forge_pop( &( DRG_LV2_Base.Forge), &tup_frame); lv2_atom_forge_pop( &( DRG_LV2_Base.Forge), &tup_frame);
lv2_atom_forge_pop( &( DRG_LV2_Base.Forge), &obj_frame); lv2_atom_forge_pop( &( DRG_LV2_Base.Forge), &obj_frame);
DR_LOG_INFO_3( "Kit Name Update: Kit_Number: (%ld) Kit_Cur_Id: (%ld) Kit_Cur_Name: [%s]", kit_number, DRG_LV2_Base.Kit_Cur_Ptr->Id, DRG_LV2_Base.Kit_Cur_Ptr->Name); DR_LOG_INFO_3( "Kit Name Update: Kit_Number: (%ld) Kit_Id: (%ld) Kit_Name: [%s]", kit_number, DRG_LV2_Base.Kit_Ptr->Id, DRG_LV2_Base.Kit_Ptr->Name);
} }
*/
} }
if( ui_disable)
if( ui_disable_ptr)
{ {
DR_LOG_INFO_0( "UI Disable!"); DR_LOG_INFO_0( "UI Disable!");
} }
if( kit_update_request_ptr)
{
lv2_base_ptr->Kit_Id_New = ( (const LV2_Atom_Long *)kit_update_request_ptr)->body;
DR_LOG_INFO_1( "Kit Update Request: Kit_Id: (%ld)!", lv2_base_ptr->Kit_Id_New);
pthread_cond_signal( &( lv2_base_ptr->Load_Cond));
}
if( kit_update_reply_ptr)
{
DR_LOG_ERROR_0( "Kit Update Reply: This shouldn't be received by me!");
}
/* /*
if( obj_ptr->body.otype == lv2_base_ptr->URIS.ui_msg) if( obj_ptr->body.otype == lv2_base_ptr->URIS.ui_msg)

View File

@ -4,7 +4,7 @@
#ifndef _LV2_PLUGIN_H_ #ifndef _LV2_PLUGIN_H_
#define _LV2_PLUGIN_H_ #define _LV2_PLUGIN_H_
/*
#include "lv2/atom/atom.h" #include "lv2/atom/atom.h"
#include "lv2/atom/forge.h" #include "lv2/atom/forge.h"
#include "lv2/atom/util.h" #include "lv2/atom/util.h"
@ -15,7 +15,7 @@
#include "lv2/midi/midi.h" #include "lv2/midi/midi.h"
#include "lv2/urid/urid.h" #include "lv2/urid/urid.h"
#include "lv2/state/state.h" #include "lv2/state/state.h"
*/
//#include "lv2/lv2plug.in/ns/ext/atom/forge.h" //#include "lv2/lv2plug.in/ns/ext/atom/forge.h"
// util includes atom.h // util includes atom.h
//#include "lv2/lv2plug.in/ns/ext/atom/util.h" //#include "lv2/lv2plug.in/ns/ext/atom/util.h"
@ -200,7 +200,7 @@ typedef enum
} DRT_Port_Index; } DRT_Port_Index;
/*
typedef struct DRT_Drummer_URIS typedef struct DRT_Drummer_URIS
{ {
LV2_URID Atom_Object; LV2_URID Atom_Object;
@ -213,14 +213,15 @@ typedef struct DRT_Drummer_URIS
LV2_URID Midi_Event; LV2_URID Midi_Event;
LV2_URID UI_Msg;
LV2_URID Atom_EventTransfer; LV2_URID Atom_EventTransfer;
LV2_URID UI_Msg;
LV2_URID UI_Enable; LV2_URID UI_Enable;
LV2_URID UI_Disable; LV2_URID UI_Disable;
LV2_URID Kit_Name_Update; LV2_URID Kit_Update_Request;
LV2_URID Kit_Update_Reply;
LV2_URID Velocity_Ignore_Flag_Toggle; LV2_URID Velocity_Ignore_Flag_Toggle;
LV2_URID Note_Off_Ignore_Flag_Toggle; LV2_URID Note_Off_Ignore_Flag_Toggle;
@ -237,7 +238,7 @@ typedef struct DRT_Drummer_URIS
// LV2_URID sample_add; // LV2_URID sample_add;
// LV2_URID sample_remove; // LV2_URID sample_remove;
} DRT_Drummer_URIS; } DRT_Drummer_URIS;
*/
typedef struct DRT_Sample typedef struct DRT_Sample
{ {
@ -284,14 +285,15 @@ typedef struct DRT_LV2_Base
LV2_Log_Logger Logger; LV2_Log_Logger Logger;
// Kit info // Kit info
DRT_Kit *Kit_Cur_Ptr; DRT_Kit *Kit_Ptr;
DRT_Kit_Id Kit_Id;
DRT_Kit_Id Kit_Id_New;
uint8_t Bank_Id_LSB; uint8_t Bank_Id_LSB;
uint8_t Bank_Id_MSB; uint8_t Bank_Id_MSB;
uint8_t Program_Id; uint8_t Program_Id;
uint8_t Bank_Id_LSB_New; uint8_t Bank_Id_LSB_New;
uint8_t Bank_Id_MSB_New; uint8_t Bank_Id_MSB_New;
uint8_t Program_Id_New; uint8_t Program_Id_New;
DRT_Kit_Id Kit_Id;
char *Current_Path; char *Current_Path;
char **Request_Buf; char **Request_Buf;
int CurReq; int CurReq;
@ -386,6 +388,14 @@ DRT_Status DR_LV2_Log_Write( DRT_Log_Type_Id, char *, va_list);
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
//static inline void DR_LV2_Map_URIS( LV2_URID_Map *, DRT_Drummer_URIS *);
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* */ /* */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
@ -544,8 +554,6 @@ LV2_SYMBOL_EXPORT const LV2_Descriptor *lv2_descriptor( uint32_t);
/* Post Private Definitions */ /* Post Private Definitions */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* DRG_LV2_Descritor */ /* DRG_LV2_Descritor */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
@ -572,6 +580,15 @@ static const LV2_Descriptor DRG_LV2_Descriptor =
/* Public Prototypes */ /* Public Prototypes */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* DR_LV2_Map_URIS */
/*----------------------------------------------------------------------------*/
//extern inline void DR_LV2_Map_URIS( LV2_URID_Map *, DRT_Drummer_URIS *);

168
lv2_ui.c
View File

@ -65,8 +65,8 @@ DRT_Status DR_LV2UI_Log_Write( DRT_Log_Type_Id Log_Type_Id, char *Out_Fmt, va
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* DR_LV2UI_Map_URIS */ /* DR_LV2UI_Map_URIS */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/*
static inline void DR_LV2UI_Map_URIS( LV2_URID_Map *Map_Ptr, DRT_LV2UI_URIS *URIS) static inline void DR_LV2UI_Map_URIS( LV2_URID_Map *Map_Ptr, DRT_Drummer_URIS *URIS)
{ {
URIS->Atom_Object = Map_Ptr->map( Map_Ptr->handle, LV2_ATOM__Object); URIS->Atom_Object = Map_Ptr->map( Map_Ptr->handle, LV2_ATOM__Object);
@ -78,14 +78,15 @@ static inline void DR_LV2UI_Map_URIS( LV2_URID_Map *Map_Ptr, DRT_LV2UI_URIS *
URIS->Midi_Event = Map_Ptr->map( Map_Ptr->handle, "http://lv2plug.in/ns/ext/midi#MidiEvent"); URIS->Midi_Event = Map_Ptr->map( Map_Ptr->handle, "http://lv2plug.in/ns/ext/midi#MidiEvent");
URIS->UI_Msg = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#uimsg");
URIS->Atom_EventTransfer = Map_Ptr->map( Map_Ptr->handle, LV2_ATOM__eventTransfer); URIS->Atom_EventTransfer = Map_Ptr->map( Map_Ptr->handle, LV2_ATOM__eventTransfer);
URIS->UI_Msg = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#uimsg");
URIS->UI_Enable = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#uienable"); URIS->UI_Enable = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#uienable");
URIS->UI_Disable = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#uidisable"); URIS->UI_Disable = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#uidisable");
URIS->Kit_Name_Update = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#kitnameupdate"); URIS->Kit_Name_Update = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#kitnameupdate");
URIS->Kit_Id_Update = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#kitidupdate");
URIS->Velocity_Ignore_Flag_Toggle = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#velocitytoggle"); URIS->Velocity_Ignore_Flag_Toggle = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#velocitytoggle");
URIS->Note_Off_Ignore_Flag_Toggle = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#noteofftoggle"); URIS->Note_Off_Ignore_Flag_Toggle = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#noteofftoggle");
@ -100,9 +101,9 @@ static inline void DR_LV2UI_Map_URIS( LV2_URID_Map *Map_Ptr, DRT_LV2UI_URIS *
URIS->sample_add = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#sampleadd"); URIS->sample_add = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#sampleadd");
URIS->sample_remove = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#sampleremove"); URIS->sample_remove = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#sampleremove");
*/ */
/*
} }
*/
@ -175,17 +176,17 @@ static void send_ui_enable( LV2UI_Handle handle)
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* DR_LV2UI_UI_Enable */ /* DR_LV2UI_UI_Enable_Send */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
static DRT_Status DR_LV2UI_UI_Enable( void) static DRT_Status DR_LV2UI_UI_Enable_Send( void)
{ {
uint8_t obj_buf[64]; uint8_t obj_buf[64];
LV2_Atom_Forge_Frame set_frame; LV2_Atom_Forge_Frame set_frame;
LV2_Atom *msg; LV2_Atom *msg;
DR_LOG_INFO_0( "UI Open!"); DR_LOG_INFO_0( "UI Enable Send!");
@ -223,17 +224,17 @@ static DRT_Status DR_LV2UI_UI_Enable( void)
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* DR_LV2UI_UI_Disable */ /* DR_LV2UI_UI_Disable_Send */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
static DRT_Status DR_LV2UI_UI_Disable( void) static DRT_Status DR_LV2UI_UI_Disable_Send( void)
{ {
uint8_t obj_buf[64]; uint8_t obj_buf[64];
LV2_Atom_Forge_Frame set_frame; LV2_Atom_Forge_Frame set_frame;
LV2_Atom *msg; LV2_Atom *msg;
DR_LOG_INFO_0( "UI Close!"); DR_LOG_INFO_0( "UI Disable Send!");
@ -254,6 +255,39 @@ static DRT_Status DR_LV2UI_UI_Disable( void)
/*----------------------------------------------------------------------------*/
/* DR_LV2UI_Kit_Id_Update_Send */
/*----------------------------------------------------------------------------*/
static DRT_Status DR_LV2UI_Kit_Update_Request_Send( void)
{
uint8_t obj_buf[64];
LV2_Atom_Forge_Frame set_frame;
LV2_Atom *msg;
DR_LOG_INFO_0( "Kit Update Request!");
lv2_atom_forge_set_buffer( &( DRG_LV2UI_Base.Forge), obj_buf, sizeof( obj_buf));
lv2_atom_forge_frame_time( &( DRG_LV2UI_Base.Forge), 0);
msg = (LV2_Atom *)lv2_atom_forge_object( &( DRG_LV2UI_Base.Forge), &set_frame, 1, DRG_LV2UI_Base.URIS.UI_Msg);
lv2_atom_forge_property_head( &( DRG_LV2UI_Base.Forge), DRG_LV2UI_Base.URIS.Kit_Update_Request, 0);
lv2_atom_forge_long( &( DRG_LV2UI_Base.Forge), DRG_LV2UI_Base.Kit_Id);
lv2_atom_forge_pop( &( DRG_LV2UI_Base.Forge), &set_frame);
DRG_LV2UI_Base.Write( DRG_LV2UI_Base.Controller, 0, lv2_atom_total_size( msg), DRG_LV2UI_Base.URIS.Atom_EventTransfer, msg);
return( DRS_OK);
}
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* */ /* */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
@ -330,7 +364,7 @@ static GtkWidget *DR_LV2UI_Kit_ComboBox_Create( void)
DRT_Kit *kit_cur_ptr; DRT_Kit *kit_cur_ptr;
*/ */
list_store_ptr = gtk_list_store_new( 1, G_TYPE_STRING); list_store_ptr = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_LONG);
if( ( status = DR_Kits_Name_Get( &kit_name_tab, &kit_number)) != DRS_OK) if( ( status = DR_Kits_Name_Get( &kit_name_tab, &kit_number)) != DRS_OK)
@ -342,7 +376,7 @@ static GtkWidget *DR_LV2UI_Kit_ComboBox_Create( void)
for( i = 0; i < kit_number; i++) for( i = 0; i < kit_number; i++)
{ {
gtk_list_store_append( list_store_ptr, &iter); gtk_list_store_append( list_store_ptr, &iter);
gtk_list_store_set( list_store_ptr, &iter, 0, kit_name_tab[i].Name, -1); gtk_list_store_set( list_store_ptr, &iter, 0, kit_name_tab[i].Name, 1, kit_name_tab[i].Id,-1);
} }
} }
@ -362,33 +396,6 @@ static GtkWidget *DR_LV2UI_Kit_ComboBox_Create( void)
} }
/*
DR_LOG_INFO_1( "DRG_Base_Ptr: (%lx)!", (char *)( &DRG_Base));
if( ( nd_status = ND_Index_Node_First_Get( &node_cur_ptr, DRG_Base.Kit_DS_Ptr, 1)) != NDS_OK)
{
DR_LOG_INFO_1( "Can't find the first kit: ND_Index_Node_First_Get() failed (%d)!", nd_status);
}
else
{
while( node_cur_ptr != NULL)
{
kit_cur_ptr = node_cur_ptr->Value;
// DR_LOG_INFO_1( "Kit Name: [%s]", kit_cur_ptr->Name);
gtk_list_store_append( list_store_ptr, &iter);
gtk_list_store_set( list_store_ptr, &iter, 0, kit_cur_ptr->Name, -1);
if( ( nd_status = ND_Index_Node_Next_Get( &node_cur_ptr, node_cur_ptr)) != NDS_OK)
{
DR_LOG_INFO_1( "Can't find the next kit: ND_Index_Node_Next_Get() failed (%d)!", nd_status);
node_cur_ptr = NULL;
}
}
}
*/
@ -398,11 +405,31 @@ static GtkWidget *DR_LV2UI_Kit_ComboBox_Create( void)
static void DR_LV2UI_Kit_ComboBox_Changed( GtkComboBox *ComboBox_Ptr, gpointer Data_Ptr) static void DR_LV2UI_Kit_ComboBox_Changed( GtkComboBox *ComboBox_Ptr, gpointer Data_Ptr)
{ {
GtkTreeModel *model_ptr;
GtkTreeIter iter;
DRG_LV2UI_Base.Kit_Id = (float)gtk_combo_box_get_active( GTK_COMBO_BOX( ComboBox_Ptr)); DRG_LV2UI_Base.Kit_Id = (float)gtk_combo_box_get_active( GTK_COMBO_BOX( ComboBox_Ptr));
/*
DR_LOG_INFO_1( "Kit_ComboBox_Changed: Id: (%d)!", (int)( DRG_LV2UI_Base.Kit_Id)); model_ptr = gtk_combo_box_get_model( GTK_COMBO_BOX( ComboBox_Ptr));
DRG_LV2UI_Base.Write( DRG_LV2UI_Base.Controller, DRD_LV2_CHANNEL_ID, 4, 0, &( DRG_LV2UI_Base.Kit_Id)); if( !gtk_tree_model_iter_nth_child( model_ptr, &iter, NULL, gtk_combo_box_get_active( GTK_COMBO_BOX( ComboBox_Ptr))))
{
DR_LOG_INFO_0( "Line not found!");
return;
}
GValue value = G_VALUE_INIT;
gtk_tree_model_get_value( model_ptr, &iter, 1, &value);
DRG_LV2UI_Base.Kit_Id = g_value_get_long(&value);
*/
DR_LOG_INFO_1( "Kit_ComboBox_Changed: Id: (%d)!", DRG_LV2UI_Base.Kit_Id);
DR_LV2UI_Kit_Update_Request_Send();
// return( FALSE); // return( FALSE);
} }
@ -412,6 +439,26 @@ static void DR_LV2UI_Kit_ComboBox_Changed( GtkComboBox *ComboBox_Ptr, gpointer
/*----------------------------------------------------------------------------*/
/* DR_LV2UI_Kit_Update_Reply */
/*----------------------------------------------------------------------------*/
static DRT_Status DR_LV2UI_Kit_Update_Reply( DRT_Kit_Id Kit_Id)
{
DRG_LV2UI_Base.Kit_Id = Kit_Id;
gtk_combo_box_set_active( GTK_COMBO_BOX( DRG_LV2UI_Base.Kit_ComboBox_Ptr), Kit_Id);
DR_LOG_INFO_1( "Kit_Update_Reply: Id: (%d)!", Kit_Id);
return( DRS_OK);
}
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* DR_LV2UI_Channel_Id_ComboBox_Create */ /* DR_LV2UI_Channel_Id_ComboBox_Create */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
@ -596,6 +643,8 @@ static gboolean DR_LV2UI_Velocity_Ignore_Flag_Toggled( GtkToggleButton *Button
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* DR_LV2UI_Note_Off_Ignore_Flag_Toggled */ /* DR_LV2UI_Note_Off_Ignore_Flag_Toggled */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
@ -708,6 +757,7 @@ DRT_Status DR_LV2UI_UI_Build( GtkWidget **Main_Widget_Ptr_Ptr)
// Save // Save
DRG_LV2UI_Base.Main_Widget_Ptr = *Main_Widget_Ptr_Ptr; DRG_LV2UI_Base.Main_Widget_Ptr = *Main_Widget_Ptr_Ptr;
DRG_LV2UI_Base.Kit_ComboBox_Ptr = kit_combobox_ptr;
DRG_LV2UI_Base.Channel_ComboBox_Ptr = channel_id_combobox_ptr; DRG_LV2UI_Base.Channel_ComboBox_Ptr = channel_id_combobox_ptr;
DRG_LV2UI_Base.Base_Note_Spin_Ptr = base_note_spin_ptr; DRG_LV2UI_Base.Base_Note_Spin_Ptr = base_note_spin_ptr;
DRG_LV2UI_Base.Base_Note_Label_Ptr = base_note_label_ptr; DRG_LV2UI_Base.Base_Note_Label_Ptr = base_note_label_ptr;
@ -802,7 +852,8 @@ static LV2UI_Handle DR_LV2UI_Instantiate( const LV2UI_Descriptor *LV2UI_Des
lv2_log_error( &(DRG_LV2UI_Base.Logger), "UI: Test error log <%s>!\n", "Krash!"); lv2_log_error( &(DRG_LV2UI_Base.Logger), "UI: Test error log <%s>!\n", "Krash!");
DR_LOG_ERROR_1( "Test error log <%s>!", "Krash!"); DR_LOG_ERROR_1( "Test error log <%s>!", "Krash!");
DR_LV2UI_Map_URIS( DRG_LV2UI_Base.Map_Ptr, &(DRG_LV2UI_Base.URIS)); // DR_LV2UI_Map_URIS( DRG_LV2UI_Base.Map_Ptr, &(DRG_LV2UI_Base.URIS));
DR_LV2_Map_URIS( DRG_LV2UI_Base.Map_Ptr, &(DRG_LV2UI_Base.URIS));
lv2_atom_forge_init( &(DRG_LV2UI_Base.Forge), DRG_LV2UI_Base.Map_Ptr); lv2_atom_forge_init( &(DRG_LV2UI_Base.Forge), DRG_LV2UI_Base.Map_Ptr);
@ -819,7 +870,7 @@ static LV2UI_Handle DR_LV2UI_Instantiate( const LV2UI_Descriptor *LV2UI_Des
} }
else else
{ {
DR_LV2UI_UI_Enable(); DR_LV2UI_UI_Enable_Send();
return( &DRG_LV2UI_Base); return( &DRG_LV2UI_Base);
} }
@ -842,7 +893,7 @@ static void DR_LV2UI_Cleanup( LV2UI_Handle Instance_Ptr)
{ {
DR_LOG_INFO_0( "Cleanup called!!"); DR_LOG_INFO_0( "Cleanup called!!");
DR_LV2UI_UI_Disable(); DR_LV2UI_UI_Disable_Send();
/* /*
EgScopeUI* ui = (EgScopeUI*)handle; EgScopeUI* ui = (EgScopeUI*)handle;
@ -886,32 +937,33 @@ static void DR_LV2UI_Port_Event( LV2UI_Handle Instance_Ptr,
if( obj->body.otype == DRG_LV2UI_Base.URIS.UI_Msg) if( obj->body.otype == DRG_LV2UI_Base.URIS.UI_Msg)
{ {
const LV2_Atom *kit_name_tab_ptr = NULL; const LV2_Atom *kit_update_request_ptr = NULL;
const LV2_Atom *kit_update_reply_ptr = NULL;
const LV2_Atom *velocity_ignore_flag_ptr = NULL; const LV2_Atom *velocity_ignore_flag_ptr = NULL;
const LV2_Atom *note_off_ignore_flag_ptr = NULL; const LV2_Atom *note_off_ignore_flag_ptr = NULL;
lv2_atom_object_get( obj, lv2_atom_object_get( obj,
DRG_LV2UI_Base.URIS.Kit_Name_Update, &kit_name_tab_ptr, DRG_LV2UI_Base.URIS.Kit_Update_Request, &kit_update_request_ptr,
DRG_LV2UI_Base.URIS.Kit_Update_Reply, &kit_update_reply_ptr,
DRG_LV2UI_Base.URIS.Velocity_Ignore_Flag_Toggle, &velocity_ignore_flag_ptr, DRG_LV2UI_Base.URIS.Velocity_Ignore_Flag_Toggle, &velocity_ignore_flag_ptr,
DRG_LV2UI_Base.URIS.Note_Off_Ignore_Flag_Toggle, &note_off_ignore_flag_ptr, DRG_LV2UI_Base.URIS.Note_Off_Ignore_Flag_Toggle, &note_off_ignore_flag_ptr,
NULL); NULL);
if( kit_name_tab_ptr) if( kit_update_request_ptr)
{ {
LV2_Atom *iter; DR_LOG_ERROR_0( "Kit Update Request: This shouldn't be received by me!");
long kit_number, kit_cur_id; }
DR_LOG_INFO_0( "UI Msg: Kit Name Update! "); if( kit_update_reply_ptr)
{
long kit_id;
iter = lv2_atom_tuple_begin( (const LV2_Atom_Tuple *)kit_name_tab_ptr); kit_id = ( (const LV2_Atom_Long *)kit_update_reply_ptr)->body;
kit_number = ( (const LV2_Atom_Long *)iter)->body;
iter = lv2_atom_tuple_next( iter); DR_LOG_INFO_1( "Kit Update Reply: Kit_Id: (%ld)!", kit_id);
kit_cur_id = ( (const LV2_Atom_Long *)iter)->body;
DR_LOG_INFO_2( "UI Msg: Kit Name Update: Kit_Number: (%ld) Kit_Cur_Id: (%ld)!", kit_number, kit_cur_id);
DR_LV2UI_Kit_Update_Reply( kit_id);
/* /*
int end; int end;

View File

@ -57,7 +57,7 @@ typedef struct {
*/ */
/*
typedef struct DRT_LV2UI_URIS typedef struct DRT_LV2UI_URIS
{ {
LV2_URID Atom_Object; LV2_URID Atom_Object;
@ -70,30 +70,29 @@ typedef struct DRT_LV2UI_URIS
LV2_URID Midi_Event; LV2_URID Midi_Event;
LV2_URID UI_Msg; LV2_URID Atom_EventTransfer;
// LV2_URID kit_path; LV2_URID UI_Msg;
LV2_URID UI_Enable; LV2_URID UI_Enable;
LV2_URID UI_Disable; LV2_URID UI_Disable;
LV2_URID Kit_Name_Update; LV2_URID Kit_Name_Update;
LV2_URID Kit_Id_Update;
LV2_URID Atom_EventTransfer;
// LV2_URID get_state;
// LV2_URID midi_info;
// LV2_URID sample_trigger;
// LV2_URID channel_id;
LV2_URID Velocity_Ignore_Flag_Toggle; LV2_URID Velocity_Ignore_Flag_Toggle;
LV2_URID Note_Off_Ignore_Flag_Toggle; LV2_URID Note_Off_Ignore_Flag_Toggle;
// LV2_URID kit_path;
// LV2_URID get_state;
// LV2_URID midi_info;
// LV2_URID sample_trigger;
// LV2_URID channel_id;
// LV2_URID zero_position; // LV2_URID zero_position;
// LV2_URID sample_add; // LV2_URID sample_add;
// LV2_URID sample_remove; // LV2_URID sample_remove;
} DRT_LV2UI_URIS; } DRT_LV2UI_URIS;
*/
typedef struct DRT_LV2UI_Base typedef struct DRT_LV2UI_Base
@ -108,7 +107,7 @@ typedef struct DRT_LV2UI_Base
LV2_Atom_Sequence *Core_Event_Port; LV2_Atom_Sequence *Core_Event_Port;
//Config //Config
float Kit_Id; DRT_Kit_Id Kit_Id;
float Channel_Id; float Channel_Id;
float Base_Note; float Base_Note;
float Velocity_Ignore_Note; float Velocity_Ignore_Note;
@ -124,7 +123,7 @@ typedef struct DRT_LV2UI_Base
// URIs // URIs
LV2_URID_Map *Map_Ptr; LV2_URID_Map *Map_Ptr;
DRT_LV2UI_URIS URIS; DRT_Drummer_URIS URIS;
// Logger // Logger
LV2_Log_Logger Logger; LV2_Log_Logger Logger;
@ -180,7 +179,7 @@ char *DRG_LV2UI_Note_String = "C C#D D#E F F#G G#A A#B ";
/* DR_LV2UI_Map_URIS */ /* DR_LV2UI_Map_URIS */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
static inline void DR_LV2UI_Map_URIS( LV2_URID_Map *, DRT_LV2UI_URIS *); //static inline void DR_LV2UI_Map_URIS( LV2_URID_Map *, DRT_Drummer_URIS *);
@ -193,18 +192,34 @@ DRT_Status DR_LV2UI_Log_Write( DRT_Log_Type_Id, char *, va_list);
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* DR_LV2UI_UI_Enable */ /* DR_LV2UI_UI_Enable_Send */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
static DRT_Status DR_LV2UI_UI_Enable( void); static DRT_Status DR_LV2UI_UI_Enable_Send( void);
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* DR_LV2UI_UI_Disable */ /* DR_LV2UI_UI_Disable_Send */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
static DRT_Status DR_LV2UI_UI_Disable( void); static DRT_Status DR_LV2UI_UI_Disable_Send( void);
/*----------------------------------------------------------------------------*/
/* DR_LV2UI_Kit_Update_Request_Send */
/*----------------------------------------------------------------------------*/
static DRT_Status DR_LV2UI_Kit_Update_Request_Send( void);
/*----------------------------------------------------------------------------*/
/* DR_LV2UI_Kit_Update_Reply */
/*----------------------------------------------------------------------------*/
static DRT_Status DR_LV2UI_Kit_Update_Reply( DRT_Kit_Id);

108
lv2_utils.c Normal file
View File

@ -0,0 +1,108 @@
/*----------------------------------------------------------------------------*/
/* Includes */
/*----------------------------------------------------------------------------*/
#define _LV2_UTILS_C_
#include <drummer.h>
/*----------------------------------------------------------------------------*/
/* DR_LV2_Log_Write */
/*----------------------------------------------------------------------------*/
/*
DRT_Status DR_LV2_Log_Write( DRT_Log_Type_Id Log_Type_Id, char *Out_Fmt, va_list Args)
{
LV2_URID type;
switch( Log_Type_Id)
{
case DRD_LOG_TYPE_ID_TRACE:
{
type = DRG_LV2_Base.Logger.Trace;
break;
}
case DRD_LOG_TYPE_ID_INFO:
{
type = DRG_LV2_Base.Logger.Note;
break;
}
case DRD_LOG_TYPE_ID_WARNING:
{
type = DRG_LV2_Base.Logger.Warning;
break;
}
case DRD_LOG_TYPE_ID_ERROR:
case DRD_LOG_TYPE_ID_UNKNOWN:
default:
{
type = DRG_LV2_Base.Logger.Error;
break;
}
}
if( lv2_log_vprintf( &(DRG_LV2_Base.Logger), type, Out_Fmt, Args) == 0)
{
fprintf( stderr, "LV2 logger error...\n");
}
return( DRS_OK);
}
*/
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
void DR_LV2_Map_URIS( LV2_URID_Map *Map_Ptr, DRT_Drummer_URIS *URIS)
{
URIS->Atom_Object = Map_Ptr->map( Map_Ptr->handle, LV2_ATOM__Object);
URIS->String_URId = Map_Ptr->map( Map_Ptr->handle, LV2_ATOM__String);
URIS->Bool_URId = Map_Ptr->map( Map_Ptr->handle, LV2_ATOM__Bool);
URIS->Int_URId = Map_Ptr->map( Map_Ptr->handle, LV2_ATOM__Int);
URIS->Long_URId = Map_Ptr->map( Map_Ptr->handle, LV2_ATOM__Long);
URIS->Tuple_URId = Map_Ptr->map( Map_Ptr->handle, LV2_ATOM__Tuple);
URIS->Midi_Event = Map_Ptr->map( Map_Ptr->handle, "http://lv2plug.in/ns/ext/midi#MidiEvent");
URIS->Atom_EventTransfer = Map_Ptr->map( Map_Ptr->handle, LV2_ATOM__eventTransfer);
URIS->UI_Msg = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#uimsg");
URIS->UI_Enable = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#uienable");
URIS->UI_Disable = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#uidisable");
URIS->Kit_Update_Request = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#kitupdaterequest");
URIS->Kit_Update_Reply = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#kitupdatereply");
URIS->Velocity_Ignore_Flag_Toggle = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#velocitytoggle");
URIS->Note_Off_Ignore_Flag_Toggle = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#noteofftoggle");
/*
URIS->kit_path = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#kitpath");
URIS->get_state = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#getstate");
URIS->midi_info = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#midiinfo");
URIS->sample_trigger = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#sampletrigger");
URIS->velocity_toggle = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#velocitytoggle");
URIS->note_off_toggle = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#noteofftoggle");
URIS->channel_id = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#channelid");
URIS->zero_position = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#zeroposition");
URIS->sample_add = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#sampleadd");
URIS->sample_remove = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#sampleremove");
*/
}

154
lv2_utils.h Normal file
View File

@ -0,0 +1,154 @@
/*---------------------------------------------------------------------------------*/
/* Includes */
/*---------------------------------------------------------------------------------*/
#ifndef _LV2_UTILS_H_
#define _LV2_UTILS_H_
#include "lv2/atom/atom.h"
#include "lv2/atom/forge.h"
#include "lv2/atom/util.h"
#include "lv2/core/lv2.h"
#include "lv2/core/lv2_util.h"
#include "lv2/log/log.h"
#include "lv2/log/logger.h"
#include "lv2/midi/midi.h"
#include "lv2/urid/urid.h"
#include "lv2/state/state.h"
//#include "lv2/lv2plug.in/ns/ext/atom/forge.h"
// util includes atom.h
//#include "lv2/lv2plug.in/ns/ext/atom/util.h"
//#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
//#include "lv2/lv2plug.in/ns/ext/urid/urid.h"
//#include "lv2/lv2plug.in/ns/ext/state/state.h"
/*----------------------------------------------------------------------------*/
/* Global definitions */
/*----------------------------------------------------------------------------*/
typedef struct DRT_Drummer_URIS
{
LV2_URID Atom_Object;
LV2_URID String_URId;
LV2_URID Bool_URId;
LV2_URID Int_URId;
LV2_URID Long_URId;
LV2_URID Tuple_URId;
LV2_URID Midi_Event;
LV2_URID Atom_EventTransfer;
LV2_URID UI_Msg;
LV2_URID UI_Enable;
LV2_URID UI_Disable;
LV2_URID Kit_Update_Request;
LV2_URID Kit_Update_Reply;
LV2_URID Velocity_Ignore_Flag_Toggle;
LV2_URID Note_Off_Ignore_Flag_Toggle;
// LV2_URID kit_path;
// LV2_URID get_state;
// LV2_URID midi_info;
// LV2_URID sample_trigger;
// LV2_URID channel_id;
// LV2_URID velocity_toggle;
// LV2_URID note_off_toggle;
// LV2_URID zero_position;
// LV2_URID sample_add;
// LV2_URID sample_remove;
} DRT_Drummer_URIS;
# ifdef _LV2_UTILS_C_
/*----------------------------------------------------------------------------*/
/* Private Definitions */
/*----------------------------------------------------------------------------*/
#define DRD_MODULE_NAME "utl"
/*----------------------------------------------------------------------------*/
/* Private Prototypes */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* DR_Log */
/*----------------------------------------------------------------------------*/
//DRT_Status DR_LV2_Log_Write( DRT_Log_Type_Id, char *, va_list);
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
void DR_LV2_Map_URIS( LV2_URID_Map *, DRT_Drummer_URIS *);
/*----------------------------------------------------------------------------*/
/* Post Private Definitions */
/*----------------------------------------------------------------------------*/
# else // ifdef _LV2_UTILS_C_
/*----------------------------------------------------------------------------*/
/* Public Prototypes */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* DR_LV2_Map_URIS */
/*----------------------------------------------------------------------------*/
extern void DR_LV2_Map_URIS( LV2_URID_Map *, DRT_Drummer_URIS *);
# endif // ifndef _LV2_UTILS_C_
/*----------------------------------------------------------------------------*/
#endif // ifndef _LV2_UTILS_H_