- Fix memory leaks with valgrind!

- Move data structure management  in datastruct.c and datastruct.h files,
- Prepare LV2 plugin in new lv2_plugin.c and lv2_plugin.h files.
This commit is contained in:
Arnaud G. GIBERT 2022-03-27 11:33:37 +02:00
parent bb02d97272
commit 6be9e0f582
4 changed files with 2796 additions and 0 deletions

1952
datastruct.c Normal file

File diff suppressed because it is too large Load Diff

495
datastruct.h Normal file
View File

@ -0,0 +1,495 @@
/*---------------------------------------------------------------------------------*/
/* Includes */
/*---------------------------------------------------------------------------------*/
#ifndef _DATASTRUCT_H_
#define _DATASTRUCT_H_
/*----------------------------------------------------------------------------*/
/* Global definitions */
/*----------------------------------------------------------------------------*/
typedef short DRT_Boolean;
#define DRD_FALSE ( DRT_Boolean) 0
#define DRD_TRUE ( DRT_Boolean) 1
#define DRD_NO 'n'
#define DRD_YES 'y'
#define DRD_MAX(A,B) (((A) < (B)) ? (B) : (A))
#define DRD_MIN(A,B) (((A) > (B)) ? (B) : (A))
#define NDD_CMD_STATS_GET ( NDT_Command) 65
#define NDD_CMD_SAMPLE_LOAD ( NDT_Command) 66
#define NDD_CMD_SAMPLE_UNLOAD ( NDT_Command) 67
#define NDD_CMD_INDEX0_PRINT ( NDT_Command) 68
#define NDD_CMD_INDEX1_PRINT ( NDT_Command) 69
#define NAME_LEN (short) 256
#define NAME_SIZE (NAME_LEN + 1)
#define DIRNAME_LEN (short) 1024
#define DIRNAME_SIZE (DIRNAME_LEN)
#define FILENAME_LEN (short) 1024
#define FILENAME_SIZE (FILENAME_LEN)
#define DESC_LEN (short) 4096
#define DESC_SIZE (DESC_LEN + 1)
/*---------------------------------------------------------------------------------*/
/* Layer / Instrument / Kit */
/*---------------------------------------------------------------------------------*/
typedef struct DRT_Layer
{
short Id;
char FileName[ FILENAME_SIZE];
float *Sample_Ptr;
long Sample_Size;
SF_INFO *SF_Info_Ptr;
double Min;
double Max;
double Gain;
double Pitch;
} DRT_Layer;
typedef struct DRT_Instrument
{
short Id;
char Name[ NAME_SIZE];
double Gain;
double Pan_Left;
double Pan_Right;
NDT_Root *Layer_DS_Ptr;
} DRT_Instrument;
typedef struct DRT_Kit
{
short Id;
char Name[ NAME_SIZE];
char Desc[ DESC_SIZE];
char DirName[ DIRNAME_SIZE];
NDT_Root *Instrument_DS_Ptr;
} DRT_Kit;
# ifdef _DATASTRUCT_C_
/*----------------------------------------------------------------------------*/
/* Private Definitions */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* Layer_DS Indexes */
/*----------------------------------------------------------------------------*/
#define DRD_LAYER_DS_INDEX_NB (short)2
static NDT_Index_Type DRG_Layer_DS_Index_Tab_Initial[DRD_LAYER_DS_INDEX_NB] =
{
(NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_SORTED),
(NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_SORTED)
};
static NDT_Index_Type DRG_Layer_DS_Index_Tab_Final[DRD_LAYER_DS_INDEX_NB] =
{
(NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED),
(NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED)
};
/*----------------------------------------------------------------------------*/
/* Instrument_DS Indexes */
/*----------------------------------------------------------------------------*/
#define DRD_INSTRUMENT_DS_INDEX_NB (short)2
static NDT_Index_Type DRG_Instrument_DS_Index_Tab_Initial[DRD_INSTRUMENT_DS_INDEX_NB] =
{
(NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_SORTED),
(NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_SORTED)
};
static NDT_Index_Type DRG_Instrument_DS_Index_Tab_Final[DRD_INSTRUMENT_DS_INDEX_NB] =
{
(NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED),
(NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED)
};
/*----------------------------------------------------------------------------*/
/* Kit_DS Indexes */
/*----------------------------------------------------------------------------*/
#define DRD_KIT_DS_INDEX_NB (short)2
static NDT_Index_Type DRG_Kit_DS_Index_Tab_Initial[DRD_KIT_DS_INDEX_NB] =
{
(NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_SORTED),
(NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_SORTED)
};
static NDT_Index_Type DRG_Kit_DS_Index_Tab_Final[DRD_KIT_DS_INDEX_NB] =
{
(NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED),
(NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_TREE | NDD_INDEX_SUBTYPE_BALANCED)
};
/*---------------------------------------------------------------------------------*/
/* XML XPATH Tags */
/*---------------------------------------------------------------------------------*/
#define STR(A) #A
#define TAG(A) STR(A)
#define XML_XPATH_ELEMENT(A) *[local-name()=(A)]
#define XML_SLASH /
#define XML_XPATH_DRUMKIT_BASE_TAG XML_XPATH_ELEMENT('drumkit_info')
#define XML_XPATH_DRUMKIT_NAME_TAG XML_XPATH_ELEMENT('name')
#define XML_XPATH_DRUMKIT_INFO_TAG XML_XPATH_ELEMENT('info')
#define XML_XPATH_DRUMKIT_INSTRUMENTLIST_TAG XML_XPATH_ELEMENT('instrumentList')
#define XML_XPATH_DRUMKIT_INSTRUMENT_TAG XML_XPATH_ELEMENT('instrument')
#define XML_XPATH_DRUMKIT_ID_TAG XML_XPATH_ELEMENT('id')
#define XML_XPATH_DRUMKIT_GAIN_TAG XML_XPATH_ELEMENT('gain')
#define XML_XPATH_DRUMKIT_PAN_LEFT_TAG XML_XPATH_ELEMENT('pan_L')
#define XML_XPATH_DRUMKIT_PAN_RIGHT_TAG XML_XPATH_ELEMENT('pan_R')
#define XML_XPATH_DRUMKIT_INSTRUMENTCOMPONENT_TAG XML_XPATH_ELEMENT('instrumentComponent')
#define XML_XPATH_DRUMKIT_LAYER_TAG XML_XPATH_ELEMENT('layer')
#define XML_XPATH_DRUMKIT_FILENAME_TAG XML_XPATH_ELEMENT('filename')
#define XML_XPATH_DRUMKIT_MIN_TAG XML_XPATH_ELEMENT('min')
#define XML_XPATH_DRUMKIT_MAX_TAG XML_XPATH_ELEMENT('max')
#define XML_XPATH_DRUMKIT_PITCH_TAG XML_XPATH_ELEMENT('pitch')
#define XML_XPATH_DRUMKIT_BASE_STR TAG(/XML_XPATH_DRUMKIT_BASE_TAG)
#define XML_XPATH_DRUMKIT_NAME_STR TAG(/XML_XPATH_DRUMKIT_NAME_TAG)
#define XML_XPATH_DRUMKIT_INFO_STR TAG(/XML_XPATH_DRUMKIT_INFO_TAG)
#define XML_XPATH_DRUMKIT_ID_STR TAG(/XML_XPATH_DRUMKIT_ID_TAG)
#define XML_XPATH_DRUMKIT_GAIN_STR TAG(/XML_XPATH_DRUMKIT_GAIN_TAG)
#define XML_XPATH_DRUMKIT_PAN_LEFT_STR TAG(/XML_XPATH_DRUMKIT_PAN_LEFT_TAG)
#define XML_XPATH_DRUMKIT_PAN_RIGHT_STR TAG(/XML_XPATH_DRUMKIT_PAN_RIGHT_TAG)
#define XML_XPATH_DRUMKIT_FILENAME_STR TAG(/XML_XPATH_DRUMKIT_FILENAME_TAG)
#define XML_XPATH_DRUMKIT_MIN_STR TAG(/XML_XPATH_DRUMKIT_MIN_TAG)
#define XML_XPATH_DRUMKIT_MAX_STR TAG(/XML_XPATH_DRUMKIT_MAX_TAG)
#define XML_XPATH_DRUMKIT_PITCH_STR TAG(/XML_XPATH_DRUMKIT_PITCH_TAG)
#define XML_XPATH_DRUMKIT_KIT_NAME_FULL TAG(/XML_XPATH_DRUMKIT_BASE_TAG/XML_XPATH_DRUMKIT_NAME_TAG)
#define XML_XPATH_DRUMKIT_KIT_INFO_FULL TAG(/XML_XPATH_DRUMKIT_BASE_TAG/XML_XPATH_DRUMKIT_INFO_TAG)
#define XML_XPATH_DRUMKIT_INSTRUMENT_FULL TAG(/XML_XPATH_DRUMKIT_BASE_TAG/XML_XPATH_DRUMKIT_INSTRUMENTLIST_TAG/XML_XPATH_DRUMKIT_INSTRUMENT_TAG[%i])
#define XML_XPATH_DRUMKIT_LAYER_FULL2 TAG(/XML_XPATH_DRUMKIT_BASE_TAG/XML_XPATH_DRUMKIT_INSTRUMENTLIST_TAG/XML_XPATH_DRUMKIT_INSTRUMENT_TAG[%i]/XML_XPATH_DRUMKIT_INSTRUMENTCOMPONENT_TAG/XML_XPATH_DRUMKIT_LAYER_TAG[%i])
#define XML_XPATH_DRUMKIT_LAYER_FULL TAG(/XML_XPATH_DRUMKIT_BASE_TAG/XML_XPATH_DRUMKIT_INSTRUMENTLIST_TAG/XML_XPATH_DRUMKIT_INSTRUMENT_TAG[%i]XML_SLASH/XML_XPATH_DRUMKIT_LAYER_TAG[%i])
/*---------------------------------------------------------------------------------*/
/* LibSamplerate */
/*---------------------------------------------------------------------------------*/
// Quality of conversion for libsamplerate.
// See http://www.mega-nerd.com/SRC/api_misc.html#Converters
// for info about availble qualities
#define RATE_CONV_QUALITY SRC_SINC_MEDIUM_QUALITY
/*---------------------------------------------------------------------------------*/
/* XML_Query */
/*---------------------------------------------------------------------------------*/
#define XML_QUERY_VALUE_UNKNOWN (short) 0
#define XML_QUERY_VALUE_STRING (short) 1
#define XML_QUERY_VALUE_INT (short) 2
#define XML_QUERY_VALUE_LONG (short) 3
#define XML_QUERY_VALUE_LONGLONG (short) 4
#define XML_QUERY_VALUE_FLOAT (short) 5
#define XML_QUERY_VALUE_DOUBLE (short) 6
typedef struct DRT_XML_Query
{
char *Query_Name;
char *XPath_Query;
short Value_Type;
long Value_Offset;
short Value_Len;
} DRT_XML_Query;
DRT_XML_Query DRG_XML_Query_Tab_Layer[] =
{
{ "File Name", XML_XPATH_DRUMKIT_FILENAME_STR, XML_QUERY_VALUE_STRING, offsetof( DRT_Layer, FileName), FILENAME_LEN },
{ "Min", XML_XPATH_DRUMKIT_MIN_STR, XML_QUERY_VALUE_DOUBLE, offsetof( DRT_Layer, Min), 0 },
{ "Max", XML_XPATH_DRUMKIT_MAX_STR, XML_QUERY_VALUE_DOUBLE, offsetof( DRT_Layer, Max), 0 },
{ "Gain", XML_XPATH_DRUMKIT_GAIN_STR, XML_QUERY_VALUE_DOUBLE, offsetof( DRT_Layer, Gain), 0 },
{ "Pitch", XML_XPATH_DRUMKIT_PITCH_STR, XML_QUERY_VALUE_DOUBLE, offsetof( DRT_Layer, Pitch), 0 },
{ NULL, NULL, XML_QUERY_VALUE_UNKNOWN, 0, 0 }
};
DRT_XML_Query DRG_XML_Query_Tab_Instrument[] =
{
{ "Id", XML_XPATH_DRUMKIT_ID_STR, XML_QUERY_VALUE_LONG, offsetof( DRT_Instrument, Id), 0 },
{ "Name", XML_XPATH_DRUMKIT_NAME_STR, XML_QUERY_VALUE_STRING, offsetof( DRT_Instrument, Name), NAME_LEN },
{ "Gain", XML_XPATH_DRUMKIT_GAIN_STR, XML_QUERY_VALUE_DOUBLE, offsetof( DRT_Instrument, Gain), 0 },
{ "Pan_Left", XML_XPATH_DRUMKIT_PAN_LEFT_STR, XML_QUERY_VALUE_DOUBLE, offsetof( DRT_Instrument, Pan_Left), 0 },
{ "Pan_Right", XML_XPATH_DRUMKIT_PAN_RIGHT_STR, XML_QUERY_VALUE_DOUBLE, offsetof( DRT_Instrument, Pan_Right), 0 },
{ NULL, NULL, XML_QUERY_VALUE_UNKNOWN, 0, 0 }
};
DRT_XML_Query DRG_XML_Query_Tab_Kit[] =
{
{ "File", XML_XPATH_DRUMKIT_NAME_STR, XML_QUERY_VALUE_STRING, offsetof( DRT_Kit, Name), NAME_LEN },
{ "Desc", XML_XPATH_DRUMKIT_INFO_STR, XML_QUERY_VALUE_STRING, offsetof( DRT_Kit, Desc), DESC_LEN },
{ NULL, NULL, XML_QUERY_VALUE_UNKNOWN, 0, 0 }
};
# endif // ifdef _DATASTRUCT_C_
# ifndef _DATASTRUCT_C_
/*----------------------------------------------------------------------------*/
/* Public Prototypes */
/*----------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
/* DR_Kit_Sample_Load */
/*---------------------------------------------------------------------------------*/
extern DRT_Status DR_Kit_Sample_Load( DRT_Kit *, double);
/*---------------------------------------------------------------------------------*/
/* DR_Kit_Load */
/*---------------------------------------------------------------------------------*/
extern DRT_Status DR_Kit_Load( DRT_Base *, char *);
/*----------------------------------------------------------------------------*/
/* DR_Kits_Load */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Kits_Load( DRT_Base *);
/*----------------------------------------------------------------------------*/
/* DR_Kits_Dump */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Kits_Dump( DRT_Base *);
/*---------------------------------------------------------------------------------*/
/* DR_DataStruct_Init */
/*---------------------------------------------------------------------------------*/
extern DRT_Status DR_DataStruct_Init( DRT_Base *);
/*---------------------------------------------------------------------------------*/
/* DR_DataStruct_DeInit */
/*---------------------------------------------------------------------------------*/
extern DRT_Status DR_DataStruct_DeInit( DRT_Base *);
# else // ifndef _DATA_STRUCT_C_
/*----------------------------------------------------------------------------*/
/* Private Prototypes */
/*----------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
/* DS Managers */
/*---------------------------------------------------------------------------------*/
NDT_Status DR_Layer_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list *);
NDT_Status DR_Instrument_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list *);
NDT_Status DR_Kit_Manager( NDT_Root *, NDT_Index_Id, NDT_Node *, NDT_Command, va_list *);
/*---------------------------------------------------------------------------------*/
/* DR_Layer_Add */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_Layer_Add( DRT_Layer **, NDT_Root *, DRT_Layer *);
/*---------------------------------------------------------------------------------*/
/* DR_Layer_Sample_Load */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_Layer_Sample_Load( DRT_Layer *, DRT_Kit *, double);
/*---------------------------------------------------------------------------------*/
/* DR_Layer_Sample_UnLoad */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_Layer_Sample_UnLoad( DRT_Layer *);
/*---------------------------------------------------------------------------------*/
/* DR_Layer_Dump */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_Layer_Dump( DRT_Layer *, long);
/*----------------------------------------------------------------------------*/
/* DR_Instrument_Add */
/*----------------------------------------------------------------------------*/
DRT_Status DR_Instrument_Add( DRT_Instrument **, NDT_Root *, DRT_Instrument *);
/*---------------------------------------------------------------------------------*/
/* DR_Instrument_Dump */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_Instrument_Dump( DRT_Instrument *, long);
/*----------------------------------------------------------------------------*/
/* DR_Kit_Add */
/*----------------------------------------------------------------------------*/
DRT_Status DR_Kit_Add( DRT_Kit **, NDT_Root *, DRT_Kit *);
/*---------------------------------------------------------------------------------*/
/* DR_Kit_Sample_Load */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_Kit_Sample_Load( DRT_Kit *, double);
/*---------------------------------------------------------------------------------*/
/* DR_Kit_Dump */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_Kit_Dump( DRT_Kit *, long);
/*---------------------------------------------------------------------------------*/
/* DR_XML_Node_Exist */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_XML_Node_Exist( xmlDocPtr, xmlXPathContextPtr, char *);
/*---------------------------------------------------------------------------------*/
/* DR_XML_Query_Tab_Exec */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_XML_Query_Tab_Exec( void *, xmlDocPtr, xmlXPathContextPtr, char *, DRT_XML_Query *);
/*---------------------------------------------------------------------------------*/
/* DR_XML_Value_Get */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_XML_Value_Get( char *, long, xmlDocPtr, xmlXPathContextPtr, char *, char *);
/*---------------------------------------------------------------------------------*/
/* DR_Kit_Load */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_Kit_Load( DRT_Base *, char *);
/*----------------------------------------------------------------------------*/
/* DR_Kits_Load */
/*----------------------------------------------------------------------------*/
DRT_Status DR_Kits_Load( DRT_Base *);
/*----------------------------------------------------------------------------*/
/* DR_Kits_Dump */
/*----------------------------------------------------------------------------*/
DRT_Status DR_Kits_Dump( DRT_Base *);
/*---------------------------------------------------------------------------------*/
/* DR_DataStruct_Init */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_DataStruct_Init( DRT_Base *);
/*---------------------------------------------------------------------------------*/
/* DR_DataStruct_DeInit */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_DataStruct_DeInit( DRT_Base *);
# endif // ifndef _DATASTRUCT_C_
/*----------------------------------------------------------------------------*/
#endif // ifndef _DATASTRUCT_H_

24
lv2_plugin.c Normal file
View File

@ -0,0 +1,24 @@
/*---------------------------------------------------------------------------------*/
/* Includes */
/*---------------------------------------------------------------------------------*/
#define _LV2_PLUGIN_C_
#include <drummer.h>
/*---------------------------------------------------------------------------------*/
/* */
/*---------------------------------------------------------------------------------*/
static LV2_Handle instantiate(const LV2_Descriptor *descriptor,
double rate,
const char* bundle_path,
const LV2_Feature* const* features)
{
}

325
lv2_plugin.h Normal file
View File

@ -0,0 +1,325 @@
/*---------------------------------------------------------------------------------*/
/* Includes */
/*---------------------------------------------------------------------------------*/
#ifndef _LV2_PLUGIN_H_
#define _LV2_PLUGIN_H_
#include <pthread.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 */
/*----------------------------------------------------------------------------*/
// lv2 stuff
#define DRD_DRUMMER_URI "http://rx3.net/AlkorZ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_PAN_ELEVEN,
DRD_LV2_PAN_TWELVE,
DRD_LV2_PAN_THIRTEEN,
DRD_LV2_PAN_FOURTEEN,
DRD_LV2_PAN_FIFTEEN,
DRD_LV2_PAN_SIXTEEN,
DRD_LV2_PAN_SEVENTEEN,
DRD_LV2_PAN_EIGHTEEN,
DRD_LV2_PAN_NINETEEN,
DRD_LV2_PAN_TWENTY,
DRD_LV2_PAN_TWENTYONE,
DRD_LV2_PAN_TWENTYTWO,
DRD_LV2_PAN_TWENTYTHREE,
DRD_LV2_PAN_TWENTYFOUR,
DRD_LV2_PAN_TWENTYFIVE,
DRD_LV2_PAN_TWENTYSIX,
DRD_LV2_PAN_TWENTYSEVEN,
DRD_LV2_PAN_TWENTYEIGHT,
DRD_LV2_PAN_TWENTYNINE,
DRD_LV2_PAN_THIRTY,
DRD_LV2_PAN_THIRTYONE,
DRD_LV2_PAN_THIRTYTWO,
DRD_LV2_CORE_EVENT,
DRD_LV2_NUM_PORTS
} DRT_Port_Index;
typedef struct
{
LV2_URID midi_event;
LV2_URID ui_msg;
LV2_URID kit_path;
LV2_URID atom_eventTransfer;
LV2_URID atom_object;
LV2_URID string_urid;
LV2_URID bool_urid;
LV2_URID int_urid;
LV2_URID get_state;
LV2_URID midi_info;
LV2_URID sample_trigger;
LV2_URID velocity_toggle;
LV2_URID note_off_toggle;
LV2_URID channel_nb;
LV2_URID zero_position;
LV2_URID sample_add;
LV2_URID sample_remove;
} DRT_Drummer_URIS;
typedef struct
{
// Ports
float *Master_Left;
float *Master_Right;
float **Left;
float **Right;
LV2_Atom_Sequence *Control_Port;
LV2_Atom_Sequence *Core_Event_Port;
LV2_Atom_Forge Forge;
} DRT_LV2_Base;
typedef struct
{
// Ports
float *master_left;
float *master_right;
float **left;
float **right;
LV2_Atom_Sequence *control_port;
LV2_Atom_Sequence *core_event_port;
LV2_Atom_Forge forge;
// params
int channel;
bool ignore_velocity;
bool ignore_note_off;
int channel_nb;
int zero_position;
float **gains;
float **pans;
float *baseNote;
double rate;
// URIs
LV2_URID_Map *map;
drmr_uris uris;
// Kit info
char *current_path;
char **request_buf;
int curReq;
// Samples
drmr_sample *samples;
uint8_t num_samples;
// loading thread stuff
pthread_mutex_t load_mutex;
pthread_cond_t load_cond;
pthread_t load_thread;
} DrMr;
static inline void map_drmr_uris( LV2_URID_Map *map, drmr_uris *uris)
{
uris->midi_event = map->map(map->handle, "http://lv2plug.in/ns/ext/midi#MidiEvent");
uris->string_urid = map->map(map->handle, LV2_ATOM__String);
uris->bool_urid = map->map(map->handle, LV2_ATOM__Bool);
uris->int_urid = map->map(map->handle, LV2_ATOM__Int);
uris->ui_msg = map->map(map->handle, DRD_LV2_URI "#uimsg");
uris->kit_path = map->map(map->handle, DRD_LV2_URI "#kitpath");
uris->get_state = map->map(map->handle, DRD_LV2_URI "#getstate");
uris->midi_info = map->map(map->handle, DRD_LV2_URI "#midiinfo");
uris->sample_trigger = map->map(map->handle, DRD_LV2_URI "#sampletrigger");
uris->velocity_toggle = map->map(map->handle, DRD_LV2_URI "#velocitytoggle");
uris->note_off_toggle = map->map(map->handle, DRD_LV2_URI "#noteofftoggle");
uris->channel_nb = map->map(map->handle, DRD_LV2_URI "#channelnb");
uris->zero_position = map->map(map->handle, DRD_LV2_URI "#zeroposition");
uris->sample_add = map->map(map->handle, DRD_LV2_URI "#sampleadd");
uris->sample_remove = map->map(map->handle, DRD_LV2_URI "#sampleremove");
uris->atom_eventTransfer = map->map(map->handle, LV2_ATOM__eventTransfer);
uris->atom_object = map->map(map->handle, LV2_ATOM__Object);
}
# ifdef _LV2_PLUGIN_C_
/*----------------------------------------------------------------------------*/
/* Private Definitions */
/*----------------------------------------------------------------------------*/
# endif // ifdef _LV2_PLUGIN_C_
# ifndef _LV2_PLUGIN_C_
/*----------------------------------------------------------------------------*/
/* Public Prototypes */
/*----------------------------------------------------------------------------*/
# else // ifndef _LV2_PLUGIN_C_
/*----------------------------------------------------------------------------*/
/* Private Prototypes */
/*----------------------------------------------------------------------------*/
# endif // ifndef _LV2_PLUGIN_C_
/*----------------------------------------------------------------------------*/
#endif // ifndef _LV2_PLUGIN_H_