Arnaud G. GIBERT
8844bd636f
- Implement DR_Kit_Id_Convert() and DR_Bank_Program_Id_Convert(), - Implement UI title label and id_bank_program label update, - Add GPL3 license file & file headers.
1222 lines
43 KiB
C
1222 lines
43 KiB
C
/*----------------------------------------------------------------------------*/
|
|
/* lv2_ui.c */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* This file is part of Drummer. */
|
|
/* */
|
|
/* Drummer is free software: you can redistribute it and/or modify it */
|
|
/* under the terms of the GNU General Public License as published by */
|
|
/* the Free Software Foundation, either version 3 of the License, or */
|
|
/* (at your option) any later version. */
|
|
/* */
|
|
/* Drummer is distributed in the hope that it will be useful, */
|
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
|
/* GNU General Public License for more details. */
|
|
/* */
|
|
/* You should have received a copy of the GNU General Public License */
|
|
/* along with Drummer. If not, see <https://www.gnu.org/licenses/>. */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* Includes */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
#define _LV2_UI_C_
|
|
|
|
|
|
|
|
#include <drummer.h>
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* DR_LV2UI_Log_Write */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
DRT_Status DR_LV2UI_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_LV2UI_Base.Logger.Trace;
|
|
break;
|
|
}
|
|
|
|
case DRD_LOG_TYPE_ID_INFO:
|
|
{
|
|
type = DRG_LV2UI_Base.Logger.Note;
|
|
break;
|
|
}
|
|
|
|
case DRD_LOG_TYPE_ID_WARNING:
|
|
{
|
|
type = DRG_LV2UI_Base.Logger.Warning;
|
|
break;
|
|
}
|
|
|
|
case DRD_LOG_TYPE_ID_ERROR:
|
|
case DRD_LOG_TYPE_ID_UNKNOWN:
|
|
default:
|
|
{
|
|
type = DRG_LV2UI_Base.Logger.Error;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if( lv2_log_vprintf( &(DRG_LV2UI_Base.Logger), type, Out_Fmt, Args) == 0)
|
|
{
|
|
fprintf( stderr, "LV2 logger error...\n");
|
|
}
|
|
|
|
return( DRS_OK);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* DR_LV2UI_Map_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->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_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->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->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");
|
|
*/
|
|
/*
|
|
}
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
static void send_ui_disable( LV2UI_Handle handle)
|
|
{
|
|
fprintf( stderr, "send_ui_disable called!\n");
|
|
|
|
/*
|
|
EgScopeUI* ui = (EgScopeUI*)handle;
|
|
send_ui_state(handle);
|
|
|
|
uint8_t obj_buf[64];
|
|
lv2_atom_forge_set_buffer(&ui->forge, obj_buf, sizeof(obj_buf));
|
|
|
|
LV2_Atom_Forge_Frame frame;
|
|
LV2_Atom* msg =
|
|
(LV2_Atom*)lv2_atom_forge_object(&ui->forge, &frame, 0, ui->uris.ui_Off);
|
|
|
|
assert(msg);
|
|
|
|
lv2_atom_forge_pop(&ui->forge, &frame);
|
|
ui->write(ui->controller,
|
|
0,
|
|
lv2_atom_total_size(msg),
|
|
ui->uris.atom_eventTransfer,
|
|
msg);
|
|
*/
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
static void send_ui_enable( LV2UI_Handle handle)
|
|
{
|
|
fprintf( stderr, "send_ui_enable called!\n");
|
|
|
|
/*
|
|
EgScopeUI* ui = (EgScopeUI*)handle;
|
|
|
|
uint8_t obj_buf[64];
|
|
lv2_atom_forge_set_buffer(&ui->forge, obj_buf, sizeof(obj_buf));
|
|
|
|
LV2_Atom_Forge_Frame frame;
|
|
LV2_Atom* msg =
|
|
(LV2_Atom*)lv2_atom_forge_object(&ui->forge, &frame, 0, ui->uris.ui_On);
|
|
|
|
assert(msg);
|
|
|
|
lv2_atom_forge_pop(&ui->forge, &frame);
|
|
ui->write(ui->controller,
|
|
0,
|
|
lv2_atom_total_size(msg),
|
|
ui->uris.atom_eventTransfer,
|
|
msg);
|
|
*/
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* DR_LV2UI_UI_Enable_Send */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
static DRT_Status DR_LV2UI_UI_Enable_Send( void)
|
|
{
|
|
uint8_t obj_buf[64];
|
|
LV2_Atom_Forge_Frame set_frame;
|
|
LV2_Atom *msg;
|
|
|
|
|
|
DR_LOG_INFO_0( "UI Enable Send!");
|
|
|
|
|
|
|
|
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.UI_Enable, 0);
|
|
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);
|
|
|
|
|
|
// EgScopeUI *ui = (EgScopeUI*)handle;
|
|
/*
|
|
uint8_t obj_buf[64];
|
|
|
|
lv2_atom_forge_set_buffer( &( DRG_LV2UI_Base.Forge), obj_buf, sizeof(obj_buf));
|
|
|
|
LV2_Atom_Forge_Frame frame;
|
|
LV2_Atom* msg = (LV2_Atom*)lv2_atom_forge_object( &( DRG_LV2UI_Base.Forge), &frame, 0, DRG_LV2UI_Base.URIS.UI_Open);
|
|
|
|
assert(msg);
|
|
|
|
lv2_atom_forge_pop( &( DRG_LV2UI_Base.Forge), &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);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* DR_LV2UI_UI_Disable_Send */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
static DRT_Status DR_LV2UI_UI_Disable_Send( void)
|
|
{
|
|
uint8_t obj_buf[64];
|
|
LV2_Atom_Forge_Frame set_frame;
|
|
LV2_Atom *msg;
|
|
|
|
|
|
DR_LOG_INFO_0( "UI Disable Send!");
|
|
|
|
|
|
|
|
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.UI_Disable, 0);
|
|
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);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* DR_LV2UI_Kit_Id_Update_Request_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);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
static gboolean on_cfg_changed( GtkWidget *widget, gpointer data)
|
|
{
|
|
fprintf( stderr, "on_cfg_changed called!\n");
|
|
|
|
/*
|
|
EgScopeUI* ui = (EgScopeUI*)data;
|
|
if (!ui->updating) {
|
|
// Only send UI state if the change is from user interaction
|
|
send_ui_state(data);
|
|
}
|
|
*/
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* DR_LV2UI_Expose_Callback */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
static gulong DRG_LV2UI_Expose_Id;
|
|
|
|
static gboolean DR_LV2UI_Expose_Callback (GtkWidget *widget, GdkEventExpose *event, gpointer data)
|
|
{
|
|
DR_LOG_INFO_0( "Expose Callback called!");
|
|
|
|
/*
|
|
DrMrUi *ui = (DrMrUi*)data;
|
|
uint8_t msg_buf[1024];
|
|
lv2_atom_forge_set_buffer(&ui->forge, msg_buf, 1024);
|
|
LV2_Atom *msg = build_get_state_message(ui);
|
|
ui->write(ui->controller,DRMR_CONTROL,
|
|
lv2_atom_total_size(msg),
|
|
ui->uris.atom_eventTransfer,
|
|
msg);
|
|
g_signal_handler_disconnect(widget,expose_id);
|
|
*/
|
|
|
|
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* DR_LV2UI_Title_Label_Set */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
static void DR_LV2UI_Title_Label_Set( DRT_Kit_Id Kit_Id)
|
|
{
|
|
DRT_Status status;
|
|
DRT_Kit *kit_ptr;
|
|
char *kit_name_ptr;
|
|
uint8_t bank_id_lsb, bank_id_msb, program_id;
|
|
|
|
|
|
DR_Kit_Id_Convert( &bank_id_lsb, &bank_id_msb, &program_id, Kit_Id);
|
|
|
|
|
|
if( ( status = DR_Kit_Logical_Id_Find( &kit_ptr, Kit_Id)) != DRS_OK)
|
|
{
|
|
DR_LOG_WARNING_4( "Can't find kit id: (%d) Bank/Program: (%d/%d/%d)!", Kit_Id, bank_id_lsb, bank_id_msb, program_id);
|
|
|
|
kit_name_ptr = "No kit loaded";
|
|
}
|
|
else
|
|
{
|
|
kit_name_ptr = kit_ptr->Name;
|
|
}
|
|
|
|
|
|
snprintf( DRG_LV2UI_Base.Title_Label_Buf, 128, "<b>%s</b>", kit_name_ptr);
|
|
|
|
// snprintf( DRG_LV2UI_Base.Bank_Program_Label_Buf, 64, " Id: <b>%d</b> Bank/Program: (<b>%d</b> / <b>%d</b> / <b>%d</b>)", Kit_Id, bank_id_lsb, bank_id_msb, program_id);
|
|
|
|
gtk_label_set_markup( GTK_LABEL( DRG_LV2UI_Base.Title_Label_Ptr), DRG_LV2UI_Base.Title_Label_Buf);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* DR_LV2UI_Id_Bank_Program_Label_Set */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
static void DR_LV2UI_Id_Bank_Program_Label_Set( DRT_Kit_Id Kit_Id)
|
|
{
|
|
uint8_t bank_id_lsb, bank_id_msb, program_id;
|
|
|
|
|
|
DR_Kit_Id_Convert( &bank_id_lsb, &bank_id_msb, &program_id, Kit_Id);
|
|
|
|
snprintf( DRG_LV2UI_Base.Id_Bank_Program_Label_Buf, 128, " Id: <b>%d</b> Bank/Program: (<b>%d</b> / <b>%d</b> / <b>%d</b>)", Kit_Id, bank_id_lsb, bank_id_msb, program_id);
|
|
|
|
gtk_label_set_markup( GTK_LABEL( DRG_LV2UI_Base.Id_Bank_Program_Label_Ptr), DRG_LV2UI_Base.Id_Bank_Program_Label_Buf);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* DR_LV2UI_Kit_ComboBox_Create */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
static GtkWidget *DR_LV2UI_Kit_ComboBox_Create( void)
|
|
{
|
|
DRT_Status status;
|
|
DRT_Kit_Name *kit_name_tab;
|
|
DRT_Kit_Id kit_number;
|
|
|
|
GtkWidget *combobox_ptr;
|
|
GtkListStore *list_store_ptr;
|
|
GtkCellRenderer *cell_ptr;
|
|
GtkTreeIter iter;
|
|
int i;
|
|
char label[8];
|
|
|
|
|
|
/*
|
|
NDT_Node *node_cur_ptr;
|
|
DRT_Kit *kit_cur_ptr;
|
|
*/
|
|
|
|
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)
|
|
{
|
|
DR_LOG_ERROR_1( "Can't get kit names: (%d)", status);
|
|
}
|
|
else
|
|
{
|
|
for( i = 0; i < kit_number; i++)
|
|
{
|
|
gtk_list_store_append( list_store_ptr, &iter);
|
|
gtk_list_store_set( list_store_ptr, &iter, 0, kit_name_tab[i].Name, 1, kit_name_tab[i].Id,-1);
|
|
}
|
|
}
|
|
|
|
free( kit_name_tab);
|
|
|
|
combobox_ptr = gtk_combo_box_new_with_model( GTK_TREE_MODEL( list_store_ptr));
|
|
|
|
gtk_combo_box_set_active( GTK_COMBO_BOX( combobox_ptr), -1);
|
|
|
|
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)
|
|
{
|
|
GtkTreeModel *model_ptr;
|
|
GtkTreeIter iter;
|
|
|
|
|
|
DRG_LV2UI_Base.Kit_Id = (float)gtk_combo_box_get_active( GTK_COMBO_BOX( ComboBox_Ptr));
|
|
/*
|
|
|
|
model_ptr = gtk_combo_box_get_model( GTK_COMBO_BOX( ComboBox_Ptr));
|
|
|
|
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);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* 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_LV2UI_Title_Label_Set( DRG_LV2UI_Base.Kit_Id);
|
|
DR_LV2UI_Id_Bank_Program_Label_Set( DRG_LV2UI_Base.Kit_Id);
|
|
|
|
|
|
DR_LOG_INFO_1( "Kit_Update_Reply: Id: (%d)!", Kit_Id);
|
|
|
|
return( DRS_OK);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* DR_LV2UI_Channel_Id_ComboBox_Create */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
static GtkWidget *DR_LV2UI_Channel_Id_ComboBox_Create( void)
|
|
{
|
|
GtkWidget *combobox_ptr;
|
|
GtkListStore *list_store_ptr;
|
|
GtkCellRenderer *cell_ptr;
|
|
GtkTreeIter iter;
|
|
int i;
|
|
char label[8];
|
|
|
|
|
|
list_store_ptr = gtk_list_store_new( 1, G_TYPE_STRING);
|
|
|
|
gtk_list_store_append( list_store_ptr, &iter);
|
|
gtk_list_store_set( list_store_ptr, &iter, 0, "Omni", -1);
|
|
|
|
for( i = 1; i <= 16; i++)
|
|
{
|
|
sprintf( label, "%02d", i);
|
|
gtk_list_store_append( list_store_ptr, &iter);
|
|
gtk_list_store_set( list_store_ptr, &iter, 0, label, -1);
|
|
}
|
|
|
|
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_Channel_Id_ComboBox_Change */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
static void DR_LV2UI_Channel_Id_ComboBox_Changed( GtkComboBox *ComboBox_Ptr, gpointer Data_Ptr)
|
|
{
|
|
DRG_LV2UI_Base.Channel_Id = (float)gtk_combo_box_get_active( GTK_COMBO_BOX( ComboBox_Ptr));
|
|
|
|
DR_LOG_INFO_1( "Channel_Id_ComboBox_Changed: Id: (%d)!", (int)( DRG_LV2UI_Base.Channel_Id));
|
|
|
|
DRG_LV2UI_Base.Write( DRG_LV2UI_Base.Controller, DRD_LV2_CHANNEL_ID, 4, 0, &( DRG_LV2UI_Base.Channel_Id));
|
|
|
|
// return( FALSE);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* DR_LV2UI_Base_Note_Label_Set */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
static void DR_LV2UI_Base_Note_Label_Set( int Note_Id)
|
|
{
|
|
int oct = ( Note_Id / 12) - 1;
|
|
int nmt = ( Note_Id % 12) * 2;
|
|
|
|
|
|
snprintf( DRG_LV2UI_Base.Base_Note_Label_Buf, 32, "Midi Base Note <b>(%c%c%i)</b>:", DRG_LV2UI_Note_String[nmt], DRG_LV2UI_Note_String[nmt+1], oct);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* DR_LV2UI_Base_Note_Spin_Change */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
static void DR_LV2UI_Base_Note_Spin_Changed( GtkSpinButton *Spin_Ptr, gpointer Data_Ptr)
|
|
{
|
|
float base = (float)gtk_spin_button_get_value( Spin_Ptr);
|
|
|
|
|
|
if( base >= 21.0f && base <= 107.0f)
|
|
{
|
|
DRG_LV2UI_Base.Base_Note = 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));
|
|
|
|
DR_LV2UI_Base_Note_Label_Set( (int)base);
|
|
gtk_label_set_markup( GTK_LABEL( DRG_LV2UI_Base.Base_Note_Label_Ptr), DRG_LV2UI_Base.Base_Note_Label_Buf);
|
|
}
|
|
else
|
|
{
|
|
fprintf( stderr,"Base spin got out of range: %f\n",base);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* DR_LV2UI_Position_Id_ComboBox_Create */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
static GtkWidget *DR_LV2UI_Position_Id_ComboBox_Create( void)
|
|
{
|
|
GtkWidget *combobox_ptr;
|
|
GtkListStore *list_store_ptr;
|
|
GtkCellRenderer *cell_ptr;
|
|
GtkTreeIter iter;
|
|
|
|
|
|
list_store_ptr = gtk_list_store_new( 1, G_TYPE_STRING);
|
|
|
|
gtk_list_store_append( list_store_ptr, &iter);
|
|
gtk_list_store_set( list_store_ptr, &iter, 0, "Top Left", -1);
|
|
gtk_list_store_append( list_store_ptr, &iter);
|
|
gtk_list_store_set( list_store_ptr, &iter, 0, "Bottom Left", -1);
|
|
gtk_list_store_append( list_store_ptr, &iter);
|
|
gtk_list_store_set( list_store_ptr, &iter, 0, "Top Right", -1);
|
|
gtk_list_store_append( list_store_ptr, &iter);
|
|
gtk_list_store_set( list_store_ptr, &iter, 0, "Bottom Right", -1);
|
|
|
|
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_Position_Id_ComboBox_Change */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
static void DR_LV2UI_Position_Id_ComboBox_Changed( GtkComboBox *ComboBox_Ptr, gpointer Data_Ptr)
|
|
{
|
|
DRG_LV2UI_Base.Position_Id = (float)gtk_combo_box_get_active( GTK_COMBO_BOX( ComboBox_Ptr));
|
|
|
|
DR_LOG_INFO_1( "Position_Id_ComboBox_Changed: Id: (%d)!", (int)( DRG_LV2UI_Base.Position_Id));
|
|
|
|
// DRG_LV2UI_Base.Write( DRG_LV2UI_Base.Controller, DRD_LV2_POSITION_ID, 4, 0, &( DRG_LV2UI_Base.Position_Id));
|
|
|
|
// return( FALSE);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* DR_LV2UI_Velocity_Ignore_Flag_Toggled */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
static gboolean DR_LV2UI_Velocity_Ignore_Flag_Toggled( GtkToggleButton *Button_Ptr, gpointer Data_Ptr)
|
|
{
|
|
DRG_LV2UI_Base.Velocity_Ignore_Flag = (float)gtk_toggle_button_get_active( Button_Ptr);
|
|
|
|
DR_LOG_INFO_1( "Velocity_Ignore_Flag_Toggled called: State: (%d)!", (int)( DRG_LV2UI_Base.Velocity_Ignore_Flag));
|
|
|
|
DRG_LV2UI_Base.Write( DRG_LV2UI_Base.Controller, DRD_LV2_VELOCITY_IGNORE_FLAG, 4, 0, &( DRG_LV2UI_Base.Velocity_Ignore_Flag));
|
|
|
|
return( FALSE);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* DR_LV2UI_Note_Off_Ignore_Flag_Toggled */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
static gboolean DR_LV2UI_Note_Off_Ignore_Flag_Toggled( GtkToggleButton *Button_Ptr, gpointer Data_Ptr)
|
|
{
|
|
DRG_LV2UI_Base.Note_Off_Ignore_Flag = (float)gtk_toggle_button_get_active( Button_Ptr);
|
|
|
|
DR_LOG_INFO_1( "Note_Off_Ignore_Flag_Toggled called: State: (%d)!", (int)( DRG_LV2UI_Base.Note_Off_Ignore_Flag));
|
|
|
|
DRG_LV2UI_Base.Write( DRG_LV2UI_Base.Controller, DRD_LV2_NOTE_OFF_IGNORE_FLAG, 4, 0, &( DRG_LV2UI_Base.Note_Off_Ignore_Flag));
|
|
|
|
return( FALSE);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* DR_LV2UI_Build */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
DRT_Status DR_LV2UI_UI_Build( GtkWidget **Main_Widget_Ptr_Ptr)
|
|
{
|
|
GtkWidget *opts_hbox1_ptr, *opts_hbox2_ptr, *kit_hbox_ptr, *base_note_hbox_ptr, *channel_id_hbox_ptr, *position_id_hbox_ptr,
|
|
*title_label_ptr, *kit_label_ptr, *kit_combobox_ptr, *id_bank_program_label_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;
|
|
GtkAdjustment *base_note_adj_ptr;
|
|
|
|
*Main_Widget_Ptr_Ptr = gtk_vbox_new( false, 0);
|
|
DRG_LV2UI_Expose_Id = g_signal_connect( *Main_Widget_Ptr_Ptr, "expose-event", G_CALLBACK( DR_LV2UI_Expose_Callback), &DRG_LV2UI_Base);
|
|
|
|
g_object_set( *Main_Widget_Ptr_Ptr, "border-width", 6, NULL);
|
|
|
|
/* Option Boxes */
|
|
opts_hbox1_ptr = gtk_hbox_new( false, 0);
|
|
opts_hbox2_ptr = gtk_hbox_new( false, 0);
|
|
|
|
// Title Label
|
|
title_label_ptr = gtk_label_new( "No kit Loaded");
|
|
gtk_label_set_use_markup( GTK_LABEL( title_label_ptr), true);
|
|
|
|
// Kit
|
|
kit_label_ptr = gtk_label_new( "Kit: ");
|
|
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, true, false, 0);
|
|
gtk_box_pack_start( GTK_BOX( kit_hbox_ptr), kit_combobox_ptr, false, false, 0);
|
|
|
|
// Id Bank Program
|
|
id_bank_program_label_ptr = gtk_label_new( " Id:? Bank/Program: (?/?/?) ");
|
|
gtk_label_set_use_markup( GTK_LABEL( id_bank_program_label_ptr), true);
|
|
|
|
// 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, true, false, 0);
|
|
gtk_box_pack_start( GTK_BOX( base_note_hbox_ptr), base_note_spin_ptr, false, 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();
|
|
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);
|
|
|
|
// Sample Zero Position Id
|
|
position_id_hbox_ptr = gtk_hbox_new( false, 0);
|
|
position_id_label_ptr = gtk_label_new( "Sample Zero Position: ");
|
|
|
|
position_id_combobox_ptr = DR_LV2UI_Position_Id_ComboBox_Create();
|
|
gtk_box_pack_start( GTK_BOX( position_id_hbox_ptr), position_id_label_ptr, true, false, 0);
|
|
gtk_box_pack_start( GTK_BOX( position_id_hbox_ptr), position_id_combobox_ptr, false, false, 0);
|
|
|
|
// Velocity Ignore
|
|
velocity_ignore_flag_checkbox_ptr = gtk_check_button_new_with_label( "Ignore Velocity");
|
|
|
|
// Note Off Ignore
|
|
note_off_ignore_flag_checkbox_ptr = gtk_check_button_new_with_label( "Ignore Note Off");
|
|
|
|
|
|
// 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), id_bank_program_label_ptr, false, 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);
|
|
|
|
gtk_box_pack_start( GTK_BOX( *Main_Widget_Ptr_Ptr), title_label_ptr, false, false, 5);
|
|
gtk_box_pack_start( GTK_BOX( *Main_Widget_Ptr_Ptr), opts_hbox1_ptr, false, false, 5);
|
|
gtk_box_pack_start( GTK_BOX( *Main_Widget_Ptr_Ptr), opts_hbox2_ptr, false, false, 5);
|
|
|
|
// Signals
|
|
g_signal_connect( G_OBJECT( kit_combobox_ptr), "changed", G_CALLBACK( DR_LV2UI_Kit_ComboBox_Changed), &DRG_LV2UI_Base);
|
|
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);
|
|
g_signal_connect( G_OBJECT( note_off_ignore_flag_checkbox_ptr), "toggled", G_CALLBACK( DR_LV2UI_Note_Off_Ignore_Flag_Toggled), &DRG_LV2UI_Base);
|
|
|
|
|
|
// Save
|
|
DRG_LV2UI_Base.Main_Widget_Ptr = *Main_Widget_Ptr_Ptr;
|
|
DRG_LV2UI_Base.Title_Label_Ptr = title_label_ptr;
|
|
DRG_LV2UI_Base.Kit_ComboBox_Ptr = kit_combobox_ptr;
|
|
DRG_LV2UI_Base.Id_Bank_Program_Label_Ptr = id_bank_program_label_ptr;
|
|
DRG_LV2UI_Base.Channel_ComboBox_Ptr = channel_id_combobox_ptr;
|
|
DRG_LV2UI_Base.Base_Note_Label_Ptr = base_note_label_ptr;
|
|
DRG_LV2UI_Base.Base_Note_Spin_Ptr = base_note_spin_ptr;
|
|
DRG_LV2UI_Base.Position_ComboBox_Ptr = position_id_combobox_ptr;
|
|
DRG_LV2UI_Base.Velocity_Ignore_Flag_CheckBox_Ptr = velocity_ignore_flag_checkbox_ptr;
|
|
DRG_LV2UI_Base.Note_Off_Ignore_Flag_CheckBox_Ptr = note_off_ignore_flag_checkbox_ptr;
|
|
|
|
gtk_widget_show_all( *Main_Widget_Ptr_Ptr);
|
|
|
|
DR_LOG_INFO_0( "UI Build completed!");
|
|
|
|
return( DRS_OK);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* DR_LV2UI_Instantiate */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
static LV2UI_Handle DR_LV2UI_Instantiate( const LV2UI_Descriptor *LV2UI_Descriptor,
|
|
const char *Plugin_URI,
|
|
const char *Bundle_Path,
|
|
LV2UI_Write_Function Write_Function,
|
|
LV2UI_Controller Controller,
|
|
LV2UI_Widget *Widget_Ptr_Ptr,
|
|
const LV2_Feature * const *LV2_Features_Ptr)
|
|
{
|
|
DRT_Status status;
|
|
|
|
|
|
fprintf( stderr, "instanciate called!\n");
|
|
|
|
DRG_LV2UI_Base.Write = Write_Function;
|
|
DRG_LV2UI_Base.Controller = Controller;
|
|
*Widget_Ptr_Ptr = NULL;
|
|
|
|
DRG_LV2UI_Base.Velocity_Ignore_Flag = 0;
|
|
DRG_LV2UI_Base.Note_Off_Ignore_Flag = 0;
|
|
|
|
while( *LV2_Features_Ptr != NULL)
|
|
{
|
|
fprintf( stderr, "Feature URI: [%s]\n", (*LV2_Features_Ptr)->URI);
|
|
|
|
if( !strcmp( ( *LV2_Features_Ptr)->URI, LV2_URID_URI "#map"))
|
|
{
|
|
DRG_LV2UI_Base.Map_Ptr = (LV2_URID_Map *)( ( *LV2_Features_Ptr)->data);
|
|
}
|
|
else
|
|
{
|
|
if( !strcmp( ( *LV2_Features_Ptr)->URI, LV2_LOG__log))
|
|
{
|
|
DRG_LV2UI_Base.Logger.log = (LV2_Log_Log *)( ( *LV2_Features_Ptr)->data);
|
|
}
|
|
}
|
|
|
|
LV2_Features_Ptr++;
|
|
}
|
|
|
|
if( ( DRG_LV2UI_Base.Map_Ptr == NULL) || ( DRG_LV2UI_Base.Logger.log == NULL))
|
|
{
|
|
if( DRG_LV2UI_Base.Map_Ptr == NULL)
|
|
{
|
|
fprintf( stderr, "LV2 host does not support urid#map!\n");
|
|
}
|
|
|
|
if( DRG_LV2UI_Base.Logger.log == NULL)
|
|
{
|
|
fprintf( stderr, "LV2 host does not support log#log!\n");
|
|
}
|
|
|
|
return( NULL);
|
|
}
|
|
else
|
|
{
|
|
// lv2_log_logger_init( &(DRG_LV2UI_Base.Logger), DRG_LV2UI_Base.Map_Ptr, DRG_LV2UI_Base.Logger.log);
|
|
lv2_log_logger_set_map( &(DRG_LV2UI_Base.Logger), DRG_LV2UI_Base.Map_Ptr);
|
|
|
|
DRG_Base.Log_Stream_Out = stderr;
|
|
DRG_Base.Log_Writer_Ptr = DRD_LOG_WRITER_DEFAULT;
|
|
|
|
if( ( status = DR_DataStruct_Init( DRD_LOG_WRITER_DEFAULT, DRD_SAMPLE_RATE_DEFAULT, DRD_THREAD_NUMBER_DEFAULT)) != DRS_OK)
|
|
{
|
|
fprintf( stderr, "Can't init data structures (%d)!\n", status);
|
|
}
|
|
else
|
|
{
|
|
lv2_log_error( &(DRG_LV2UI_Base.Logger), "UI: Test error log <%s>!\n", "Krash!");
|
|
DR_LOG_ERROR_1( "Test error log <%s>!", "Krash!");
|
|
|
|
// 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);
|
|
|
|
/* Load Local Database copy waiting a shared DataStruct implementation ! */
|
|
if( ( status = DR_Kits_Load()) != DRS_OK)
|
|
{
|
|
fprintf( stderr, "Can't load kits (%d)!\n", status);
|
|
}
|
|
else
|
|
{
|
|
if( DR_LV2UI_UI_Build( (GtkWidget **)Widget_Ptr_Ptr) != DRS_OK)
|
|
{
|
|
return( NULL);
|
|
}
|
|
else
|
|
{
|
|
DR_LV2UI_UI_Enable_Send();
|
|
|
|
return( &DRG_LV2UI_Base);
|
|
}
|
|
}
|
|
}
|
|
|
|
DR_DataStruct_DeInit();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* DR_LV2UI_Cleanup */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
static void DR_LV2UI_Cleanup( LV2UI_Handle Instance_Ptr)
|
|
{
|
|
DR_LOG_INFO_0( "Cleanup called!!");
|
|
|
|
DR_LV2UI_UI_Disable_Send();
|
|
|
|
/*
|
|
EgScopeUI* ui = (EgScopeUI*)handle;
|
|
*/
|
|
/* Send UIOff message to plugin, which will save state and disable message
|
|
* transmission. */
|
|
/*
|
|
send_ui_disable(ui);
|
|
gtk_widget_destroy(ui->darea);
|
|
free(ui);
|
|
*/
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* DR_LV2UI_Port_Event */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
static void DR_LV2UI_Port_Event( LV2UI_Handle Instance_Ptr,
|
|
uint32_t Port_Id,
|
|
uint32_t Buffer_size,
|
|
uint32_t Format,
|
|
const void *Buffer_Ptr)
|
|
{
|
|
DR_LOG_INFO_2( "Port_Event called: Port: (%d) Format: (%d)!", Port_Id, Format);
|
|
|
|
if( Port_Id == DRD_LV2_CORE_EVENT)
|
|
{
|
|
DR_LOG_INFO_0( "Port_Event called: Core Event!");
|
|
|
|
if( Format == DRG_LV2UI_Base.URIS.Atom_EventTransfer)
|
|
{
|
|
LV2_Atom *atom = (LV2_Atom *)Buffer_Ptr;
|
|
|
|
if( atom->type == DRG_LV2UI_Base.URIS.Atom_Object)
|
|
{
|
|
LV2_Atom_Object *obj = (LV2_Atom_Object *)atom;
|
|
|
|
if( obj->body.otype == DRG_LV2UI_Base.URIS.UI_Msg)
|
|
{
|
|
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 *note_off_ignore_flag_ptr = NULL;
|
|
|
|
lv2_atom_object_get( obj,
|
|
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.Note_Off_Ignore_Flag_Toggle, ¬e_off_ignore_flag_ptr,
|
|
NULL);
|
|
|
|
if( kit_update_request_ptr)
|
|
{
|
|
DR_LOG_ERROR_0( "Kit Update Request: This shouldn't be received by me!");
|
|
}
|
|
|
|
|
|
if( kit_update_reply_ptr)
|
|
{
|
|
long kit_id;
|
|
|
|
kit_id = ( (const LV2_Atom_Long *)kit_update_reply_ptr)->body;
|
|
|
|
DR_LOG_INFO_1( "Kit Update Reply: Kit_Id: (%ld)!", kit_id);
|
|
|
|
DR_LV2UI_Kit_Update_Reply( kit_id);
|
|
|
|
/*
|
|
int end;
|
|
long count, i;
|
|
|
|
|
|
LV2_ATOM_TUPLE_FOREACH( (const LV2_Atom_Tuple *)kit_name_tab_ptr, iter)
|
|
{
|
|
end = lv2_atom_tuple_is_end( LV2_ATOM_BODY( (const LV2_Atom_Tuple *)kit_name_tab_ptr), ((const LV2_Atom_Tuple *)kit_name_tab_ptr)->atom.size, lv2_atom_tuple_next( iter));
|
|
|
|
DR_LOG_INFO_3( "ATOM: type: (%d) size: (%d) Value: (%ld)", iter->type, iter->size, ( (const LV2_Atom_Long *)iter)->body);
|
|
DR_LOG_INFO_3( "ATOM: Iter: (%lx) size: (%ld) End: (%d)", lv2_atom_tuple_next( iter), ((const LV2_Atom_Tuple *)kit_name_tab_ptr)->atom.size, end);
|
|
|
|
if( iter->type == DRG_LV2UI_Base.URIS.Long_URId)
|
|
{
|
|
count = ( (const LV2_Atom_Long *)iter)->body;
|
|
DR_LOG_INFO_1( "ATOM: Long: (%ld)!", count);
|
|
}
|
|
else
|
|
{
|
|
if( iter->type == DRG_LV2UI_Base.URIS.String_URId)
|
|
{
|
|
DR_LOG_INFO_0( "ATOM: String!");
|
|
kit_name_tab = (DRT_Kit_Name *)LV2_ATOM_BODY( iter);
|
|
|
|
for( i = 0; i < count; i++)
|
|
{
|
|
DR_LOG_INFO_3( " Kit: #: (%ld) Id: (%ld) Name: [%s]", i, kit_name_tab[i].Id, kit_name_tab[i].Name);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
DR_LOG_INFO_0( "ATOM: ???");
|
|
}
|
|
}
|
|
}
|
|
*/
|
|
|
|
}
|
|
|
|
if( velocity_ignore_flag_ptr)
|
|
{
|
|
DRG_LV2UI_Base.Velocity_Ignore_Flag = ( (const LV2_Atom_Float *)velocity_ignore_flag_ptr)->body;
|
|
|
|
DR_LOG_INFO_1( "UI Msg: Velocity Ignore Flag: (%f)!", DRG_LV2UI_Base.Velocity_Ignore_Flag);
|
|
|
|
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( DRG_LV2UI_Base.Velocity_Ignore_Flag_CheckBox_Ptr), (int)( DRG_LV2UI_Base.Velocity_Ignore_Flag));
|
|
}
|
|
|
|
if( note_off_ignore_flag_ptr)
|
|
{
|
|
DRG_LV2UI_Base.Note_Off_Ignore_Flag = ( (const LV2_Atom_Float *)note_off_ignore_flag_ptr)->body;
|
|
|
|
DR_LOG_INFO_1( "UI Msg: Note Off Ignore Flag: (%f)!", DRG_LV2UI_Base.Note_Off_Ignore_Flag);
|
|
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( DRG_LV2UI_Base.Note_Off_Ignore_Flag_CheckBox_Ptr), (int)( DRG_LV2UI_Base.Note_Off_Ignore_Flag));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
DR_LOG_ERROR_0( "Unknown resource type passed to ui!");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
DR_LOG_ERROR_0( "Non resource message passed to ui!");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
DR_LOG_ERROR_0( "Unknown format!");
|
|
}
|
|
}
|
|
else if( Port_Id == DRD_LV2_CHANNEL_ID)
|
|
{
|
|
DRG_LV2UI_Base.Channel_Id = *(float *)Buffer_Ptr;
|
|
|
|
DR_LOG_INFO_1( "Port_Event called: Channel Id: (%d)!", (int)( DRG_LV2UI_Base.Channel_Id));
|
|
gtk_combo_box_set_active( GTK_COMBO_BOX( DRG_LV2UI_Base.Channel_ComboBox_Ptr), (int)( DRG_LV2UI_Base.Channel_Id));
|
|
}
|
|
else if( Port_Id == DRD_LV2_BASE_NOTE)
|
|
{
|
|
DR_LOG_INFO_0( "Port_Event called: Base Note!");
|
|
}
|
|
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)
|
|
{
|
|
DR_LOG_INFO_0( "Port_Event called: Note Off Ignore Note!");
|
|
}
|
|
else if( Port_Id == DRD_LV2_VELOCITY_IGNORE_FLAG)
|
|
{
|
|
DRG_LV2UI_Base.Velocity_Ignore_Flag = *(float *)Buffer_Ptr;
|
|
|
|
DR_LOG_INFO_1( "Port_Event called: Velocity Ignore Flag: (%d)!", (int)( DRG_LV2UI_Base.Velocity_Ignore_Flag));
|
|
|
|
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( DRG_LV2UI_Base.Velocity_Ignore_Flag_CheckBox_Ptr), (int)( DRG_LV2UI_Base.Velocity_Ignore_Flag));
|
|
}
|
|
else if( Port_Id == DRD_LV2_NOTE_OFF_IGNORE_FLAG)
|
|
{
|
|
DRG_LV2UI_Base.Note_Off_Ignore_Flag = *(float *)Buffer_Ptr;
|
|
|
|
DR_LOG_INFO_1( "Port_Event called: Note Off Ignore Flag: (%d)!", (int)( DRG_LV2UI_Base.Note_Off_Ignore_Flag));
|
|
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( DRG_LV2UI_Base.Note_Off_Ignore_Flag_CheckBox_Ptr), (int)( DRG_LV2UI_Base.Note_Off_Ignore_Flag));
|
|
}
|
|
else if( ( Port_Id >= DRD_LV2_GAIN_00) && ( Port_Id <= DRD_LV2_GAIN_31))
|
|
{
|
|
DR_LOG_INFO_1( "Port_Event called: Gain: (%d)!", ( Port_Id - DRD_LV2_GAIN_00));
|
|
}
|
|
else if( ( Port_Id >= DRD_LV2_PAN_00) && ( Port_Id <= DRD_LV2_PAN_31))
|
|
{
|
|
DR_LOG_INFO_1( "Port_Event called: Pan: (%d)!", ( Port_Id - DRD_LV2_PAN_00));
|
|
}
|
|
else
|
|
{
|
|
DR_LOG_INFO_2( "Port_Event called: Port: (%d) Format: (%d)!", Port_Id, Format);
|
|
DR_LOG_ERROR_0( "Port_Event called: Unknown port!");
|
|
}
|
|
|
|
// if( Format == DRG_LV2UIBase.URIS.Atom_Object)
|
|
|
|
/*
|
|
EgScopeUI* ui = (EgScopeUI*)handle;
|
|
const LV2_Atom* atom = (const LV2_Atom*)buffer;
|
|
|
|
/* Check type of data received
|
|
* - format == 0: Control port event (float)
|
|
* - format > 0: Message (atom)
|
|
*/
|
|
/*
|
|
if (format == ui->uris.atom_eventTransfer &&
|
|
lv2_atom_forge_is_object_type(&ui->forge, atom->type)) {
|
|
const LV2_Atom_Object* obj = (const LV2_Atom_Object*)atom;
|
|
if (obj->body.otype == ui->uris.RawAudio) {
|
|
recv_raw_audio(ui, obj);
|
|
} else if (obj->body.otype == ui->uris.ui_State) {
|
|
recv_ui_state(ui, obj);
|
|
}
|
|
}
|
|
*/
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* LV2UI_Descritor */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
LV2_SYMBOL_EXPORT const LV2UI_Descriptor *lv2ui_descriptor( uint32_t Index)
|
|
{
|
|
switch( Index)
|
|
{
|
|
case 0:
|
|
{
|
|
return &DRG_LV2UI_Descriptor;
|
|
}
|
|
|
|
default:
|
|
{
|
|
return NULL;
|
|
}
|
|
}
|
|
}
|