- Add a new log system support,

- Add LV2 log support,
- Move Base & LV2_Base to global,
- Remove uneeded *Base pointer aguments,
- Code cleanup (to be clompleted)
This commit is contained in:
Arnaud G. GIBERT 2022-05-14 23:53:23 +02:00
parent 843d73655d
commit 4acba194b5
6 changed files with 989 additions and 675 deletions

File diff suppressed because it is too large Load Diff

View File

@ -24,6 +24,8 @@ typedef struct DRT_Kit DRT_Kit;
/* Global definitions */
/*----------------------------------------------------------------------------*/
#define DRD_LOG_WRITER_DEFAULT DR_Log_Write
#define DRD_CHANNEL_ID_DEFAULT 10
#define DRD_BASE_NOTE_DEFAULT 36
#define DRD_VELOCITY_IGNORE_NOTE_DEFAULT 24
@ -42,7 +44,70 @@ typedef struct DRT_Kit DRT_Kit;
/*----------------------------------------------------------------------------*/
/* DSl definitions */
/* Log Definitions */
/*----------------------------------------------------------------------------*/
#define DRD_LOG_TYPE_NB 5
typedef short DRT_Log_Type_Id;
#define DRD_LOG_TYPE_ID_UNKNOWN ( DRT_Log_Type_Id) 0
#define DRD_LOG_TYPE_ID_TRACE ( DRT_Log_Type_Id) 1
#define DRD_LOG_TYPE_ID_INFO ( DRT_Log_Type_Id) 2
#define DRD_LOG_TYPE_ID_WARNING ( DRT_Log_Type_Id) 3
#define DRD_LOG_TYPE_ID_ERROR ( DRT_Log_Type_Id) 4
typedef char *DRT_Log_Type_Name;
#define DRD_LOG_TYPE_NAME_UNKNOWN ( DRT_Log_Type_Name) "???"
#define DRD_LOG_TYPE_NAME_TRACE ( DRT_Log_Type_Name) "TRA"
#define DRD_LOG_TYPE_NAME_INFO ( DRT_Log_Type_Name) "INF"
#define DRD_LOG_TYPE_NAME_WARNING ( DRT_Log_Type_Name) "WRN"
#define DRD_LOG_TYPE_NAME_ERROR ( DRT_Log_Type_Name) "ERR"
typedef short DRT_Log_Level;
#define DRD_LOG_LEVEL_UNKNOWN ( DRT_Log_Level) 0
#define DRD_LOG_LEVEL_DEFAULT ( DRT_Log_Level) 1
#define DR_LOG_TRACE_0( Level, Fmt) DR_Log( DRD_LOG_TYPE_ID_TRACE, (Level), DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt))
#define DR_LOG_TRACE_1( Level, Fmt, Arg1) DR_Log( DRD_LOG_TYPE_ID_TRACE, (Level), DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1))
#define DR_LOG_TRACE_2( Level, Fmt, Arg1, Arg2) DR_Log( DRD_LOG_TYPE_ID_TRACE, (Level), DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2))
#define DR_LOG_TRACE_3( Level, Fmt, Arg1, Arg2, Arg3) DR_Log( DRD_LOG_TYPE_ID_TRACE, (Level), DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2), (Arg3))
#define DR_LOG_TRACE_4( Level, Fmt, Arg1, Arg2, Arg3, Arg4) DR_Log( DRD_LOG_TYPE_ID_TRACE, (Level), DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2), (Arg3), (Arg4))
#define DR_LOG_TRACE_5( Level, Fmt, Arg1, Arg2, Arg3, Arg4, Arg5) DR_Log( DRD_LOG_TYPE_ID_TRACE, (Level), DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2), (Arg3), (Arg4), (Arg5))
#define DR_LOG_TRACE_6( Level, Fmt, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6) DR_Log( DRD_LOG_TYPE_ID_TRACE, (Level), DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2), (Arg3), (Arg4), (Arg5), (Arg6))
#define DR_LOG_INFO_0( Fmt) DR_Log( DRD_LOG_TYPE_ID_INFO, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt))
#define DR_LOG_INFO_1( Fmt, Arg1) DR_Log( DRD_LOG_TYPE_ID_INFO, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1))
#define DR_LOG_INFO_2( Fmt, Arg1, Arg2) DR_Log( DRD_LOG_TYPE_ID_INFO, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2))
#define DR_LOG_INFO_3( Fmt, Arg1, Arg2, Arg3) DR_Log( DRD_LOG_TYPE_ID_INFO, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2), (Arg3))
#define DR_LOG_INFO_4( Fmt, Arg1, Arg2, Arg3, Arg4) DR_Log( DRD_LOG_TYPE_ID_INFO, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2), (Arg3), (Arg4))
#define DR_LOG_INFO_5( Fmt, Arg1, Arg2, Arg3, Arg4, Arg5) DR_Log( DRD_LOG_TYPE_ID_INFO, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2), (Arg3), (Arg4), (Arg5))
#define DR_LOG_INFO_6( Fmt, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6) DR_Log( DRD_LOG_TYPE_ID_INFO, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2), (Arg3), (Arg4), (Arg5), (Arg6))
#define DR_LOG_WARNING_0( Fmt) DR_Log( DRD_LOG_TYPE_ID_WARNING, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt))
#define DR_LOG_WARNING_1( Fmt, Arg1) DR_Log( DRD_LOG_TYPE_ID_WARNING, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1))
#define DR_LOG_WARNING_2( Fmt, Arg1, Arg2) DR_Log( DRD_LOG_TYPE_ID_WARNING, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2))
#define DR_LOG_WARNING_3( Fmt, Arg1, Arg2, Arg3) DR_Log( DRD_LOG_TYPE_ID_WARNING, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2), (Arg3))
#define DR_LOG_WARNING_4( Fmt, Arg1, Arg2, Arg3, Arg4) DR_Log( DRD_LOG_TYPE_ID_WARNING, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2), (Arg3), (Arg4))
#define DR_LOG_WARNING_5( Fmt, Arg1, Arg2, Arg3, Arg4, Arg5) DR_Log( DRD_LOG_TYPE_ID_WARNING, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2), (Arg3), (Arg4), (Arg5))
#define DR_LOG_WARNING_6( Fmt, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6) DR_Log( DRD_LOG_TYPE_ID_WARNING, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2), (Arg3), (Arg4), (Arg5), (Arg6))
#define DR_LOG_ERROR_0( Fmt) DR_Log( DRD_LOG_TYPE_ID_ERROR, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt))
#define DR_LOG_ERROR_1( Fmt, Arg1) DR_Log( DRD_LOG_TYPE_ID_ERROR, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1))
#define DR_LOG_ERROR_2( Fmt, Arg1, Arg2) DR_Log( DRD_LOG_TYPE_ID_ERROR, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2))
#define DR_LOG_ERROR_3( Fmt, Arg1, Arg2, Arg3) DR_Log( DRD_LOG_TYPE_ID_ERROR, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2), (Arg3))
#define DR_LOG_ERROR_4( Fmt, Arg1, Arg2, Arg3, Arg4) DR_Log( DRD_LOG_TYPE_ID_ERROR, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2), (Arg3), (Arg4))
#define DR_LOG_ERROR_5( Fmt, Arg1, Arg2, Arg3, Arg4, Arg5) DR_Log( DRD_LOG_TYPE_ID_ERROR, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2), (Arg3), (Arg4), (Arg5))
#define DR_LOG_ERROR_6( Fmt, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6) DR_Log( DRD_LOG_TYPE_ID_ERROR, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2), (Arg3), (Arg4), (Arg5), (Arg6))
/*----------------------------------------------------------------------------*/
/* Definitions */
/*----------------------------------------------------------------------------*/
#define NDD_CMD_ID_REFRESH ( NDT_Command) 65
@ -174,35 +239,40 @@ typedef struct DRT_Task
/* DRT_Base */
/*---------------------------------------------------------------------------------*/
typedef DRT_Status (*DRT_Log_Writer_Ptr)( DRT_Log_Type_Id, char *, va_list);
typedef int DRT_SampleRate;
typedef struct DRT_Base
{
NDT_Root *Kit_DS_Ptr;
DRT_SampleRate SampleRate;
FILE *Log_Stream_Out;
char *Log_Type_Name_Tab[ DRD_LOG_TYPE_NB];
DRT_Log_Writer_Ptr Log_Writer_Ptr;
NDT_Root *Kit_DS_Ptr;
DRT_SampleRate SampleRate;
//Config
float *Channel_Id_Ptr;
float *Base_Note_Ptr;
float *Velocity_Ignore_Note_Ptr;
float *Note_Off_Ignore_Note_Ptr;
float *Velocity_Ignore_Flag_Ptr;
float *Note_Off_Ignore_Flag_Ptr;
DRT_Task_Id Task_Number;
DRT_Boolean Task_Load_Layer_Flag;
DRT_Boolean Task_Load_Instrument_Flag;
DRT_Boolean Task_Load_Kit_Flag;
DRT_Boolean Task_Sync_Kit_Flag;
DRT_Boolean Task_Sync_Kits_Flag;
DRT_Task *Task_Tab;
pthread_mutex_t Task_Mutex;
pthread_cond_t Task_Cond;
DRT_Task_Id Task_Count_Waiting;
long Task_Count_Run;
long Task_Count_Sleep;
long Task_Count_FakeWU;
float *Channel_Id_Ptr;
float *Base_Note_Ptr;
float *Velocity_Ignore_Note_Ptr;
float *Note_Off_Ignore_Note_Ptr;
float *Velocity_Ignore_Flag_Ptr;
float *Note_Off_Ignore_Flag_Ptr;
DRT_Task_Id Task_Number;
DRT_Boolean Task_Load_Layer_Flag;
DRT_Boolean Task_Load_Instrument_Flag;
DRT_Boolean Task_Load_Kit_Flag;
DRT_Boolean Task_Sync_Kit_Flag;
DRT_Boolean Task_Sync_Kits_Flag;
DRT_Task *Task_Tab;
pthread_mutex_t Task_Mutex;
pthread_cond_t Task_Cond;
DRT_Task_Id Task_Count_Waiting;
long Task_Count_Run;
long Task_Count_Sleep;
long Task_Count_FakeWU;
} DRT_Base;
@ -264,6 +334,22 @@ typedef struct DRT_Kit
/* Private Definitions */
/*----------------------------------------------------------------------------*/
#define DRD_MODULE_NAME "ds"
/*----------------------------------------------------------------------------*/
/* DRT_Base */
/*----------------------------------------------------------------------------*/
DRT_Base DRG_Base =
{
NULL,
{ DRD_LOG_TYPE_NAME_UNKNOWN, DRD_LOG_TYPE_NAME_TRACE, DRD_LOG_TYPE_NAME_INFO, DRD_LOG_TYPE_NAME_WARNING, DRD_LOG_TYPE_NAME_ERROR}
};
/*----------------------------------------------------------------------------*/
/* Layer_DS Indexes */
/*----------------------------------------------------------------------------*/
@ -437,194 +523,36 @@ DRT_XML_Query DRG_XML_Query_Tab_Kit[] =
{ NULL, NULL, DRD_XML_QUERY_VALUE_UNKNOWN, 0, 0 }
};
# endif // ifdef _DATASTRUCT_C_
# ifndef _DATASTRUCT_C_
/*----------------------------------------------------------------------------*/
/* Public Prototypes */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* DR_Layer_Dump */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Layer_Dump( DRT_Layer *, long);
/*---------------------------------------------------------------------------------*/
/* DR_Kit_Id_Find */
/*---------------------------------------------------------------------------------*/
extern DRT_Status DR_Kit_Id_Find( DRT_Kit **, NDT_Root *, DRT_Kit_Id);
/*----------------------------------------------------------------------------*/
/* DR_Kit_Logical_Id_Find */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Kit_Logical_Id_Find( DRT_Kit **, NDT_Root *, DRT_Kit_Id);
/*---------------------------------------------------------------------------------*/
/* DR_Kit_Name_Find */
/*---------------------------------------------------------------------------------*/
extern DRT_Status DR_Kit_Name_Find( DRT_Kit **, NDT_Root *, char *);
/*----------------------------------------------------------------------------*/
/* DR_Kit_Dump */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Kit_Dump( DRT_Kit *, long);
/*---------------------------------------------------------------------------------*/
/* DR_Kit_Load */
/*---------------------------------------------------------------------------------*/
extern DRT_Status DR_Kit_Load( DRT_Base *, char *);
/*---------------------------------------------------------------------------------*/
/* DR_Kit_Sample_Load */
/*---------------------------------------------------------------------------------*/
extern DRT_Status DR_Kit_Sample_Load( DRT_Kit *);
/*---------------------------------------------------------------------------------*/
/* DR_Kit_Sample_UnLoad */
/*---------------------------------------------------------------------------------*/
extern DRT_Status DR_Kit_Sample_UnLoad( DRT_Kit *);
/*----------------------------------------------------------------------------*/
/* DR_Kits_Sample_Load */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Kits_Sample_Load( DRT_Base *);
/*----------------------------------------------------------------------------*/
/* DR_Kits_Sample_UnLoad */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Kits_Sample_UnLoad( DRT_Base *);
/*----------------------------------------------------------------------------*/
/* DR_Kits_Load */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Kits_Load( DRT_Base *);
/*----------------------------------------------------------------------------*/
/* DR_Kits_Stats_Dump */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Kits_Stats_Dump( DRT_Base *);
/*----------------------------------------------------------------------------*/
/* DR_Kits_Dump */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Kits_Dump( DRT_Base *);
/*----------------------------------------------------------------------------*/
/* DR_Kits_Graph_Dump */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Kits_Graph_Dump( DRT_Base *);
/*----------------------------------------------------------------------------*/
/* DR_Task_Id_Run */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Task_Id_Run( DRT_Task_Id, DRT_Base *, DRT_Task_Command, void *);
/*----------------------------------------------------------------------------*/
/* DR_Task_Id_Kill */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Task_Id_Kill( DRT_Task_Id, DRT_Base *);
/*----------------------------------------------------------------------------*/
/* DR_Task_Run */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Task_Run( DRT_Base *, void *);
/*----------------------------------------------------------------------------*/
/* DR_Task_Wait */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Task_Wait( DRT_Base *);
/*----------------------------------------------------------------------------*/
/* DR_Tasks_Dump */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Tasks_Dump( DRT_Base *);
/*---------------------------------------------------------------------------------*/
/* DR_DataStruct_Init */
/*---------------------------------------------------------------------------------*/
extern DRT_Status DR_DataStruct_Init( DRT_Base *, DRT_SampleRate, DRT_Task_Id);
/*---------------------------------------------------------------------------------*/
/* DR_DataStruct_DeInit */
/*---------------------------------------------------------------------------------*/
extern DRT_Status DR_DataStruct_DeInit( DRT_Base *);
# else // ifndef _DATA_STRUCT_C_
/*----------------------------------------------------------------------------*/
/* Private Prototypes */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
DRT_Status DR_Log_Format( char *, DRT_Log_Type_Id, DRT_Log_Level, char *, char *, long, bool, char *);
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
DRT_Status DR_Log_Write( DRT_Log_Type_Id, char *, va_list);
/*----------------------------------------------------------------------------*/
/* DR_Log */
/*----------------------------------------------------------------------------*/
DRT_Status DR_Log( DRT_Log_Type_Id, DRT_Log_Level, char *, char *, long, bool, char *, ...);
/*---------------------------------------------------------------------------------*/
/* DS Managers */
/*---------------------------------------------------------------------------------*/
@ -711,7 +639,7 @@ DRT_Status DR_Kit_Add( DRT_Kit **, NDT_Root *, DRT_Kit *);
/* DR_Kit_Id_Find */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_Kit_Id_Find( DRT_Kit **, NDT_Root *, DRT_Kit_Id);
DRT_Status DR_Kit_Id_Find( DRT_Kit **, DRT_Kit_Id);
@ -719,7 +647,7 @@ DRT_Status DR_Kit_Id_Find( DRT_Kit **, NDT_Root *, DRT_Kit_Id);
/* DR_Kit_Logical_Id_Find */
/*----------------------------------------------------------------------------*/
DRT_Status DR_Kit_Logical_Id_Find( DRT_Kit **, NDT_Root *, DRT_Kit_Id);
DRT_Status DR_Kit_Logical_Id_Find( DRT_Kit **, DRT_Kit_Id);
@ -727,7 +655,7 @@ DRT_Status DR_Kit_Logical_Id_Find( DRT_Kit **, NDT_Root *, DRT_Kit_Id);
/* DR_Kit_Name_Find */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_Kit_Name_Find( DRT_Kit **, NDT_Root *, char *);
DRT_Status DR_Kit_Name_Find( DRT_Kit **, char *);
@ -767,7 +695,7 @@ DRT_Status DR_XML_Value_Get( char *, long, xmlDocPtr, xmlXPathContextPtr, char
/* DR_Kit_Load */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_Kit_Load( DRT_Base *, char *);
DRT_Status DR_Kit_Load( char *);
@ -791,7 +719,7 @@ DRT_Status DR_Kit_Sample_UnLoad( DRT_Kit *);
/* DR_Kits_Sample_Load */
/*----------------------------------------------------------------------------*/
DRT_Status DR_Kits_Sample_Load( DRT_Base *);
DRT_Status DR_Kits_Sample_Load();
@ -799,7 +727,7 @@ DRT_Status DR_Kits_Sample_Load( DRT_Base *);
/* DR_Kits_Sample_UnLoad */
/*----------------------------------------------------------------------------*/
DRT_Status DR_Kits_Sample_UnLoad( DRT_Base *);
DRT_Status DR_Kits_Sample_UnLoad();
@ -807,7 +735,7 @@ DRT_Status DR_Kits_Sample_UnLoad( DRT_Base *);
/* DR_Kits_Load */
/*----------------------------------------------------------------------------*/
DRT_Status DR_Kits_Load( DRT_Base *);
DRT_Status DR_Kits_Load();
@ -815,7 +743,7 @@ DRT_Status DR_Kits_Load( DRT_Base *);
/* DR_Kits_Stats_Dump */
/*----------------------------------------------------------------------------*/
DRT_Status DR_Kits_Stats_Dump( DRT_Base *);
DRT_Status DR_Kits_Stats_Dump();
@ -823,7 +751,7 @@ DRT_Status DR_Kits_Stats_Dump( DRT_Base *);
/* DR_Kits_Dump */
/*----------------------------------------------------------------------------*/
DRT_Status DR_Kits_Dump( DRT_Base *);
DRT_Status DR_Kits_Dump();
@ -831,7 +759,7 @@ DRT_Status DR_Kits_Dump( DRT_Base *);
/* DR_Kits_Graph_Dump */
/*----------------------------------------------------------------------------*/
DRT_Status DR_Kits_Graph_Dump( DRT_Base *);
DRT_Status DR_Kits_Graph_Dump();
@ -839,7 +767,7 @@ DRT_Status DR_Kits_Graph_Dump( DRT_Base *);
/* DR_Task_Tread */
/*----------------------------------------------------------------------------*/
static void *DR_Task_Thread( DRT_Base *);
static void *DR_Task_Thread();
@ -847,7 +775,7 @@ static void *DR_Task_Thread( DRT_Base *);
/* DR_Task_Id_Run */
/*----------------------------------------------------------------------------*/
DRT_Status DR_Task_Id_Run( DRT_Task_Id, DRT_Base *, DRT_Task_Command, void *);
DRT_Status DR_Task_Id_Run( DRT_Task_Id, DRT_Task_Command, void *);
@ -855,7 +783,7 @@ DRT_Status DR_Task_Id_Run( DRT_Task_Id, DRT_Base *, DRT_Task_Command, void *)
/* DR_Task_Id_Kill */
/*----------------------------------------------------------------------------*/
DRT_Status DR_Task_Id_Kill( DRT_Task_Id, DRT_Base *);
DRT_Status DR_Task_Id_Kill( DRT_Task_Id);
@ -863,7 +791,7 @@ DRT_Status DR_Task_Id_Kill( DRT_Task_Id, DRT_Base *);
/* DR_Task_Run */
/*----------------------------------------------------------------------------*/
DRT_Status DR_Task_Run( DRT_Base *, DRT_Task_Command, void *);
DRT_Status DR_Task_Run( DRT_Task_Command, void *);
@ -871,7 +799,7 @@ DRT_Status DR_Task_Run( DRT_Base *, DRT_Task_Command, void *);
/* DR_Task_Wait */
/*----------------------------------------------------------------------------*/
DRT_Status DR_Task_Wait( DRT_Base *);
DRT_Status DR_Task_Wait();
@ -879,7 +807,7 @@ DRT_Status DR_Task_Wait( DRT_Base *);
/* DR_Tasks_Dump */
/*----------------------------------------------------------------------------*/
DRT_Status DR_Tasks_Dump( DRT_Base *);
DRT_Status DR_Tasks_Dump();
@ -887,7 +815,7 @@ DRT_Status DR_Tasks_Dump( DRT_Base *);
/* DR_DataStruct_Init */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_DataStruct_Init( DRT_Base *, DRT_SampleRate, DRT_Task_Id);
DRT_Status DR_DataStruct_Init( DRT_Log_Writer_Ptr, DRT_SampleRate, DRT_Task_Id);
@ -895,11 +823,220 @@ DRT_Status DR_DataStruct_Init( DRT_Base *, DRT_SampleRate, DRT_Task_Id);
/* DR_DataStruct_DeInit */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_DataStruct_DeInit( DRT_Base *);
DRT_Status DR_DataStruct_DeInit();
# endif // ifndef _DATASTRUCT_C_
# else // ifdef _DATASTRUCT_C_
/*----------------------------------------------------------------------------*/
/* Public Definitions */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* DRT_Base */
/*----------------------------------------------------------------------------*/
extern DRT_Base DRG_Base;
/*----------------------------------------------------------------------------*/
/* Public Prototypes */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Log_Write( DRT_Log_Type_Id, char *, va_list);
/*----------------------------------------------------------------------------*/
/* DR_Log */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Log( DRT_Log_Type_Id, DRT_Log_Level, char *, char *, long, bool, char *, ...);
/*----------------------------------------------------------------------------*/
/* DR_Layer_Dump */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Layer_Dump( DRT_Layer *, long);
/*---------------------------------------------------------------------------------*/
/* DR_Kit_Id_Find */
/*---------------------------------------------------------------------------------*/
extern DRT_Status DR_Kit_Id_Find( DRT_Kit **, DRT_Kit_Id);
/*----------------------------------------------------------------------------*/
/* DR_Kit_Logical_Id_Find */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Kit_Logical_Id_Find( DRT_Kit **, DRT_Kit_Id);
/*---------------------------------------------------------------------------------*/
/* DR_Kit_Name_Find */
/*---------------------------------------------------------------------------------*/
extern DRT_Status DR_Kit_Name_Find( DRT_Kit **, char *);
/*----------------------------------------------------------------------------*/
/* DR_Kit_Dump */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Kit_Dump( DRT_Kit *, long);
/*---------------------------------------------------------------------------------*/
/* DR_Kit_Load */
/*---------------------------------------------------------------------------------*/
extern DRT_Status DR_Kit_Load( char *);
/*---------------------------------------------------------------------------------*/
/* DR_Kit_Sample_Load */
/*---------------------------------------------------------------------------------*/
extern DRT_Status DR_Kit_Sample_Load( DRT_Kit *);
/*---------------------------------------------------------------------------------*/
/* DR_Kit_Sample_UnLoad */
/*---------------------------------------------------------------------------------*/
extern DRT_Status DR_Kit_Sample_UnLoad( DRT_Kit *);
/*----------------------------------------------------------------------------*/
/* DR_Kits_Sample_Load */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Kits_Sample_Load();
/*----------------------------------------------------------------------------*/
/* DR_Kits_Sample_UnLoad */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Kits_Sample_UnLoad();
/*----------------------------------------------------------------------------*/
/* DR_Kits_Load */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Kits_Load();
/*----------------------------------------------------------------------------*/
/* DR_Kits_Stats_Dump */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Kits_Stats_Dump();
/*----------------------------------------------------------------------------*/
/* DR_Kits_Dump */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Kits_Dump();
/*----------------------------------------------------------------------------*/
/* DR_Kits_Graph_Dump */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Kits_Graph_Dump();
/*----------------------------------------------------------------------------*/
/* DR_Task_Id_Run */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Task_Id_Run( DRT_Task_Id, DRT_Task_Command, void *);
/*----------------------------------------------------------------------------*/
/* DR_Task_Id_Kill */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Task_Id_Kill( DRT_Task_Id);
/*----------------------------------------------------------------------------*/
/* DR_Task_Run */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Task_Run( void *);
/*----------------------------------------------------------------------------*/
/* DR_Task_Wait */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Task_Wait();
/*----------------------------------------------------------------------------*/
/* DR_Tasks_Dump */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Tasks_Dump();
/*---------------------------------------------------------------------------------*/
/* DR_DataStruct_Init */
/*---------------------------------------------------------------------------------*/
extern DRT_Status DR_DataStruct_Init( DRT_Log_Writer_Ptr, DRT_SampleRate, DRT_Task_Id);
/*---------------------------------------------------------------------------------*/
/* DR_DataStruct_DeInit */
/*---------------------------------------------------------------------------------*/
extern DRT_Status DR_DataStruct_DeInit();
# endif // ifdef _DATASTRUCT_C_

View File

@ -16,12 +16,12 @@
/* DR_Init */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_Init( DRT_Base *Base_Ptr)
DRT_Status DR_Init()
{
DRT_Status status;
if( ( status = DR_DataStruct_Init( Base_Ptr, DRD_SAMPLE_RATE_DEFAULT, DRD_THREAD_NUMBER_DEFAULT)) != DRS_OK)
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) !", status);
return( status);
@ -38,12 +38,12 @@ DRT_Status DR_Init( DRT_Base *Base_Ptr)
/* DR_DeInit */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_DeInit( DRT_Base *Base_Ptr)
DRT_Status DR_DeInit()
{
DRT_Status status;
if( ( status = DR_DataStruct_DeInit( Base_Ptr)) != DRS_OK)
if( ( status = DR_DataStruct_DeInit()) != DRS_OK)
{
printf( "Can't deinit data structures (%d)!\n", status);
return( status);
@ -63,18 +63,17 @@ DRT_Status DR_DeInit( DRT_Base *Base_Ptr)
int main( int argc, char **argv)
{
DRT_Base base;
DRT_Status status;
DRT_Kit *kit_ptr;
DRT_Id i;
if( ( status = DR_Init( &base)) != DRS_OK)
if( ( status = DR_Init()) != DRS_OK)
{
exit( -1);
}
if( ( status = DR_Kits_Load( &base)) != DRS_OK)
if( ( status = DR_Kits_Load()) != DRS_OK)
{
exit( -1);
}
@ -110,7 +109,7 @@ int main( int argc, char **argv)
// }
DR_Kits_Sample_Load( &base);
DR_Kits_Sample_Load();
/*
for( i = 0; i < 1; i++)
@ -130,7 +129,7 @@ int main( int argc, char **argv)
}
*/
fprintf( stderr, "hello world!\n");
DR_LOG_INFO_0( "hello world!");
@ -160,17 +159,17 @@ int main( int argc, char **argv)
exit( -1);
}
*/
if( ( status = DR_Tasks_Dump( &base)) != DRS_OK)
if( ( status = DR_Tasks_Dump()) != DRS_OK)
{
exit( -1);
}
if( ( status = DR_Kits_Stats_Dump( &base)) != DRS_OK)
if( ( status = DR_Kits_Stats_Dump()) != DRS_OK)
{
exit( -1);
}
if( ( status = DR_DeInit( &base)) != DRS_OK)
if( ( status = DR_DeInit()) != DRS_OK)
{
exit( -1);
}

View File

@ -15,7 +15,9 @@
#include <ctype.h>
#include <math.h>
#include <unistd.h>
#include <errno.h>
#include <time.h>
#include <sys/time.h>
#include <libgen.h>
#include <glob.h>
@ -94,6 +96,16 @@ typedef short DRT_Status;
# ifdef _DRUMMER_C_
/*----------------------------------------------------------------------------*/
/* Private Definitions */
/*----------------------------------------------------------------------------*/
#define DRD_MODULE_NAME "dru"
/*----------------------------------------------------------------------------*/
/* Prototypes */
/*----------------------------------------------------------------------------*/
@ -102,7 +114,7 @@ typedef short DRT_Status;
/* DR_Init */
/*----------------------------------------------------------------------------*/
DRT_Status DR_Init( DRT_Base *);
DRT_Status DR_Init();
@ -110,7 +122,7 @@ DRT_Status DR_Init( DRT_Base *);
/* DeInit */
/*----------------------------------------------------------------------------*/
DRT_Status DR_DeInit( DRT_Base *);
DRT_Status DR_DeInit();
@ -125,9 +137,19 @@ int main( int, char **);
# else // ifdef _DRUMMER_C_
/*----------------------------------------------------------------------------*/
/* Public Prototypes */
/*----------------------------------------------------------------------------*/
# endif // ifdef _DRUMMER_C_
/*----------------------------------------------------------------------------*/
#endif
#endif // ifndef _DRUMMER_H_

View File

@ -21,7 +21,54 @@ static int current_kit_changed = 0;
/* */
/*----------------------------------------------------------------------------*/
DRT_Status DR_LV2_Kit_Sample_Load( DRT_LV2_Base *LV2_Base_Ptr, DRT_Kit *Kit_Ptr)
DRT_Status DR_LV2_Log_Write( DRT_Log_Type_Id Log_Type_Id, char *Out_Fmt, va_list Args)
{
switch( Log_Type_Id)
{
case DRD_LOG_TYPE_ID_UNKNOWN:
{
break;
}
case DRD_LOG_TYPE_ID_TRACE:
{
break;
}
case DRD_LOG_TYPE_ID_INFO:
{
lv2_log_vprintf( &(DRG_LV2_Base.Logger), DRG_LV2_Base.Logger.Note, Out_Fmt, Args);
// lv2_log_note( &(DRG_LV2_Base.Logger), "\n");
break;
}
case DRD_LOG_TYPE_ID_WARNING:
{
break;
}
case DRD_LOG_TYPE_ID_ERROR:
{
lv2_log_vprintf( &(DRG_LV2_Base.Logger), DRG_LV2_Base.Logger.Error, Out_Fmt, Args);
// lv2_log_error( &(DRG_LV2_Base.Logger), "\n");
break;
}
}
return( DRS_OK);
}
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
DRT_Status DR_LV2_Kit_Sample_Load( DRT_Kit *Kit_Ptr)
{
DRT_Status status;
NDT_Node *cur_node_ptr;
@ -30,45 +77,45 @@ DRT_Status DR_LV2_Kit_Sample_Load( DRT_LV2_Base *LV2_Base_Ptr, DRT_Kit *Kit_P
if( Kit_Ptr != NULL)
{
// fprintf( stderr, "Sample Rate: (%d)\n", LV2_Base_Ptr->Base.SampleRate);
// fprintf( stderr, "Sample Rate: (%d)\n", DRG_LV2_Base.Base.SampleRate);
if( ( status = DR_Kit_Sample_Load( Kit_Ptr)) == DRS_OK)
{
LV2_Base_Ptr->Kit_Cur_Ptr = Kit_Ptr;
DRG_LV2_Base.Kit_Cur_Ptr = Kit_Ptr;
cur_node_ptr = Kit_Ptr->Instrument_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Head;
pthread_mutex_lock( &( LV2_Base_Ptr->Load_Mutex));
pthread_mutex_lock( &( DRG_LV2_Base.Load_Mutex));
for( sample_id = 0; sample_id < DRD_PORT_NUMBER_MAX; sample_id++)
{
LV2_Base_Ptr->Samples[sample_id].Active = 0;
LV2_Base_Ptr->Samples[sample_id].Offset = 0;
LV2_Base_Ptr->Samples[sample_id].Limit = 0;
LV2_Base_Ptr->Samples[sample_id].Velocity = 0;
LV2_Base_Ptr->Samples[sample_id].Layer_Ptr = 0;
LV2_Base_Ptr->Samples[sample_id].Data_Ptr = NULL;
LV2_Base_Ptr->Samples[sample_id].Data_Offset = 0;
LV2_Base_Ptr->Samples[sample_id].Sustained = false;
DRG_LV2_Base.Samples[sample_id].Active = 0;
DRG_LV2_Base.Samples[sample_id].Offset = 0;
DRG_LV2_Base.Samples[sample_id].Limit = 0;
DRG_LV2_Base.Samples[sample_id].Velocity = 0;
DRG_LV2_Base.Samples[sample_id].Layer_Ptr = 0;
DRG_LV2_Base.Samples[sample_id].Data_Ptr = NULL;
DRG_LV2_Base.Samples[sample_id].Data_Offset = 0;
DRG_LV2_Base.Samples[sample_id].Sustained = false;
if( cur_node_ptr == NULL)
{
// fprintf( stderr, "Skip sample\n");
LV2_Base_Ptr->Samples[sample_id].Instrument_Ptr = NULL;
DRG_LV2_Base.Samples[sample_id].Instrument_Ptr = NULL;
}
else
{
LV2_Base_Ptr->Samples[sample_id].Instrument_Ptr = (DRT_Instrument *)cur_node_ptr->Value;
DRG_LV2_Base.Samples[sample_id].Instrument_Ptr = (DRT_Instrument *)cur_node_ptr->Value;
cur_node_ptr = cur_node_ptr->Right;
// fprintf( stderr, "Add sample: [%s]\n", LV2_Base_Ptr->Samples[sample_id].Instrument_Ptr->Name);
// fprintf( stderr, "Add sample: [%s]\n", DRG_LV2_Base.Samples[sample_id].Instrument_Ptr->Name);
}
}
pthread_mutex_unlock( &( LV2_Base_Ptr->Load_Mutex));
pthread_mutex_unlock( &( DRG_LV2_Base.Load_Mutex));
LV2_Base_Ptr->Sample_Number = Kit_Ptr->Instrument_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Node_Number;
fprintf( stderr, "Loaded: (%d) instruments!\n", LV2_Base_Ptr->Sample_Number);
DRG_LV2_Base.Sample_Number = Kit_Ptr->Instrument_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Node_Number;
DR_LOG_INFO_1( "Loaded: (%d) instruments!", DRG_LV2_Base.Sample_Number);
// DR_Kit_Dump( Kit_Ptr, 0);
}
@ -85,51 +132,51 @@ DRT_Status DR_LV2_Kit_Sample_Load( DRT_LV2_Base *LV2_Base_Ptr, DRT_Kit *Kit_P
/* */
/*----------------------------------------------------------------------------*/
DRT_Status DR_LV2_CurKit_Sample_Load( DRT_LV2_Base *LV2_Base_Ptr)
DRT_Status DR_LV2_CurKit_Sample_Load()
{
DRT_Status status;
DRT_Kit *Kit_Ptr;
DRT_Kit_Id kit_id;
kit_id = ( LV2_Base_Ptr->Bank_Id_LSB_New * 128 + LV2_Base_Ptr->Bank_Id_MSB_New) * 128 + LV2_Base_Ptr->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 == LV2_Base_Ptr->Kit_Id)
if( kit_id == DRG_LV2_Base.Kit_Id)
{
fprintf( stderr, "Same kit id: (%d) Bank/Program: (%d/%d/%d) Name: [%s]!\n",
kit_id, LV2_Base_Ptr->Bank_Id_LSB_New, LV2_Base_Ptr->Bank_Id_MSB_New, LV2_Base_Ptr->Program_Id_New, LV2_Base_Ptr->Kit_Cur_Ptr->Name);
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);
status = DRS_OK;
}
else
{
if( ( status = DR_Kit_Logical_Id_Find( &Kit_Ptr, LV2_Base_Ptr->Base.Kit_DS_Ptr, kit_id)) != DRS_OK)
if( ( status = DR_Kit_Logical_Id_Find( &Kit_Ptr, kit_id)) != DRS_OK)
{
fprintf( stderr, "Can't find kit id: (%d) Bank/Program: (%d/%d/%d)!\n",
kit_id, LV2_Base_Ptr->Bank_Id_LSB_New, LV2_Base_Ptr->Bank_Id_MSB_New, LV2_Base_Ptr->Program_Id_New);
kit_id, DRG_LV2_Base.Bank_Id_LSB_New, DRG_LV2_Base.Bank_Id_MSB_New, DRG_LV2_Base.Program_Id_New);
if( LV2_Base_Ptr->Kit_Id == DRD_ID_UNKNOWN)
if( DRG_LV2_Base.Kit_Id == DRD_ID_UNKNOWN)
{
fprintf( stderr, "No Kit available!\n");
status=DRS_KO;
}
else
{
fprintf( stderr, "Keep kit id: (%d) Bank/Program: (%d/%d/%d) Name: [%s]!\n",
LV2_Base_Ptr->Kit_Id, LV2_Base_Ptr->Bank_Id_LSB, LV2_Base_Ptr->Bank_Id_MSB, LV2_Base_Ptr->Program_Id, LV2_Base_Ptr->Kit_Cur_Ptr->Name);
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);
}
}
else
{
fprintf( stderr, "New kit id: (%d) Bank/Program: (%d/%d/%d) Name: [%s]!\n",
kit_id, LV2_Base_Ptr->Bank_Id_LSB_New, LV2_Base_Ptr->Bank_Id_MSB_New, LV2_Base_Ptr->Program_Id_New, Kit_Ptr->Name);
DR_LOG_INFO_5( "New 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, Kit_Ptr->Name);
LV2_Base_Ptr->Bank_Id_LSB = LV2_Base_Ptr->Bank_Id_LSB_New;
LV2_Base_Ptr->Bank_Id_MSB = LV2_Base_Ptr->Bank_Id_MSB_New;
LV2_Base_Ptr->Program_Id = LV2_Base_Ptr->Program_Id_New;
LV2_Base_Ptr->Kit_Id = kit_id;
LV2_Base_Ptr->Kit_Cur_Ptr = Kit_Ptr;
DRG_LV2_Base.Bank_Id_LSB = DRG_LV2_Base.Bank_Id_LSB_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.Kit_Id = kit_id;
DRG_LV2_Base.Kit_Cur_Ptr = Kit_Ptr;
status = DR_LV2_Kit_Sample_Load( LV2_Base_Ptr, Kit_Ptr);
status = DR_LV2_Kit_Sample_Load( Kit_Ptr);
}
}
@ -142,37 +189,37 @@ DRT_Status DR_LV2_CurKit_Sample_Load( DRT_LV2_Base *LV2_Base_Ptr)
/* */
/*----------------------------------------------------------------------------*/
static void *DR_LV2_Load_Thread( DRT_LV2_Base *LV2_Base_Ptr)
static void *DR_LV2_Load_Thread()
{
DRT_Status status;
fprintf( stderr, "Start Load Thread!\n");
DR_LOG_INFO_0( "Start Load Thread!");
for(;;)
{
pthread_mutex_lock( &( LV2_Base_Ptr->Load_Mutex));
pthread_cond_wait( &( LV2_Base_Ptr->Load_Cond), &( LV2_Base_Ptr->Load_Mutex));
pthread_mutex_lock( &( DRG_LV2_Base.Load_Mutex));
pthread_cond_wait( &( DRG_LV2_Base.Load_Cond), &( DRG_LV2_Base.Load_Mutex));
fprintf( stderr, "Load_Thread: New load!\n");
pthread_mutex_unlock( &(LV2_Base_Ptr->Load_Mutex));
pthread_mutex_unlock( &(DRG_LV2_Base.Load_Mutex));
if( ( status = DR_LV2_CurKit_Sample_Load( LV2_Base_Ptr)) != DRS_OK)
if( ( status = DR_LV2_CurKit_Sample_Load()) != DRS_OK)
{
fprintf( stderr, "Can't load kit sample (%d) !", status);
}
pthread_mutex_lock( &(LV2_Base_Ptr->Load_Mutex));
pthread_mutex_unlock( &(LV2_Base_Ptr->Load_Mutex));
pthread_mutex_lock( &(DRG_LV2_Base.Load_Mutex));
pthread_mutex_unlock( &(DRG_LV2_Base.Load_Mutex));
/*
// old_samples = LV2_Base_Ptr->Samples;
// old_scount = LV2_Base_Ptr->Num_Samples;
// old_samples = DRG_LV2_Base.Samples;
// old_scount = DRG_LV2_Base.Num_Samples;
request_orig = request = LV2_Base_Ptr->Request_Buf[ LV2_Base_Ptr->CurReq];
request_orig = request = DRG_LV2_Base.Request_Buf[ DRG_LV2_Base.CurReq];
if( !strncmp( request, "file://", 7))
{
@ -185,29 +232,29 @@ static void *DR_LV2_Load_Thread( DRT_LV2_Base *LV2_Base_Ptr)
{
fprintf(stderr,"Failed to load kit at: %s\n",request);
pthread_mutex_lock( &(LV2_Base_Ptr->Load_Mutex));
pthread_mutex_lock( &(DRG_LV2_Base.Load_Mutex));
// LV2_Base_Ptr->Num_Samples = 0;
// LV2_Base_Ptr->Samples = NULL;
// DRG_LV2_Base.Num_Samples = 0;
// DRG_LV2_Base.Samples = NULL;
pthread_mutex_unlock( &(LV2_Base_Ptr->Load_Mutex));
pthread_mutex_unlock( &(DRG_LV2_Base.Load_Mutex));
}
else
{
// just lock for the critical moment when we swap in the new kit
printf( "loaded kit at: %s\n", request);
pthread_mutex_lock( &(LV2_Base_Ptr->Load_Mutex));
pthread_mutex_lock( &(DRG_LV2_Base.Load_Mutex));
// LV2_Base_Ptr->Samples = loaded_samples;
// LV2_Base_Ptr->Num_Samples = loaded_count;
// DRG_LV2_Base.Samples = loaded_samples;
// DRG_LV2_Base.Num_Samples = loaded_count;
pthread_mutex_unlock( &(LV2_Base_Ptr->Load_Mutex));
pthread_mutex_unlock( &(DRG_LV2_Base.Load_Mutex));
}
// if( old_scount > 0) free_samples( old_samples, old_scount);
LV2_Base_Ptr->Current_Path = request_orig;
DRG_LV2_Base.Current_Path = request_orig;
current_kit_changed = 1;
*/
}
@ -287,10 +334,10 @@ static inline LV2_Atom *DR_LV2_Message_Midi_Info_Build( DRT_LV2_Base *LV2_Base
LV2_Atom *msg;
msg = (LV2_Atom *)lv2_atom_forge_object( &( LV2_Base_Ptr->Forge), &set_frame, 1, LV2_Base_Ptr->URIS.midi_info);
lv2_atom_forge_property_head( &( LV2_Base_Ptr->Forge), LV2_Base_Ptr->URIS.midi_event, 0);
lv2_atom_forge_write( &( LV2_Base_Ptr->Forge), Data, 3);
lv2_atom_forge_pop( &( LV2_Base_Ptr->Forge), &set_frame);
msg = (LV2_Atom *)lv2_atom_forge_object( &( DRG_LV2_Base.Forge), &set_frame, 1, DRG_LV2_Base.URIS.midi_info);
lv2_atom_forge_property_head( &( DRG_LV2_Base.Forge), DRG_LV2_Base.URIS.midi_event, 0);
lv2_atom_forge_write( &( DRG_LV2_Base.Forge), Data, 3);
lv2_atom_forge_pop( &( DRG_LV2_Base.Forge), &set_frame);
return( msg);
}
@ -384,7 +431,7 @@ static inline void DR_Layer_To_Sample( DRT_Sample *Sample_Ptr, float Gain)
Sample_Ptr->Limit = cur_layer_ptr->Sample_Size;
Sample_Ptr->SF_Info_Ptr = cur_layer_ptr->SF_Info_Ptr;
fprintf( stderr, "Layer: (%d) MGain: (%f) Gain: (%f)\n", i, mapped_gain, Gain);
DR_LOG_INFO_3( "Layer: (%d) MGain: (%f) Gain: (%f)", i, mapped_gain, Gain);
}
@ -395,45 +442,45 @@ static inline void DR_Layer_To_Sample( DRT_Sample *Sample_Ptr, float Gain)
/* */
/*----------------------------------------------------------------------------*/
static inline void DR_Sample_Trigger( DRT_LV2_Base *LV2_Base_Ptr, int Sample_Id, uint8_t *const Data, uint32_t Offset)
static inline void DR_Sample_Trigger( int Sample_Id, uint8_t *const Data, uint32_t Offset)
{
// need to mutex this to avoid getting the samples array
// changed after the check that the midi-note is valid
pthread_mutex_lock( &( LV2_Base_Ptr->Load_Mutex));
pthread_mutex_lock( &( DRG_LV2_Base.Load_Mutex));
fprintf( stderr, "Trigger Sample: Id: (%d) Offset: (%d)\n", Sample_Id, Offset);
DR_LOG_INFO_2( "Trigger Sample: Id: (%d) Offset: (%d)", Sample_Id, Offset);
if( ( Sample_Id >= 0) && ( Sample_Id < LV2_Base_Ptr->Sample_Number))
if( ( Sample_Id >= 0) && ( Sample_Id < DRG_LV2_Base.Sample_Number))
{
/*
if( Data)
{
lv2_atom_forge_frame_time( &( LV2_Base_Ptr->Forge), 0);
lv2_atom_forge_frame_time( &( DRG_LV2_Base.Forge), 0);
DR_LV2_Message_Midi_Info_Build( LV2_Base_Ptr, Data);
}
*/
LV2_Base_Ptr->Samples[Sample_Id].Active = 1;
LV2_Base_Ptr->Samples[Sample_Id].Offset = 0;
LV2_Base_Ptr->Samples[Sample_Id].Velocity = *( LV2_Base_Ptr->Base.Velocity_Ignore_Flag_Ptr) ? 1.0f : ( (float)Data[2]) / DRD_VELOCITY_MAX;
LV2_Base_Ptr->Samples[Sample_Id].Data_Offset = Offset;
LV2_Base_Ptr->Samples[Sample_Id].Sustained = false;
DRG_LV2_Base.Samples[Sample_Id].Active = 1;
DRG_LV2_Base.Samples[Sample_Id].Offset = 0;
DRG_LV2_Base.Samples[Sample_Id].Velocity = *( DRG_Base.Velocity_Ignore_Flag_Ptr) ? 1.0f : ( (float)Data[2]) / DRD_VELOCITY_MAX;
DRG_LV2_Base.Samples[Sample_Id].Data_Offset = Offset;
DRG_LV2_Base.Samples[Sample_Id].Sustained = false;
if( LV2_Base_Ptr->Samples[Sample_Id].Instrument_Ptr->Layer_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Node_Number > 0)
if( DRG_LV2_Base.Samples[Sample_Id].Instrument_Ptr->Layer_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Node_Number > 0)
{
// drmr currently has 32 hard-coded gains so just use the last gain
// to prevent a segfault
int gain_idx = Sample_Id < 32 ? Sample_Id : 31;
// DR_Layer_To_Sample( &(LV2_Base_Ptr->Samples[Sample_Id]), *( LV2_Base_Ptr->Gains[ gain_idx]));
DR_Layer_To_Sample( &(LV2_Base_Ptr->Samples[Sample_Id]), LV2_Base_Ptr->Samples[Sample_Id].Velocity);
// DR_Layer_To_Sample( &(DRG_LV2_Base.Samples[Sample_Id]), *( DRG_LV2_Base.Gains[ gain_idx]));
DR_Layer_To_Sample( &(DRG_LV2_Base.Samples[Sample_Id]), DRG_LV2_Base.Samples[Sample_Id].Velocity);
if( LV2_Base_Ptr->Samples[Sample_Id].Limit == 0)
fprintf(stderr,"Failed to find layer at: %i for %f\n", Sample_Id, *( LV2_Base_Ptr->Gains[ gain_idx]));
if( DRG_LV2_Base.Samples[Sample_Id].Limit == 0)
fprintf(stderr,"Failed to find layer at: %i for %f\n", Sample_Id, *( DRG_LV2_Base.Gains[ gain_idx]));
}
}
pthread_mutex_unlock( &( LV2_Base_Ptr->Load_Mutex));
pthread_mutex_unlock( &( DRG_LV2_Base.Load_Mutex));
}
@ -444,20 +491,19 @@ static inline void DR_Sample_Trigger( DRT_LV2_Base *LV2_Base_Ptr, int Sample_
/* */
/*----------------------------------------------------------------------------*/
static inline void DR_Sample_Untrigger( DRT_LV2_Base *LV2_Base_Ptr, int Sample_Id, uint32_t Offset)
static inline void DR_Sample_Untrigger( int Sample_Id, uint32_t Offset)
{
pthread_mutex_lock( &( LV2_Base_Ptr->Load_Mutex));
pthread_mutex_lock( &( DRG_LV2_Base.Load_Mutex));
if( LV2_Base_Ptr->Sustain == true)
if( DRG_LV2_Base.Sustain == true)
{
fprintf( stderr, "Sustains Sample: Id: (%d) Offset: (%d)\n", Sample_Id, Offset);
DR_LOG_INFO_2( "Sustains Sample: Id: (%d) Offset: (%d)", Sample_Id, Offset);
LV2_Base_Ptr->Samples[Sample_Id].Sustained = true;
DRG_LV2_Base.Samples[Sample_Id].Sustained = true;
}
else
{
fprintf( stderr, "UnTrigger Sample: Id: (%d) Offset: (%d)\n", Sample_Id, Offset);
DR_LOG_INFO_2( "UnTrigger Sample: Id: (%d) Offset: (%d)", Sample_Id, Offset);
/*
if (nn >= 0 && nn < drmr->num_samples) {
@ -470,12 +516,12 @@ static inline void DR_Sample_Untrigger( DRT_LV2_Base *LV2_Base_Ptr, int Sampl
drmr->samples[nn].dataoffset = offset;
}
*/
LV2_Base_Ptr->Samples[Sample_Id].Active = 0;
LV2_Base_Ptr->Samples[Sample_Id].Data_Offset = Offset;
LV2_Base_Ptr->Samples[Sample_Id].Sustained = false;
DRG_LV2_Base.Samples[Sample_Id].Active = 0;
DRG_LV2_Base.Samples[Sample_Id].Data_Offset = Offset;
DRG_LV2_Base.Samples[Sample_Id].Sustained = false;
}
pthread_mutex_unlock( &( LV2_Base_Ptr->Load_Mutex));
pthread_mutex_unlock( &( DRG_LV2_Base.Load_Mutex));
}
@ -486,16 +532,16 @@ static inline void DR_Sample_Untrigger( DRT_LV2_Base *LV2_Base_Ptr, int Sampl
/* */
/*----------------------------------------------------------------------------*/
static inline void DR_Sample_UnSustain( DRT_LV2_Base *LV2_Base_Ptr, uint32_t Offset)
static inline void DR_Sample_UnSustain( uint32_t Offset)
{
int sample_id;
for( sample_id =0; sample_id < DRD_PORT_NUMBER_MAX; sample_id++)
{
if( LV2_Base_Ptr->Samples[sample_id].Sustained)
if( DRG_LV2_Base.Samples[sample_id].Sustained)
{
DR_Sample_Untrigger( LV2_Base_Ptr, sample_id, Offset);
DR_Sample_Untrigger( sample_id, Offset);
}
}
}
@ -515,158 +561,178 @@ static LV2_Handle DR_LV2_Instantiate( const LV2_Descriptor *LV2_Descriptor
{
DRT_Status status;
int i;
DRT_LV2_Base *lv2_base_ptr;
// DRT_LV2_Base *lv2_base_ptr;
fprintf( stderr, "LV2 Instantiate\n");
/*
if( ( lv2_base_ptr = malloc( sizeof( DRT_LV2_Base))) == NULL)
{
fprintf( stderr, "Can't allocate LV2 Base!\n");
return( (LV2_Handle)NULL);
}
*/
DRG_LV2_Base.Map_Ptr = NULL;
DRG_LV2_Base.Logger.log = NULL;
lv2_base_ptr->Kit_Cur_Ptr = NULL;
lv2_base_ptr->Bank_Id_LSB = -1;
lv2_base_ptr->Bank_Id_LSB = -1;
lv2_base_ptr->Program_Id = -1;
lv2_base_ptr->Bank_Id_LSB_New = 0;
lv2_base_ptr->Bank_Id_MSB_New = 0;
lv2_base_ptr->Program_Id_New = 0;
lv2_base_ptr->Kit_Id = DRD_ID_UNKNOWN;
lv2_base_ptr->Current_Path = NULL;
lv2_base_ptr->CurReq = -1;
DRG_LV2_Base.Kit_Cur_Ptr = NULL;
DRG_LV2_Base.Bank_Id_LSB = -1;
DRG_LV2_Base.Bank_Id_LSB = -1;
DRG_LV2_Base.Program_Id = -1;
DRG_LV2_Base.Bank_Id_LSB_New = 0;
DRG_LV2_Base.Bank_Id_MSB_New = 0;
DRG_LV2_Base.Program_Id_New = 0;
DRG_LV2_Base.Kit_Id = DRD_ID_UNKNOWN;
DRG_LV2_Base.Current_Path = NULL;
DRG_LV2_Base.CurReq = -1;
// lv2_base_ptr->Channel_Id = 0;
lv2_base_ptr->Zero_Position = 0;
// DRG_LV2_Base.Channel_Id = 0;
DRG_LV2_Base.Zero_Position = 0;
lv2_base_ptr->Sustain = false;
DRG_LV2_Base.Sustain = false;
lv2_base_ptr->Sample_Number = 0;
DRG_LV2_Base.Sample_Number = 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"))
if( !strcmp( ( *LV2_Features_Ptr)->URI, LV2_URID_URI "#map"))
{
lv2_base_ptr->Map_Ptr = (LV2_URID_Map *)((*LV2_Features_Ptr)->data);
DRG_LV2_Base.Map_Ptr = (LV2_URID_Map *)( ( *LV2_Features_Ptr)->data);
}
else
{
if( !strcmp( ( *LV2_Features_Ptr)->URI, LV2_LOG__log))
{
DRG_LV2_Base.Logger.log = (LV2_Log_Log *)( ( *LV2_Features_Ptr)->data);
}
}
LV2_Features_Ptr++;
}
if( lv2_base_ptr->Map_Ptr == NULL)
if( ( DRG_LV2_Base.Map_Ptr == NULL) || ( DRG_LV2_Base.Logger.log == NULL))
{
fprintf( stderr, "LV2 host does not support urid#map!\n");
if( DRG_LV2_Base.Map_Ptr == NULL)
{
fprintf( stderr, "LV2 host does not support urid#map!\n");
}
if( DRG_LV2_Base.Logger.log == NULL)
{
fprintf( stderr, "LV2 host does not support log#log!\n");
}
}
else
{
if( pthread_mutex_init( &( lv2_base_ptr->Load_Mutex), 0))
if( ( status = DR_DataStruct_Init( DR_LV2_Log_Write, (DRT_SampleRate)SampleRate, DRD_THREAD_NUMBER_DEFAULT)) != DRS_OK)
{
fprintf( stderr, "Could not initialize load_mutex!\n");
}
else if( pthread_cond_init( &( lv2_base_ptr->Load_Cond), 0))
{
fprintf( stderr, "Could not initialize load_cond!\n");
fprintf( stderr, "Can't init data structures (%d)!\n", status);
}
else
{
DR_Map_Drummer_URIS( lv2_base_ptr->Map_Ptr, &(lv2_base_ptr->URIS));
lv2_log_error( &(DRG_LV2_Base.Logger), "Test error log <%s>!\n", "Krash!");
DR_LOG_ERROR_1( "Test error log <%s>!", "Krash!");
lv2_atom_forge_init( &(lv2_base_ptr->Forge), lv2_base_ptr->Map_Ptr);
if( pthread_create( &lv2_base_ptr->Load_Thread, 0, (void * (*)(void *))DR_LV2_Load_Thread, lv2_base_ptr))
if( pthread_mutex_init( &( DRG_LV2_Base.Load_Mutex), 0))
{
fprintf( stderr, "Could not initialize loading thread!\n");
fprintf( stderr, "Could not initialize load_mutex!\n");
}
else if( pthread_cond_init( &( DRG_LV2_Base.Load_Cond), 0))
{
fprintf( stderr, "Could not initialize load_cond!\n");
}
else
{
if( ( lv2_base_ptr->Request_Buf = malloc( DRD_REQ_BUF_SIZE * sizeof(char *))) == NULL)
DR_Map_Drummer_URIS( DRG_LV2_Base.Map_Ptr, &(DRG_LV2_Base.URIS));
lv2_atom_forge_init( &(DRG_LV2_Base.Forge), DRG_LV2_Base.Map_Ptr);
if( pthread_create( &DRG_LV2_Base.Load_Thread, 0, (void * (*)(void *))DR_LV2_Load_Thread, NULL))
{
fprintf( stderr, "Cant'allocate Request buffer!\n");
fprintf( stderr, "Could not initialize loading thread!\n");
}
else
{
memset( lv2_base_ptr->Request_Buf, 0, DRD_REQ_BUF_SIZE * sizeof(char *));
if( ( lv2_base_ptr->Left = malloc( DRD_PORT_NUMBER_MAX * sizeof(float *))) == NULL)
if( ( DRG_LV2_Base.Request_Buf = malloc( DRD_REQ_BUF_SIZE * sizeof(char *))) == NULL)
{
fprintf( stderr, "Cant'allocate Left buffer!\n");
free( lv2_base_ptr);
return( NULL);
fprintf( stderr, "Cant'allocate Request buffer!\n");
}
else
{
if( ( lv2_base_ptr->Right = malloc( DRD_PORT_NUMBER_MAX * sizeof(float *))) == NULL)
memset( DRG_LV2_Base.Request_Buf, 0, DRD_REQ_BUF_SIZE * sizeof(char *));
if( ( DRG_LV2_Base.Left = malloc( DRD_PORT_NUMBER_MAX * sizeof(float *))) == NULL)
{
fprintf( stderr, "Cant'allocate Right buffer!\n");
fprintf( stderr, "Cant'allocate Left buffer!\n");
// free( lv2_base_ptr);
return( NULL);
}
else
{
if( ( lv2_base_ptr->Gains = malloc( DRD_PORT_NUMBER_MAX * sizeof(float *))) == NULL)
if( ( DRG_LV2_Base.Right = malloc( DRD_PORT_NUMBER_MAX * sizeof(float *))) == NULL)
{
fprintf( stderr, "Cant'allocate Gains buffer!\n");
fprintf( stderr, "Cant'allocate Right buffer!\n");
}
else
{
if( ( lv2_base_ptr->Pans = malloc( DRD_PORT_NUMBER_MAX * sizeof(float *))) == NULL)
if( ( DRG_LV2_Base.Gains = malloc( DRD_PORT_NUMBER_MAX * sizeof(float *))) == NULL)
{
fprintf( stderr, "Cant'allocate Pans buffer!\n");
fprintf( stderr, "Cant'allocate Gains buffer!\n");
}
else
{
for( i = 0; i < 32; i++)
if( ( DRG_LV2_Base.Pans = malloc( DRD_PORT_NUMBER_MAX * sizeof(float *))) == NULL)
{
lv2_base_ptr->Gains[i] = NULL;
lv2_base_ptr->Pans[i] = NULL;
}
if( ( status = DR_DataStruct_Init( &( lv2_base_ptr->Base), (DRT_SampleRate)SampleRate, DRD_THREAD_NUMBER_DEFAULT)) != DRS_OK)
{
fprintf( stderr, "Can't init data structures (%d)!\n", status);
fprintf( stderr, "Cant'allocate Pans buffer!\n");
}
else
{
if( ( status = DR_Kits_Load( & ( lv2_base_ptr->Base))) != DRS_OK)
for( i = 0; i < 32; i++)
{
DRG_LV2_Base.Gains[i] = NULL;
DRG_LV2_Base.Pans[i] = NULL;
}
if( ( status = DR_Kits_Load()) != DRS_OK)
{
fprintf( stderr, "Can't load kits (%d)!\n", status);
}
else
{
if( ( status = DR_LV2_CurKit_Sample_Load( lv2_base_ptr)) != DRS_OK)
if( ( status = DR_LV2_CurKit_Sample_Load()) != DRS_OK)
{
fprintf( stderr, "Can't load kit sample (%d)!\n", status);
}
else
{
return( (LV2_Handle)lv2_base_ptr);
return( (LV2_Handle)&DRG_LV2_Base);
}
}
DR_DataStruct_DeInit( &( lv2_base_ptr->Base));
}
free( DRG_LV2_Base.Gains);
}
free( lv2_base_ptr->Gains);
}
free( lv2_base_ptr->Right);
free( DRG_LV2_Base.Right);
}
}
free( lv2_base_ptr->Left);
}
free( DRG_LV2_Base.Left);
}
free( lv2_base_ptr->Request_Buf);
free( DRG_LV2_Base.Request_Buf);
}
}
}
DR_DataStruct_DeInit();
}
}
free( lv2_base_ptr);
return( (LV2_Handle)NULL);
}
@ -684,7 +750,7 @@ static void DR_LV2_Connect_Port( LV2_Handle Instance_Ptr, uint32_t Port_Id, v
DRT_Port_Index port_index = (DRT_Port_Index)Port_Id;
// fprintf( stderr, "LV2 Connect Port (%d)!\n", Port_Id);
// DR_LOG_INFO_1( "LV2 Connect Port (%d)!", Port_Id);
switch( port_index)
{
@ -702,37 +768,37 @@ static void DR_LV2_Connect_Port( LV2_Handle Instance_Ptr, uint32_t Port_Id, v
case DRD_LV2_CHANNEL_ID:
{
if( Data_Ptr) lv2_base_ptr->Base.Channel_Id_Ptr = (float *)Data_Ptr;
if( Data_Ptr) DRG_Base.Channel_Id_Ptr = (float *)Data_Ptr;
break;
}
case DRD_LV2_BASE_NOTE:
{
if( Data_Ptr) lv2_base_ptr->Base.Base_Note_Ptr = (float *)Data_Ptr;
if( Data_Ptr) DRG_Base.Base_Note_Ptr = (float *)Data_Ptr;
break;
}
case DRD_LV2_VELOCITY_IGNORE_NOTE:
{
if( Data_Ptr) lv2_base_ptr->Base.Velocity_Ignore_Note_Ptr = (float *)Data_Ptr;
if( Data_Ptr) DRG_Base.Velocity_Ignore_Note_Ptr = (float *)Data_Ptr;
break;
}
case DRD_LV2_NOTE_OFF_IGNORE_NOTE:
{
if( Data_Ptr) lv2_base_ptr->Base.Note_Off_Ignore_Note_Ptr = (float *)Data_Ptr;
if( Data_Ptr) DRG_Base.Note_Off_Ignore_Note_Ptr = (float *)Data_Ptr;
break;
}
case DRD_LV2_VELOCITY_IGNORE_FLAG:
{
if( Data_Ptr) lv2_base_ptr->Base.Velocity_Ignore_Flag_Ptr = (float *)Data_Ptr;
if( Data_Ptr) DRG_Base.Velocity_Ignore_Flag_Ptr = (float *)Data_Ptr;
break;
}
case DRD_LV2_NOTE_OFF_IGNORE_FLAG:
{
if( Data_Ptr) lv2_base_ptr->Base.Note_Off_Ignore_Flag_Ptr = (float *)Data_Ptr;
if( Data_Ptr) DRG_Base.Note_Off_Ignore_Flag_Ptr = (float *)Data_Ptr;
break;
}
@ -789,7 +855,7 @@ static void DR_LV2_Connect_Port( LV2_Handle Instance_Ptr, uint32_t Port_Id, v
static void DR_LV2_Activate( LV2_Handle instance)
{
fprintf( stderr, "LV2 Activate!\n");
DR_LOG_INFO_0( "LV2 Activate!");
}
@ -809,7 +875,7 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples)
// fprintf( stderr, "LV2 Run!\n");
base_note = (int)floorf( *( lv2_base_ptr->Base.Base_Note_Ptr));
base_note = (int)floorf( *( DRG_Base.Base_Note_Ptr));
const uint32_t event_capacity = lv2_base_ptr->Core_Event_Port->atom.size;
@ -820,7 +886,7 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples)
LV2_ATOM_SEQUENCE_FOREACH( lv2_base_ptr->Control_Port, ev_ptr)
{
fprintf( stderr, "LV2 Event!\n");
DR_LOG_INFO_0( "LV2 Event!");
if( ev_ptr->body.type == lv2_base_ptr->URIS.midi_event)
{
@ -834,18 +900,18 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples)
// fprintf( stderr, " Midi Event!\n");
if( ( *( lv2_base_ptr->Base.Channel_Id_Ptr) == 0) || ( channel == ( *( lv2_base_ptr->Base.Channel_Id_Ptr) - 1)))
if( ( *( DRG_Base.Channel_Id_Ptr) == 0) || ( channel == ( *( DRG_Base.Channel_Id_Ptr) - 1)))
{
switch( ( *data) >> 4)
{
case 8: // Note Off
{
if( !*( lv2_base_ptr->Base.Note_Off_Ignore_Flag_Ptr))
if( !*( DRG_Base.Note_Off_Ignore_Flag_Ptr))
{
nn = data[1];
nn -= base_note;
DR_Sample_Untrigger( lv2_base_ptr, nn, offset);
DR_Sample_Untrigger( nn, offset);
}
break;
@ -855,25 +921,25 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples)
{
nn = data[1];
if( nn == *( lv2_base_ptr->Base.Velocity_Ignore_Note_Ptr))
if( nn == *( DRG_Base.Velocity_Ignore_Note_Ptr))
{
// *( lv2_base_ptr->Base.Velocity_Ignore_Flag) ^= true;
*( lv2_base_ptr->Base.Velocity_Ignore_Flag_Ptr) = (float)( (int)*( lv2_base_ptr->Base.Velocity_Ignore_Flag_Ptr) ^ true);
fprintf( stderr, "Velocity Ignore: [%f] - [%f]\n", *( lv2_base_ptr->Base.Velocity_Ignore_Flag_Ptr), *( lv2_base_ptr->Base.Velocity_Ignore_Note_Ptr));
// *( DRG_Base.Velocity_Ignore_Flag) ^= true;
*( 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));
}
else
{
if( nn == *( lv2_base_ptr->Base.Note_Off_Ignore_Note_Ptr))
if( nn == *( DRG_Base.Note_Off_Ignore_Note_Ptr))
{
// *( lv2_base_ptr->Base.Note_Off_Ignore_Flag) ^= true;
*( lv2_base_ptr->Base.Note_Off_Ignore_Flag_Ptr) = (float)( (int)*( lv2_base_ptr->Base.Note_Off_Ignore_Flag_Ptr) ^ true);
fprintf( stderr, "Note Off Ignore: [%f] - [%f]\n", *( lv2_base_ptr->Base.Note_Off_Ignore_Flag_Ptr), *( lv2_base_ptr->Base.Note_Off_Ignore_Note_Ptr));
// *( DRG_Base.Note_Off_Ignore_Flag) ^= true;
*( DRG_Base.Note_Off_Ignore_Flag_Ptr) = (float)( (int)*( DRG_Base.Note_Off_Ignore_Flag_Ptr) ^ true);
DR_LOG_INFO_2( "Note Off Ignore: [%f] - [%f]", *( DRG_Base.Note_Off_Ignore_Flag_Ptr), *( DRG_Base.Note_Off_Ignore_Note_Ptr));
/*
LV2_Atom_Forge_Frame set_frame;
LV2_Atom *msg = (LV2_Atom *)lv2_atom_forge_object( &( lv2_base_ptr->forge), &set_frame, 1, drmr->uris.ui_msg);
lv2_atom_forge_property_head( &( lv2_base_ptr->forge), lv2_base_ptr->URIS.velocity_toggle, 0);
lv2_atom_forge_bool( &( lv2_base_ptr->forge), lv2_base_ptr->Base.Note_Off_Ignore_Flag ? true : false);
lv2_atom_forge_bool( &( lv2_base_ptr->forge), DRG_Base.Note_Off_Ignore_Flag ? true : false);
lv2_atom_forge_pop( &( lv2_base_ptr->forge), &set_frame);
*/
}
@ -881,7 +947,7 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples)
{
nn -= base_note;
DR_Sample_Trigger( lv2_base_ptr, nn, data, offset);
DR_Sample_Trigger( nn, data, offset);
}
}
@ -897,7 +963,7 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples)
{
case 0: // Bank MSB Select
{
fprintf( stderr, "Bank MSB select: (%d)!\n", value);
DR_LOG_INFO_1( "Bank MSB select: (%d)!", value);
lv2_base_ptr->Bank_Id_MSB_New = value;
break;
@ -905,7 +971,7 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples)
case 32: // Bank LSB Select
{
fprintf( stderr, "Bank LSB select: (%d)!\n", value);
DR_LOG_INFO_1( "Bank LSB select: (%d)!", value);
lv2_base_ptr->Bank_Id_LSB_New = value;
break;
@ -913,7 +979,7 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples)
case 64: // Sustain
{
fprintf( stderr, "Sustain: (%d)!\n", value);
DR_LOG_INFO_1( "Sustain: (%d)!", value);
if( value == 127)
{
@ -926,7 +992,7 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples)
if( !( lv2_base_ptr->Sustain))
{
DR_Sample_UnSustain( lv2_base_ptr, offset);
DR_Sample_UnSustain( offset);
}
break;
@ -934,7 +1000,7 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples)
default:
{
fprintf( stderr, "Unhandled controler: (%d) value: (%d)!\n", controler, value);
DR_LOG_WARNING_2( "Unhandled controler: (%d) value: (%d)!", controler, value);
break;
}
}
@ -946,33 +1012,11 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples)
{
value = data[1];
fprintf( stderr, "Program change: (%d)!\n", value);
DR_LOG_INFO_1( "Program change: (%d)!", value);
lv2_base_ptr->Program_Id_New = value;
pthread_cond_signal( &( lv2_base_ptr->Load_Cond));
/*
if( ( status = DR_LV2_CurKit_Sample_Load( lv2_base_ptr)) != DRS_OK)
{
fprintf( stderr, "Can't load kit sample (%d) !", status);
}
*/
/*
int reqpos = ( lv2_base_ptr->CurReq + 1) % DRD_REQ_BUF_SIZE;
char *tmp = NULL;
if( reqpos >= 0 && lv2_base_ptr->Request_Buf[reqpos])
tmp = lv2_base_ptr->Request_Buf[reqpos];
lv2_base_ptr->Request_Buf[reqpos] = strdup( LV2_ATOM_BODY( lv2_base_ptr->Kit_Id));
lv2_base_ptr->CurReq = reqpos;
if( tmp) free(tmp);
fprintf( stderr, "Path!\n");
*/
break;
}
@ -987,7 +1031,7 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples)
}
else if( ev_ptr->body.type == lv2_base_ptr->URIS.atom_object)
{
fprintf( stderr, "LV2 AO...\n");
DR_LOG_INFO_0( "LV2 AO...");
const LV2_Atom_Object *obj_ptr = (LV2_Atom_Object *)&(ev_ptr->body);
/*
@ -1047,16 +1091,16 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples)
}
if( ignvel)
lv2_base_ptr->Base.Velocity_Ignore_Flag = ((const LV2_Atom_Bool*)ignvel)->body;
DRG_Base.Velocity_Ignore_Flag = ((const LV2_Atom_Bool*)ignvel)->body;
if( ignno)
{
fprintf( stderr, "Change Note Off Ignore Flag!\n");
// lv2_base_ptr->Base.Note_Off_Ignore_Flag = ((const LV2_Atom_Bool*)ignno)->body;
// DRG_Base.Note_Off_Ignore_Flag = ((const LV2_Atom_Bool*)ignno)->body;
}
if( channel_id)
lv2_base_ptr->Base.Channel_Id_Ptr = ((const LV2_Atom_Int*)channel_id)->body;
DRG_Base.Channel_Id_Ptr = ((const LV2_Atom_Int*)channel_id)->body;
if( zerop)
lv2_base_ptr->Zero_Position = ((const LV2_Atom_Int*)zerop)->body;
@ -1090,7 +1134,7 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples)
}
else
{
fprintf( stderr, "Unrecognized event (%d) != (%d)\n", ev_ptr->body.type, lv2_base_ptr->URIS.atom_object);
DR_LOG_WARNING_2( "Unrecognized event (%d) != (%d)", ev_ptr->body.type, lv2_base_ptr->URIS.atom_object);
}
}
/*
@ -1111,6 +1155,7 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples)
fprintf(stderr, "Kit Changes!\n");
}
*/
lv2_atom_forge_pop( &( lv2_base_ptr->Forge), &seq_frame);
pthread_mutex_lock( &( lv2_base_ptr->Load_Mutex));
@ -1218,7 +1263,7 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples)
static void DR_LV2_DeActivate( LV2_Handle instance)
{
fprintf( stderr, "LV2 DeActivate!\n");
DR_LOG_INFO_0( "LV2 DeActivate!");
}
@ -1235,13 +1280,13 @@ static void DR_LV2_Cleanup( LV2_Handle Instance_Ptr)
DRT_LV2_Base *lv2_base_ptr = (DRT_LV2_Base *)Instance_Ptr;
fprintf( stderr, "LV2 Cleanup!\n");
DR_LOG_INFO_0( "LV2 Cleanup!");
DR_Tasks_Dump( &( lv2_base_ptr->Base));
DR_Kits_Stats_Dump( &( lv2_base_ptr->Base));
DR_Tasks_Dump();
DR_Kits_Stats_Dump();
if( ( status = DR_DataStruct_DeInit( &( lv2_base_ptr->Base))) != DRS_OK)
if( ( status = DR_DataStruct_DeInit()) != DRS_OK)
{
printf( "Can't deinit data structures (%d)!\n", status);
}
@ -1250,7 +1295,6 @@ static void DR_LV2_Cleanup( LV2_Handle Instance_Ptr)
free( lv2_base_ptr->Right);
free( lv2_base_ptr->Left);
free( lv2_base_ptr->Request_Buf);
free( lv2_base_ptr);
}
@ -1270,7 +1314,7 @@ static LV2_State_Status DR_LV2_Save_State( LV2_Handle instance
LV2_State_Status lv2_status = LV2_STATE_SUCCESS;
fprintf( stderr, "LV2 Save State!\n");
DR_LOG_INFO_0( "LV2 Save State!");
return( lv2_status);
}
@ -1291,7 +1335,7 @@ static LV2_State_Status DR_LV2_Restore_State( LV2_Handle ins
LV2_State_Status lv2_status = LV2_STATE_SUCCESS;
fprintf( stderr, "LV2 Restore State!\n");
DR_LOG_INFO_0( "LV2 Restore State!");
return( lv2_status);
}

View File

@ -261,8 +261,6 @@ typedef struct
typedef struct DRT_LV2_Base
{
DRT_Base Base;
// Ports
float *Master_Left;
float *Master_Right;
@ -286,6 +284,9 @@ typedef struct DRT_LV2_Base
LV2_URID_Map *Map_Ptr;
DRT_Drummer_URIS URIS;
// Logger
LV2_Log_Logger Logger;
// Kit info
DRT_Kit *Kit_Cur_Ptr;
uint8_t Bank_Id_LSB;
@ -361,6 +362,8 @@ static inline void DR_Map_Drummer_URIS( LV2_URID_Map *Map_Ptr, DRT_Drummer_URI
{
URIS->atom_object = Map_Ptr->map( Map_Ptr->handle, LV2_ATOM__Object);
URIS->midi_event = Map_Ptr->map( Map_Ptr->handle, "http://lv2plug.in/ns/ext/midi#MidiEvent");
/*
URIS->string_urid = Map_Ptr->map( Map_Ptr->handle, LV2_ATOM__String);
URIS->bool_urid = Map_Ptr->map( Map_Ptr->handle, LV2_ATOM__Bool);
@ -386,29 +389,19 @@ static inline void DR_Map_Drummer_URIS( LV2_URID_Map *Map_Ptr, DRT_Drummer_URI
# ifdef _LV2_PLUGIN_C_
/*----------------------------------------------------------------------------*/
/* Private Definitions */
/*----------------------------------------------------------------------------*/
# endif // ifdef _LV2_PLUGIN_C_
#define DRD_MODULE_NAME "lv2"
# ifndef _LV2_PLUGIN_C_
/*----------------------------------------------------------------------------*/
/* Public Prototypes */
/* DRT_LV2_Base */
/*----------------------------------------------------------------------------*/
# else // ifndef _LV2_PLUGIN_C_
DRT_LV2_Base DRG_LV2_Base;
@ -417,10 +410,10 @@ static inline void DR_Map_Drummer_URIS( LV2_URID_Map *Map_Ptr, DRT_Drummer_URI
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* */
/* DR_Log */
/*----------------------------------------------------------------------------*/
static void *DR_LV2_Load_Thread( DRT_LV2_Base *);
DRT_Status DR_LV2_Log_Write( DRT_Log_Type_Id, char *, va_list);
@ -428,7 +421,7 @@ static void *DR_LV2_Load_Thread( DRT_LV2_Base *);
/* */
/*----------------------------------------------------------------------------*/
static inline LV2_Atom *DR_LV2_Message_Midi_Info_Build( DRT_LV2_Base *, uint8_t *);
static void *DR_LV2_Load_Thread();
@ -436,7 +429,7 @@ static inline LV2_Atom *DR_LV2_Message_Midi_Info_Build( DRT_LV2_Base *, uint8_
/* */
/*----------------------------------------------------------------------------*/
DRT_Status DR_LV2_Kit_Samples_Load( DRT_LV2_Base *, DRT_Kit *);
static inline LV2_Atom *DR_LV2_Message_Midi_Info_Build( uint8_t *);
@ -444,7 +437,15 @@ DRT_Status DR_LV2_Kit_Samples_Load( DRT_LV2_Base *, DRT_Kit *);
/* */
/*----------------------------------------------------------------------------*/
DRT_Status DR_LV2_CurKit_Samples_Load( DRT_LV2_Base *);
DRT_Status DR_LV2_Kit_Samples_Load( DRT_Kit *);
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
DRT_Status DR_LV2_CurKit_Samples_Load();
@ -460,7 +461,7 @@ static inline void DR_Layer_To_Sample( DRT_Sample *, float);
/* */
/*----------------------------------------------------------------------------*/
static inline void DR_Sample_Trigger( DRT_LV2_Base *, int, uint8_t *const, uint32_t);
static inline void DR_Sample_Trigger( int, uint8_t *const, uint32_t);
@ -468,7 +469,7 @@ static inline void DR_Sample_Trigger( DRT_LV2_Base *, int, uint8_t *const, ui
/* */
/*----------------------------------------------------------------------------*/
static inline void DR_Sample_Untrigger( DRT_LV2_Base *, int, uint32_t);
static inline void DR_Sample_Untrigger( int, uint32_t);
@ -476,7 +477,7 @@ static inline void DR_Sample_Untrigger( DRT_LV2_Base *, int, uint32_t);
/* */
/*----------------------------------------------------------------------------*/
static inline void DR_Sample_UnSustain( DRT_LV2_Base *, uint32_t);
static inline void DR_Sample_UnSustain( uint32_t);
@ -562,6 +563,21 @@ LV2_SYMBOL_EXPORT const LV2_Descriptor *lv2_descriptor( uint32_t);
# else // ifdef _LV2_PLUGIN_C_
/*----------------------------------------------------------------------------*/
/* Public Prototypes */
/*----------------------------------------------------------------------------*/
# endif // ifndef _LV2_PLUGIN_C_