- Add kit combobox in ui,

- Remove kits database load on ui side,
- Fix velocity ignore flag toggling,
- Start kit name tab update process.
This commit is contained in:
Arnaud G. GIBERT 2024-04-08 10:01:34 +02:00
parent e816f1cb0d
commit 1368d988d1
5 changed files with 195 additions and 58 deletions

4
go.sh
View File

@ -37,8 +37,8 @@ eval ${cmd}
cmd="./drummer-mkttl"
echo ${cmd}
eval ${cmd}
#echo ${cmd}
#eval ${cmd}
#gcc -g -I . -L . -shared -o drummer.so -fPIC drummer.c
#gcc -g -I. -I/usr/include/libxml2 -o xpath -fPIC -ldl -lxml2 -lz -llzma -lm xpath.c

View File

@ -87,6 +87,8 @@ static inline void DR_LV2_Map_URIS( LV2_URID_Map *Map_Ptr, DRT_Drummer_URIS *
URIS->Atom_EventTransfer = Map_Ptr->map( Map_Ptr->handle, LV2_ATOM__eventTransfer);
URIS->Kit_Name_Tab_Update = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#kitnametabupdate");
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");
@ -758,6 +760,8 @@ static LV2_Handle DR_LV2_Instantiate( const LV2_Descriptor *LV2_Descripto
}
else
{
DR_LOG_INFO_1( "DRG_Base_Ptr: (%lx)!", (char *)( &DRG_Base));
return( (LV2_Handle)&DRG_LV2_Base);
}
}
@ -975,7 +979,7 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples)
*( DRG_Base.Velocity_Ignore_Flag_Ptr) = (float)( (int)*( DRG_Base.Velocity_Ignore_Flag_Ptr) ^ true);
DR_LOG_INFO_2( "Velocity Ignore: [%f] - [%f]", *( DRG_Base.Velocity_Ignore_Flag_Ptr), *( DRG_Base.Velocity_Ignore_Note_Ptr));
DR_UI_Port_Notify( DRG_LV2_Base.URIS.Velocity_Ignore_Flag_Toggle, *( DRG_Base.Velocity_Ignore_Flag_Ptr));
DR_UI_Port_Notify( DRG_LV2_Base.URIS.Velocity_Ignore_Flag_Toggle, *( DRG_Base.Velocity_Ignore_Flag_Ptr));
}
else
{
@ -988,11 +992,32 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples)
}
else
{
nn -= base_note;
if( nn == 26)
{
LV2_Atom_Forge_Frame set_frame;
DR_LOG_INFO_1( "Update Kit Name Tab: [%d]", nn);
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_property_head( &( DRG_LV2_Base.Forge), DRG_LV2_Base.URIS.Kit_Name_Tab_Update, 0);
lv2_atom_forge_string( &( DRG_LV2_Base.Forge), "Hello World!", 13);
lv2_atom_forge_pop( &( DRG_LV2_Base.Forge), &set_frame);
}
else
{
DR_LOG_INFO_1( "ZZZ Update Kit Name Tab: [%d]", nn);
nn -= base_note;
DR_Sample_Trigger( nn, data, offset);
DR_Sample_Trigger( nn, data, offset);
}
}
}
}
break;
}

View File

@ -215,6 +215,8 @@ typedef struct DRT_Drummer_URIS
LV2_URID Atom_EventTransfer;
LV2_URID Kit_Name_Tab_Update;
LV2_URID Velocity_Ignore_Flag_Toggle;
LV2_URID Note_Off_Ignore_Flag_Toggle;

161
lv2_ui.c
View File

@ -80,6 +80,8 @@ static inline void DR_LV2UI_Map_URIS( LV2_URID_Map *Map_Ptr, DRT_LV2UI_URIS *
URIS->Atom_EventTransfer = Map_Ptr->map( Map_Ptr->handle, LV2_ATOM__eventTransfer);
URIS->Kit_Name_Tab_Update = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#kitnametabupdate");
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");
@ -220,6 +222,89 @@ static gboolean DR_LV2UI_Expose_Callback (GtkWidget *widget, GdkEventExpose *eve
/*----------------------------------------------------------------------------*/
/* DR_LV2UI_Kit_ComboBox_Create */
/*----------------------------------------------------------------------------*/
static GtkWidget *DR_LV2UI_Kit_ComboBox_Create( void)
{
GtkWidget *combobox_ptr;
GtkListStore *list_store_ptr;
GtkCellRenderer *cell_ptr;
GtkTreeIter iter;
int i;
char label[8];
NDT_Status nd_status;
NDT_Node *node_cur_ptr;
DRT_Kit *kit_cur_ptr;
list_store_ptr = gtk_list_store_new( 1, G_TYPE_STRING);
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;
}
}
}
combobox_ptr = gtk_combo_box_new_with_model( GTK_TREE_MODEL( list_store_ptr));
gtk_combo_box_set_active( GTK_COMBO_BOX( combobox_ptr), 0);
g_object_unref( list_store_ptr);
cell_ptr = gtk_cell_renderer_text_new();
gtk_cell_layout_pack_start( GTK_CELL_LAYOUT( combobox_ptr), cell_ptr, TRUE);
gtk_cell_layout_set_attributes( GTK_CELL_LAYOUT( combobox_ptr), cell_ptr, "text", 0, NULL);
return( combobox_ptr);
}
/*----------------------------------------------------------------------------*/
/* DR_LV2UI_Kit_ComboBox_Change */
/*----------------------------------------------------------------------------*/
static void DR_LV2UI_Kit_ComboBox_Changed( GtkComboBox *ComboBox_Ptr, gpointer Data_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));
DRG_LV2UI_Base.Write( DRG_LV2UI_Base.Controller, DRD_LV2_CHANNEL_ID, 4, 0, &( DRG_LV2UI_Base.Kit_Id));
// return( FALSE);
}
/*----------------------------------------------------------------------------*/
/* DR_LV2UI_Channel_Id_ComboBox_Create */
/*----------------------------------------------------------------------------*/
@ -313,7 +398,7 @@ static void DR_LV2UI_Base_Note_Spin_Changed( GtkSpinButton *Spin_Ptr, gpointer
{
DRG_LV2UI_Base.Base_Note = base;
DR_LOG_INFO_1( "Channel_Id_ComboBox_Changed: Id: (%d)!", (int)( base));
DR_LOG_INFO_1( "Base_Note_Spin_Changed: Id: (%d)!", (int)( base));
DRG_LV2UI_Base.Write( DRG_LV2UI_Base.Controller, DRD_LV2_BASE_NOTE, 4, 0, &( DRG_LV2UI_Base.Base_Note));
@ -429,8 +514,9 @@ static gboolean DR_LV2UI_Note_Off_Ignore_Flag_Toggled( GtkToggleButton *Button
DRT_Status DR_LV2UI_UI_Build( GtkWidget **Main_Widget_Ptr_Ptr)
{
GtkWidget *opts_hbox1_ptr, *opts_hbox2_ptr, *channel_id_hbox_ptr, *position_id_hbox_ptr,
*channel_id_label_ptr, *channel_id_combobox_ptr, *position_id_label_ptr, *position_id_combobox_ptr, *base_note_label_ptr, *base_note_spin_ptr, *velocity_ignore_flag_checkbox_ptr, *note_off_ignore_flag_checkbox_ptr;
GtkWidget *opts_hbox1_ptr, *opts_hbox2_ptr, *kit_hbox_ptr, *base_note_hbox_ptr, *channel_id_hbox_ptr, *position_id_hbox_ptr,
*kit_label_ptr, *kit_combobox_ptr, *channel_id_label_ptr, *channel_id_combobox_ptr, *position_id_label_ptr, *position_id_combobox_ptr,
*base_note_label_ptr, *base_note_spin_ptr, *velocity_ignore_flag_checkbox_ptr, *note_off_ignore_flag_checkbox_ptr;
GtkLabel *label_ptr;
GtkAdjustment *base_note_adj_ptr;
@ -439,31 +525,42 @@ DRT_Status DR_LV2UI_UI_Build( GtkWidget **Main_Widget_Ptr_Ptr)
g_object_set( *Main_Widget_Ptr_Ptr, "border-width", 6, NULL);
label_ptr = GTK_LABEL( gtk_label_new( "Test!"));
label_ptr = GTK_LABEL( gtk_label_new( "Test!!!"));
/* Option Boxes */
opts_hbox1_ptr = gtk_hbox_new( false, 0);
opts_hbox2_ptr = gtk_hbox_new( false, 0);
opts_hbox1_ptr = gtk_hbox_new( false, 0);
opts_hbox2_ptr = gtk_hbox_new( false, 0);
// Kit
kit_label_ptr = gtk_label_new( "Kit: <b>No kit selected</b>");
gtk_label_set_use_markup( GTK_LABEL( kit_label_ptr), true);
kit_combobox_ptr = DR_LV2UI_Kit_ComboBox_Create();
kit_hbox_ptr = gtk_hbox_new( false, 0);
gtk_box_pack_start( GTK_BOX( kit_hbox_ptr), kit_label_ptr, false, false, 0);
gtk_box_pack_start( GTK_BOX( kit_hbox_ptr), kit_combobox_ptr, true, false, 0);
// Midi Base Note
base_note_label_ptr = gtk_label_new( "Midi Base Note <b>(C 2)</b>:");
gtk_label_set_use_markup( GTK_LABEL( base_note_label_ptr), true);
base_note_adj_ptr = GTK_ADJUSTMENT( gtk_adjustment_new( 36.0, // val
21.0,107.0, // min/max
1.0, // step
5.0,0.0)); // page adj/size
base_note_spin_ptr = gtk_spin_button_new( base_note_adj_ptr, 1.0, 0);
base_note_hbox_ptr = gtk_hbox_new( false, 0);
gtk_box_pack_start( GTK_BOX( base_note_hbox_ptr), base_note_label_ptr, false, false, 0);
gtk_box_pack_start( GTK_BOX( base_note_hbox_ptr), base_note_spin_ptr, true, false, 0);
// Midi Channel_Id
channel_id_hbox_ptr = gtk_hbox_new( false, 0);
channel_id_label_ptr = gtk_label_new( "Midi Channel: ");
channel_id_combobox_ptr = DR_LV2UI_Channel_Id_ComboBox_Create();
channel_id_combobox_ptr = DR_LV2UI_Channel_Id_ComboBox_Create();
gtk_box_pack_start( GTK_BOX( channel_id_hbox_ptr), channel_id_label_ptr, true, false, 0);
gtk_box_pack_start( GTK_BOX( channel_id_hbox_ptr), channel_id_combobox_ptr, false, false, 0);
// Midi Base Note
base_note_label_ptr = gtk_label_new("Midi Base Note <b>(C 2)</b>:");
gtk_label_set_use_markup( GTK_LABEL( base_note_label_ptr), true);
base_note_adj_ptr = GTK_ADJUSTMENT( gtk_adjustment_new( 36.0, // val
21.0,107.0, // min/max
1.0, // step
5.0,0.0)); // page adj/size
base_note_spin_ptr = gtk_spin_button_new( base_note_adj_ptr, 1.0, 0);
// Sample Zero Position Id
position_id_hbox_ptr = gtk_hbox_new( false, 0);
position_id_label_ptr = gtk_label_new( "Sample Zero Position: ");
@ -478,12 +575,13 @@ DRT_Status DR_LV2UI_UI_Build( GtkWidget **Main_Widget_Ptr_Ptr)
// Note Off Ignore
note_off_ignore_flag_checkbox_ptr = gtk_check_button_new_with_label( "Ignore Note Off");
gtk_box_pack_start( GTK_BOX( opts_hbox1_ptr), base_note_label_ptr, false, false, 15);
gtk_box_pack_start( GTK_BOX( opts_hbox1_ptr), base_note_spin_ptr, true, true, 0);
gtk_box_pack_start( GTK_BOX( opts_hbox2_ptr), channel_id_hbox_ptr, true, false, 0);
gtk_box_pack_start( GTK_BOX( opts_hbox2_ptr), position_id_hbox_ptr, true, false, 0);
// Layout
gtk_box_pack_start( GTK_BOX( opts_hbox1_ptr), kit_hbox_ptr, true, false, 15);
gtk_box_pack_start( GTK_BOX( opts_hbox1_ptr), base_note_hbox_ptr, true, false, 15);
gtk_box_pack_start( GTK_BOX( opts_hbox2_ptr), channel_id_hbox_ptr, true, false, 15);
gtk_box_pack_start( GTK_BOX( opts_hbox2_ptr), position_id_hbox_ptr, true, false, 15);
gtk_box_pack_start( GTK_BOX( opts_hbox2_ptr), velocity_ignore_flag_checkbox_ptr, true, false, 15);
gtk_box_pack_start( GTK_BOX( opts_hbox2_ptr), note_off_ignore_flag_checkbox_ptr, true, true, 15);
@ -492,8 +590,8 @@ DRT_Status DR_LV2UI_UI_Build( GtkWidget **Main_Widget_Ptr_Ptr)
gtk_box_pack_start( GTK_BOX( *Main_Widget_Ptr_Ptr), opts_hbox2_ptr, false, false, 5);
// Signals
// g_signal_connect( G_OBJECT( kit_combo_box), "changed", G_CALLBACK( kit_combobox_changed), &DRG_LV2UI_Note);
// g_signal_connect( G_OBJECT( base_note_spin_ptr), "value-changed", G_CALLBACK( DR_LV2UI_Base_Note_Note_Changed), &DRG_LV2UI_Base);
// g_signal_connect( G_OBJECT( kit_combobox), "changed", G_CALLBACK( kit_combobox_changed), &DRG_LV2UI_Note);
g_signal_connect( G_OBJECT( base_note_spin_ptr), "value-changed", G_CALLBACK( DR_LV2UI_Base_Note_Spin_Changed), &DRG_LV2UI_Base);
g_signal_connect( G_OBJECT( channel_id_combobox_ptr), "changed", G_CALLBACK( DR_LV2UI_Channel_Id_ComboBox_Changed), &DRG_LV2UI_Base);
g_signal_connect( G_OBJECT( position_id_combobox_ptr), "changed", G_CALLBACK( DR_LV2UI_Position_Id_ComboBox_Changed), &DRG_LV2UI_Base);
g_signal_connect( G_OBJECT( velocity_ignore_flag_checkbox_ptr), "toggled", G_CALLBACK( DR_LV2UI_Velocity_Ignore_Flag_Toggled), &DRG_LV2UI_Base);
@ -600,11 +698,12 @@ static LV2UI_Handle DR_LV2UI_Instantiate( const LV2UI_Descriptor *LV2UI_Des
lv2_atom_forge_init( &(DRG_LV2UI_Base.Forge), DRG_LV2UI_Base.Map_Ptr);
/*
if( ( status = DR_Kits_Load()) != DRS_OK)
{
fprintf( stderr, "Can't load kits (%d)!\n", status);
}
else
}
else */
{
if( DR_LV2UI_UI_Build( (GtkWidget **)Widget_Ptr_Ptr) != DRS_OK)
{
@ -659,7 +758,7 @@ static void DR_LV2UI_Port_Event( LV2UI_Handle Instance_Ptr,
uint32_t Format,
const void *Buffer_Ptr)
{
// DR_LOG_INFO_2( "Port_Event called: Port: (%d) Format: (%d)!", Port_Id, Format);
DR_LOG_INFO_2( "Port_Event called: Port: (%d) Format: (%d)!", Port_Id, Format);
if( Port_Id == DRD_LV2_CORE_EVENT)
{
@ -675,14 +774,21 @@ static void DR_LV2UI_Port_Event( LV2UI_Handle Instance_Ptr,
if( obj->body.otype == DRG_LV2UI_Base.URIS.UI_Msg)
{
const LV2_Atom *kit_name_tab_ptr = NULL;
const LV2_Atom *velocity_ignore_flag_ptr = NULL;
const LV2_Atom *note_off_ignore_flag_ptr = NULL;
lv2_atom_object_get( obj,
DRG_LV2UI_Base.URIS.Kit_Name_Tab_Update, &kit_name_tab_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,
NULL);
if( kit_name_tab_ptr)
{
DR_LOG_INFO_1( "UI Msg: Kit Name Tab Update! [%s]", (char*)LV2_ATOM_BODY( kit_name_tab_ptr));
}
if( velocity_ignore_flag_ptr)
{
DRG_LV2UI_Base.Velocity_Ignore_Flag = ( (const LV2_Atom_Float *)velocity_ignore_flag_ptr)->body;
@ -729,6 +835,7 @@ static void DR_LV2UI_Port_Event( LV2UI_Handle Instance_Ptr,
else if( Port_Id == DRD_LV2_VELOCITY_IGNORE_NOTE)
{
DR_LOG_INFO_0( "Port_Event called: Velocity Ignore Note!");
DR_LOG_INFO_1( "Received DRG_Base_Ptr: (%lx)!", (char *)( Buffer_Ptr));
}
else if( Port_Id == DRD_LV2_NOTE_OFF_IGNORE_NOTE)
{

View File

@ -71,6 +71,7 @@ typedef struct DRT_LV2UI_URIS
LV2_URID UI_Msg;
// LV2_URID kit_path;
LV2_URID Kit_Name_Tab_Update;
LV2_URID Atom_EventTransfer;
@ -97,41 +98,43 @@ typedef struct DRT_LV2UI_Base
LV2_Atom_Forge Forge;
// Ports
LV2_Atom_Sequence *Control_Port;
LV2_Atom_Sequence *Core_Event_Port;
LV2_Atom_Sequence *Control_Port;
LV2_Atom_Sequence *Core_Event_Port;
//Config
float Channel_Id;
float Base_Note;
float Velocity_Ignore_Note;
float Note_Off_Ignore_Note;
float Velocity_Ignore_Flag;
float Note_Off_Ignore_Flag;
float Position_Id;
float Kit_Id;
float Channel_Id;
float Base_Note;
float Velocity_Ignore_Note;
float Note_Off_Ignore_Note;
float Velocity_Ignore_Flag;
float Note_Off_Ignore_Flag;
float Position_Id;
// params
int Zero_Position;
float **Gains;
float **Pans;
int Zero_Position;
float **Gains;
float **Pans;
// URIs
LV2_URID_Map *Map_Ptr;
DRT_LV2UI_URIS URIS;
LV2_URID_Map *Map_Ptr;
DRT_LV2UI_URIS URIS;
// Logger
LV2_Log_Logger Logger;
LV2_Log_Logger Logger;
// UI
GtkWidget *Main_Widget_Ptr;
GtkWidget *Channel_ComboBox_Ptr;
GtkWidget *Base_Note_Spin_Ptr;
GtkWidget *Base_Note_Label_Ptr;
char Base_Note_Label_Buf[32];
GtkWidget *Position_ComboBox_Ptr;
GtkWidget *Velocity_Ignore_Note_Spin_Ptr;
GtkWidget *Note_Off_Ignore_Note_Spin_Ptr;
GtkWidget *Velocity_Ignore_Flag_CheckBox_Ptr;
GtkWidget *Note_Off_Ignore_Flag_CheckBox_Ptr;
GtkWidget *Main_Widget_Ptr;
GtkWidget *Kit_ComboBox_Ptr;
GtkWidget *Channel_ComboBox_Ptr;
GtkWidget *Base_Note_Spin_Ptr;
GtkWidget *Base_Note_Label_Ptr;
char Base_Note_Label_Buf[32];
GtkWidget *Position_ComboBox_Ptr;
GtkWidget *Velocity_Ignore_Note_Spin_Ptr;
GtkWidget *Note_Off_Ignore_Note_Spin_Ptr;
GtkWidget *Velocity_Ignore_Flag_CheckBox_Ptr;
GtkWidget *Note_Off_Ignore_Flag_CheckBox_Ptr;
} DRT_LV2UI_Base;