- Add Multithread task support,

- Add task layer loading support,
- Add task kit loading support,
- Add task kits loading support.
This commit is contained in:
Arnaud G. GIBERT 2022-04-27 23:13:33 +02:00
parent 5dfe9feb17
commit 5113c24f6a
6 changed files with 1302 additions and 270 deletions

File diff suppressed because it is too large Load Diff

View File

@ -11,15 +11,28 @@
/*----------------------------------------------------------------------------*/
/* Pre definitions */
/*----------------------------------------------------------------------------*/
typedef struct DRT_Instrument DRT_Instrument;
typedef struct DRT_Kit DRT_Kit;
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* Global definitions */ /* Global definitions */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
#define NDD_CMD_STATS_GET ( NDT_Command) 65 #define NDD_CMD_ID_REFRESH ( NDT_Command) 65
#define NDD_CMD_SAMPLE_LOAD ( NDT_Command) 66 #define NDD_CMD_STATS_GET ( NDT_Command) 66
#define NDD_CMD_SAMPLE_UNLOAD ( NDT_Command) 67 #define NDD_CMD_GRAPH_PRINT ( NDT_Command) 67
#define NDD_CMD_INDEX0_PRINT ( NDT_Command) 68 #define NDD_CMD_SAMPLE_LOAD ( NDT_Command) 68
#define NDD_CMD_INDEX1_PRINT ( NDT_Command) 69 #define NDD_CMD_SAMPLE_UNLOAD ( NDT_Command) 69
#define NDD_CMD_INDEX0_PRINT ( NDT_Command) 70
#define NDD_CMD_INDEX1_PRINT ( NDT_Command) 71
#define DRD_NAME_LEN (short) 256 #define DRD_NAME_LEN (short) 256
#define DRD_NAME_SIZE (DRD_NAME_LEN + 1) #define DRD_NAME_SIZE (DRD_NAME_LEN + 1)
@ -30,17 +43,24 @@
#define DRD_DESC_LEN (short) 4096 #define DRD_DESC_LEN (short) 4096
#define DRD_DESC_SIZE (DRD_DESC_LEN + 1) #define DRD_DESC_SIZE (DRD_DESC_LEN + 1)
typedef long DRT_Layer_Id;
typedef long DRT_Instrument_Id;
typedef long DRT_Kit_Id; typedef long DRT_Id;
typedef short DRT_Load_Status; typedef DRT_Id DRT_Layer_Id;
typedef DRT_Id DRT_Instrument_Id;
typedef DRT_Id DRT_Kit_Id;
typedef DRT_Id DRT_Task_Id;
#define DRD_LOAD_STATUS_UNKNOWN ( DRT_Load_Status) 0 #define DRD_ID_UNKNOWN (DRT_Id) -1
#define DRD_LOAD_STATUS_UNLOADED ( DRT_Load_Status) 1
#define DRD_LOAD_STATUS_LOADED ( DRT_Load_Status) 2
#define DRD_LOAD_STATUS_TRANSIENT ( DRT_Load_Status) 3
typedef short DRT_Load_Status;
#define DRD_LOAD_STATUS_UNKNOWN ( DRT_Load_Status) -1
#define DRD_LOAD_STATUS_UNLOADED ( DRT_Load_Status) 0
#define DRD_LOAD_STATUS_LOADED ( DRT_Load_Status) 1
#define DRD_LOAD_STATUS_TRANSIENT ( DRT_Load_Status) 2
#define DR_LOAD_STATUS_VALUE_UNKNOWN_IS( v) ( (v) == DRD_LOAD_STATUS_UNKNOWN) #define DR_LOAD_STATUS_VALUE_UNKNOWN_IS( v) ( (v) == DRD_LOAD_STATUS_UNKNOWN)
#define DR_LOAD_STATUS_VALUE_UNLOADED_IS( v) ( (v) == DRD_LOAD_STATUS_UNLOADED) #define DR_LOAD_STATUS_VALUE_UNLOADED_IS( v) ( (v) == DRD_LOAD_STATUS_UNLOADED)
@ -57,6 +77,105 @@ typedef short DRT_Load_Status;
/*---------------------------------------------------------------------------------*/
/* DRT_Task */
/*---------------------------------------------------------------------------------*/
typedef short DRT_Task_Status;
#define DRD_TASK_STATUS_UNKNOWN ( DRT_Task_Status) -1
#define DRD_TASK_STATUS_UNSPAWNED ( DRT_Task_Status) 0
#define DRD_TASK_STATUS_WAITING ( DRT_Task_Status) 1
#define DRD_TASK_STATUS_RUNNING ( DRT_Task_Status) 2
#define DRD_TASK_STATUS_KILLED ( DRT_Task_Status) 3
#define DR_TASK_STATUS_VALUE_UNKNOWN_IS( v) ( (v) == DRD_TASK_STATUS_UNKNOWN)
#define DR_TASK_STATUS_VALUE_UNSPAWNED_IS( v) ( (v) == DRD_TASK_STATUS_UNSPAWNED)
#define DR_TASK_STATUS_VALUE_WAITING_IS( v) ( (v) == DRD_TASK_STATUS_WAITING)
#define DR_TASK_STATUS_VALUE_RUNNING_IS( v) ( (v) == DRD_TASK_STATUS_RUNNING)
#define DR_TASK_STATUS_VALUE_KILLED_IS( v) ( (v) == DRD_TASK_STATUS_KILLED)
#define DR_TASK_STATUS_UNKNOWN_IS( s) DR_TASK_STATUS_VALUE_UNKNOWN_IS( (s)->Status)
#define DR_TASK_STATUS_UNSPAWNED_IS( s) DR_TASK_STATUS_VALUE_UNSPAWNED_IS( (s)->Status)
#define DR_TASK_STATUS_WAITING_IS( s) DR_TASK_STATUS_VALUE_WAITING_IS( (s)->Status)
#define DR_TASK_STATUS_RUNNING_IS( s) DR_TASK_STATUS_VALUE_RUNNING_IS( (s)->Status)
#define DR_TASK_STATUS_KILLED_IS( s) DR_TASK_STATUS_VALUE_KILLED_IS( (s)->Status)
#define DR_TASK_STATUS_VALUE_ASCII_GET( v) ( DR_TASK_STATUS_VALUE_UNKNOWN_IS( (v)) ? "UNKNOWN" : ( DR_TASK_STATUS_VALUE_UNSPAWNED_IS( (v)) ? "UNUNSPAWNED" : ( DR_TASK_STATUS_VALUE_WAITING_IS( (v)) ? "WAITING" : ( DR_TASK_STATUS_VALUE_RUNNING_IS( (v)) ? "RUNNING" : ( DR_TASK_STATUS_VALUE_KILLED_IS( (v)) ? "KILLED" : "???")))))
#define DR_TASK_STATUS_ASCII_GET( s) DR_TASK_STATUS_VALUE_ASCII_GET( (s)->Status)
typedef short DRT_Task_Command;
#define DRD_TASK_CMD_UNKNOWN ( DRT_Task_Command) -1
#define DRD_TASK_CMD_NONE ( DRT_Task_Command) 0
#define DRD_TASK_CMD_TASK_SPAWN ( DRT_Task_Command) 1
#define DRD_TASK_CMD_TASK_KILL ( DRT_Task_Command) 2
#define DRD_TASK_CMD_LAYER_LOAD ( DRT_Task_Command) 3
#define DRD_TASK_CMD_INSTRUMENT_LOAD ( DRT_Task_Command) 4
#define DRD_TASK_CMD_KIT_LOAD ( DRT_Task_Command) 5
#define DR_TASK_CMD_VALUE_UNKNOWN_IS( v) ( (v) == DRD_TASK_CMD_UNKNOWN)
#define DR_TASK_CMD_VALUE_NONE_IS( v) ( (v) == DRD_TASK_CMD_NONE)
#define DR_TASK_CMD_VALUE_TASK_SPAWN_IS( v) ( (v) == DRD_TASK_CMD_TASK_SPAWN)
#define DR_TASK_CMD_VALUE_TASK_KILL_IS( v) ( (v) == DRD_TASK_CMD_TASK_KILL)
#define DR_TASK_CMD_VALUE_LAYER_LOAD_IS( v) ( (v) == DRD_TASK_CMD_LAYER_LOAD)
#define DR_TASK_CMD_VALUE_INSTRUMENT_LOAD_IS( v) ( (v) == DRD_TASK_CMD_INSTRUMENT_LOAD)
#define DR_TASK_CMD_VALUE_KIT_LOAD_IS( v) ( (v) == DRD_TASK_CMD_KIT_LOAD)
#define DR_TASK_CMD_UNKNOWN_IS( s) DR_TASK_CMD_VALUE_UNKNOWN_IS( (s)->Command)
#define DR_TASK_CMD_NONE_IS( s) DR_TASK_CMD_VALUE_NONE_IS( (s)->Command)
#define DR_TASK_CMD_TASK_SPAWN_IS( s) DR_TASK_CMD_VALUE_TASK_SPAWN_IS( (s)->Command)
#define DR_TASK_CMD_TASK_KILL_IS( s) DR_TASK_CMD_VALUE_TASK_KILL_IS( (s)->Command)
#define DR_TASK_CMD_LAYER_LOAD_IS( s) DR_TASK_CMD_VALUE_LAYER_LOAD_IS( (s)->Command)
#define DR_TASK_CMD_INSTRUMENT_LOAD_IS( s) DR_TASK_CMD_VALUE_INSTRUMENT_LOAD_IS( (s)->Command)
#define DR_TASK_CMD_KIT_LOAD_IS( s) DR_TASK_CMD_VALUE_KIT_LOAD_IS( (s)->Command)
#define DR_TASK_CMD_VALUE_ASCII_GET( v) ( DR_TASK_CMD_VALUE_UNKNOWN_IS( (v)) ? "UNKNOWN" : ( DR_TASK_CMD_VALUE_NONE_IS( (v)) ? "None" : ( DR_TASK_CMD_VALUE_TASK_SPAWN_IS( (v)) ? "Task Spawn" : ( DR_TASK_CMD_VALUE_TASK_KILL_IS( (v)) ? "Task Kill" : ( DR_TASK_CMD_VALUE_LAYER_LOAD_IS( (v)) ? "Layer Load" : ( DR_TASK_CMD_VALUE_INSTRUMENT_LOAD_IS( (v)) ? "Instrument Load" : ( DR_TASK_CMD_VALUE_KIT_LOAD_IS( (v)) ? "Kit Load" : "???")))))))
#define DR_TASK_CMD_ASCII_GET( s) DR_TASK_CMD_VALUE_ASCII_GET( (s)->Command)
typedef struct DRT_Task
{
DRT_Task_Status Status;
pthread_t Thread;
pthread_cond_t Cond;
DRT_Task_Command Command;
void *Target_Ptr;
long Count;
} DRT_Task;
/*---------------------------------------------------------------------------------*/
/* DRT_Base */
/*---------------------------------------------------------------------------------*/
typedef int DRT_SampleRate;
typedef struct DRT_Base
{
NDT_Root *Kit_DS_Ptr;
DRT_SampleRate SampleRate;
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;
} DRT_Base;
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
@ -66,7 +185,6 @@ typedef short DRT_Load_Status;
typedef struct DRT_Layer typedef struct DRT_Layer
{ {
DRT_Layer_Id Id; DRT_Layer_Id Id;
DRT_Load_Status Status;
char FileName[ DRD_FILENAME_SIZE]; char FileName[ DRD_FILENAME_SIZE];
float *Sample_Ptr; float *Sample_Ptr;
long Sample_Size; long Sample_Size;
@ -75,6 +193,7 @@ typedef struct DRT_Layer
double Max; double Max;
double Gain; double Gain;
double Pitch; double Pitch;
DRT_Instrument *Instrument_Ptr;
} DRT_Layer; } DRT_Layer;
@ -82,11 +201,11 @@ typedef struct DRT_Layer
typedef struct DRT_Instrument typedef struct DRT_Instrument
{ {
DRT_Instrument_Id Id; DRT_Instrument_Id Id;
DRT_Load_Status Status;
char Name[ DRD_NAME_SIZE]; char Name[ DRD_NAME_SIZE];
double Gain; double Gain;
double Pan_Left; double Pan_Left;
double Pan_Right; double Pan_Right;
DRT_Kit *Kit_Ptr;
NDT_Root *Layer_DS_Ptr; NDT_Root *Layer_DS_Ptr;
} DRT_Instrument; } DRT_Instrument;
@ -95,10 +214,12 @@ typedef struct DRT_Instrument
typedef struct DRT_Kit typedef struct DRT_Kit
{ {
DRT_Kit_Id Id; DRT_Kit_Id Id;
DRT_Kit_Id Logical_Id;
DRT_Load_Status Status; DRT_Load_Status Status;
char Name[ DRD_NAME_SIZE]; char Name[ DRD_NAME_SIZE];
char Desc[ DRD_DESC_SIZE]; char Desc[ DRD_DESC_SIZE];
char DirName[ DRD_DIRNAME_SIZE]; char DirName[ DRD_DIRNAME_SIZE];
DRT_Base *Base_Ptr;
NDT_Root *Instrument_DS_Ptr; NDT_Root *Instrument_DS_Ptr;
} DRT_Kit; } DRT_Kit;
@ -313,6 +434,14 @@ 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 */ /* DR_Kit_Name_Find */
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
@ -341,7 +470,7 @@ extern DRT_Status DR_Kit_Load( DRT_Base *, char *);
/* DR_Kit_Sample_Load */ /* DR_Kit_Sample_Load */
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
extern DRT_Status DR_Kit_Sample_Load( DRT_Kit *, DRT_SampleRate); extern DRT_Status DR_Kit_Sample_Load( DRT_Kit *);
@ -352,22 +481,6 @@ extern DRT_Status DR_Kit_Sample_Load( DRT_Kit *, DRT_SampleRate);
extern DRT_Status DR_Kit_Sample_UnLoad( DRT_Kit *); extern DRT_Status DR_Kit_Sample_UnLoad( DRT_Kit *);
/*---------------------------------------------------------------------------------*/
/* DR_DataStruct_Init */
/*---------------------------------------------------------------------------------*/
extern DRT_Status DR_DataStruct_Init( DRT_Base *, DRT_SampleRate);
/*---------------------------------------------------------------------------------*/
/* DR_DataStruct_DeInit */
/*---------------------------------------------------------------------------------*/
extern DRT_Status DR_DataStruct_DeInit( DRT_Base *);
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* DR_Kits_Sample_Load */ /* DR_Kits_Sample_Load */
@ -393,6 +506,14 @@ extern DRT_Status DR_Kits_Load( DRT_Base *);
/*----------------------------------------------------------------------------*/
/* DR_Kits_Stats_Dump */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Kits_Stats_Dump( DRT_Base *);
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* DR_Kits_Dump */ /* DR_Kits_Dump */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
@ -401,6 +522,70 @@ 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_ # else // ifndef _DATA_STRUCT_C_
@ -431,7 +616,7 @@ DRT_Status DR_Layer_Add( DRT_Layer **, NDT_Root *, DRT_Layer *);
/* DR_Layer_Sample_Load */ /* DR_Layer_Sample_Load */
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
DRT_Status DR_Layer_Sample_Load( DRT_Layer *, DRT_Kit *, DRT_SampleRate); DRT_Status DR_Layer_Sample_Load( DRT_Layer *);
@ -467,6 +652,22 @@ DRT_Status DR_Instrument_Dump( DRT_Instrument *, long);
/*----------------------------------------------------------------------------*/
/* DR_Instrument_Sample_Load */
/*----------------------------------------------------------------------------*/
DRT_Status DR_Instrument_Sample_Load( DRT_Instrument *);
/*----------------------------------------------------------------------------*/
/* DR_Instrument_Sample_Unload */
/*----------------------------------------------------------------------------*/
DRT_Status DR_Instrument_Sample_UnLoad( DRT_Instrument *);
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* DR_Kit_Add */ /* DR_Kit_Add */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
@ -483,6 +684,14 @@ 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);
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
/* DR_Kit_Name_Find */ /* DR_Kit_Name_Find */
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
@ -535,34 +744,18 @@ DRT_Status DR_Kit_Load( DRT_Base *, char *);
/* DR_Kit_Sample_Load */ /* DR_Kit_Sample_Load */
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
DRT_Status DR_Kit_Sample_Load( DRT_Kit *, DRT_SampleRate); DRT_Status DR_Kit_Sample_Load( DRT_Kit *);
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
/* DR_Kit_Sample_UnLoad */ /* DR_Kit_Sample_UnLoad */
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
DRT_Status DR_Kit_Sample_UnLoad( DRT_Kit *); DRT_Status DR_Kit_Sample_UnLoad( DRT_Kit *);
/*---------------------------------------------------------------------------------*/
/* DR_DataStruct_Init */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_DataStruct_Init( DRT_Base *, DRT_SampleRate);
/*---------------------------------------------------------------------------------*/
/* DR_DataStruct_DeInit */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_DataStruct_DeInit( DRT_Base *);
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* DR_Kits_Sample_Load */ /* DR_Kits_Sample_Load */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
@ -587,6 +780,14 @@ DRT_Status DR_Kits_Load( DRT_Base *);
/*----------------------------------------------------------------------------*/
/* DR_Kits_Stats_Dump */
/*----------------------------------------------------------------------------*/
DRT_Status DR_Kits_Stats_Dump( DRT_Base *);
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* DR_Kits_Dump */ /* DR_Kits_Dump */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
@ -595,6 +796,78 @@ DRT_Status DR_Kits_Dump( DRT_Base *);
/*----------------------------------------------------------------------------*/
/* DR_Kits_Graph_Dump */
/*----------------------------------------------------------------------------*/
DRT_Status DR_Kits_Graph_Dump( DRT_Base *);
/*----------------------------------------------------------------------------*/
/* DR_Task_Tread */
/*----------------------------------------------------------------------------*/
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 *);
/*----------------------------------------------------------------------------*/
/* DR_Task_Id_Kill */
/*----------------------------------------------------------------------------*/
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 *);
/*----------------------------------------------------------------------------*/
/* DR_Task_Wait */
/*----------------------------------------------------------------------------*/
DRT_Status DR_Task_Wait( DRT_Base *);
/*----------------------------------------------------------------------------*/
/* DR_Tasks_Dump */
/*----------------------------------------------------------------------------*/
DRT_Status DR_Tasks_Dump( DRT_Base *);
/*---------------------------------------------------------------------------------*/
/* DR_DataStruct_Init */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_DataStruct_Init( DRT_Base *, DRT_SampleRate, DRT_Task_Id);
/*---------------------------------------------------------------------------------*/
/* DR_DataStruct_DeInit */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_DataStruct_DeInit( DRT_Base *);
# endif // ifndef _DATASTRUCT_C_ # endif // ifndef _DATASTRUCT_C_

View File

@ -21,7 +21,7 @@ DRT_Status DR_Init( DRT_Base *Base_Ptr)
DRT_Status status; DRT_Status status;
if( ( status = DR_DataStruct_Init( Base_Ptr, DRD_SAMPLE_RATE_DEFAULT)) != DRS_OK) if( ( status = DR_DataStruct_Init( Base_Ptr, DRD_SAMPLE_RATE_DEFAULT, DRD_THREAD_NUMBER_DEFAULT)) != DRS_OK)
{ {
fprintf( stderr, "Can't init data structures (%d) !", status); fprintf( stderr, "Can't init data structures (%d) !", status);
return( status); return( status);
@ -66,6 +66,7 @@ int main( int argc, char **argv)
DRT_Base base; DRT_Base base;
DRT_Status status; DRT_Status status;
DRT_Kit *kit_ptr; DRT_Kit *kit_ptr;
DRT_Id i;
if( ( status = DR_Init( &base)) != DRS_OK) if( ( status = DR_Init( &base)) != DRS_OK)
@ -77,16 +78,16 @@ int main( int argc, char **argv)
{ {
exit( -1); exit( -1);
} }
/*
if( ( status = DR_Kit_Id_Find( &kit_ptr, base.Kit_DS_Ptr, 0)) != DRS_OK)
if( ( status = DR_Kit_Id_Find( &kit_ptr, base.Kit_DS_Ptr, 0)) != DRS_OK) // if( ( status = DR_Kit_Logical_Id_Find( &kit_ptr, base.Kit_DS_Ptr, 31)) != DRS_OK)
// if( ( status = DR_Kit_Name_Find( &kit_ptr, base.Kit_DS_Ptr, "Mars LM1: 01-777 Clean Kit")) != DRS_OK) // if( ( status = DR_Kit_Name_Find( &kit_ptr, base.Kit_DS_Ptr, "HardElectro1")) != DRS_OK)
{ {
exit( -1); exit( -1);
} }
else else
{ {
if( ( status = DR_Kit_Sample_Load( kit_ptr, base.SampleRate)) != DRS_OK) if( ( status = DR_Kit_Sample_Load( kit_ptr)) != DRS_OK)
{ {
exit( -1); exit( -1);
} }
@ -97,18 +98,74 @@ int main( int argc, char **argv)
{ {
exit( -1); exit( -1);
} }
*/ */
/*
fprintf( stderr, "After!\n"); fprintf( stderr, "After!\n");
if( ( status = DR_Kit_Sample_Load( kit_ptr, base.SampleRate)) != DRS_OK) if( ( status = DR_Kit_Sample_Load( kit_ptr)) != DRS_OK)
{ {
exit( -1); exit( -1);
} }
*/
// }
DR_Kits_Sample_Load( &base);
/*
for( i = 0; i < 264; i++)
{
if( ( status = DR_Kit_Logical_Id_Find( &kit_ptr, base.Kit_DS_Ptr, i)) == DRS_OK)
{
printf( "Loading Logical Id: (%d)\n", i);
DR_Kit_Sample_Load( kit_ptr);
}
}
*/
/*
if( DR_Task_Wait( &base) != DRS_OK)
{
printf( "DR_Task_Wait failed (%d)!\n");
exit(-1);
}
*/
fprintf( stderr, "hello world!\n");
// DR_Kits_Graph_Dump( &base);
/*
if( ( status = DR_Kits_Dump( &base)) != DRS_OK)
{
exit( -1);
}
*/
/*
DR_Task_Run( &base, (DRT_Instrument *)1);
DR_Task_Run( &base, (DRT_Instrument *)2);
DR_Task_Run( &base, (DRT_Instrument *)3);
*/
// sleep( 10);
/*
if( ( status = DR_Tasks_Dump( &base)) != DRS_OK)
{
exit( -1);
} }
fprintf( stderr, "hello world!\n"); if( ( status = DR_Task_Wait( &base)) != DRS_OK)
{
if( ( status = DR_Kits_Dump( &base)) != DRS_OK) exit( -1);
}
*/
if( ( status = DR_Tasks_Dump( &base)) != DRS_OK)
{
exit( -1);
}
if( ( status = DR_Kits_Stats_Dump( &base)) != DRS_OK)
{ {
exit( -1); exit( -1);
} }

View File

@ -13,6 +13,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <ctype.h> #include <ctype.h>
#include <math.h> #include <math.h>
#include <unistd.h>
#include <libgen.h> #include <libgen.h>
#include <glob.h> #include <glob.h>
@ -31,8 +32,6 @@
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* Global definitions */ /* Global definitions */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
@ -42,13 +41,28 @@ typedef short DRT_Boolean;
#define DRD_FALSE ( DRT_Boolean) 0 #define DRD_FALSE ( DRT_Boolean) 0
#define DRD_TRUE ( DRT_Boolean) 1 #define DRD_TRUE ( DRT_Boolean) 1
#define DR_BOOLEAN_VALUE_FALSE_IS( v) ( (v) == DRD_FALSE)
#define DR_BOOLEAN_VALUE_TRUE_IS( v) ( (v) == DRD_TRUE)
#define DR_BOOLEAN_VALUE_ASCII_GET( v) ( DR_BOOLEAN_VALUE_FALSE_IS( (v)) ? "FALSE" : ( DR_BOOLEAN_VALUE_TRUE_IS( (v)) ? "TRUE" : "???"))
#define DRD_NO 'n' #define DRD_NO 'n'
#define DRD_YES 'y' #define DRD_YES 'y'
#define DR_MAX(A,B) (((A) < (B)) ? (B) : (A)) #define DR_MAX(A,B) (((A) < (B)) ? (B) : (A))
#define DR_MIN(A,B) (((A) > (B)) ? (B) : (A)) #define DR_MIN(A,B) (((A) > (B)) ? (B) : (A))
#define DRD_SAMPLE_RATE_DEFAULT 44100
#define DRD_SAMPLE_RATE_DEFAULT 44100
#define DRD_THREAD_NUMBER_DEFAULT 16L
#define DRD_TASK_LOAD_LAYER_DEFAULT DRD_TRUE
#define DRD_TASK_LOAD_INSTRUMENT_DEFAULT DRD_FALSE
#define DRD_TASK_LOAD_KIT_DEFAULT DRD_FALSE
#define DRD_TASK_SYNC_KIT_DEFAULT DRD_TRUE
#define DRD_TASK_SYNC_KITS_DEFAULT DRD_TRUE
@ -74,17 +88,12 @@ typedef short DRT_Status;
/*---------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* DRT_Base */ /* Drummer Includes */
/*---------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
typedef int DRT_SampleRate; #include <datastruct.h>
#include <lv2_plugin.h>
typedef struct DRT_Base
{
NDT_Root *Kit_DS_Ptr;
DRT_SampleRate SampleRate;
} DRT_Base;
@ -125,7 +134,5 @@ int main( int, char **);
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
#include <datastruct.h>
#include <lv2_plugin.h>
#endif #endif

2
go.sh
View File

@ -13,7 +13,7 @@ done
cmd="gcc -g -o drummer ${module_list//.c/.o} drummer.o -fPIC -ldl -lxml2 -lz -llzma -lm -lsndfile -lsamplerate" cmd="gcc -g -o drummer ${module_list//.c/.o} drummer.o -fPIC -ldl -lpthread -lxml2 -lz -llzma -lm -lsndfile -lsamplerate"
echo ${cmd} echo ${cmd}
eval ${cmd} eval ${cmd}

View File

@ -32,7 +32,7 @@ DRT_Status DR_LV2_Kit_Sample_Load( DRT_LV2_Base *LV2_Base_Ptr, DRT_Kit *Kit_P
{ {
// fprintf( stderr, "Sample Rate: (%d)\n", LV2_Base_Ptr->Base.SampleRate); // fprintf( stderr, "Sample Rate: (%d)\n", LV2_Base_Ptr->Base.SampleRate);
if( ( status = DR_Kit_Sample_Load( Kit_Ptr, LV2_Base_Ptr->Base.SampleRate)) == DRS_OK) if( ( status = DR_Kit_Sample_Load( Kit_Ptr)) == DRS_OK)
{ {
LV2_Base_Ptr->Kit_Cur_Ptr = Kit_Ptr; LV2_Base_Ptr->Kit_Cur_Ptr = Kit_Ptr;
@ -67,7 +67,7 @@ DRT_Status DR_LV2_Kit_Sample_Load( DRT_LV2_Base *LV2_Base_Ptr, DRT_Kit *Kit_P
pthread_mutex_unlock( &( LV2_Base_Ptr->Load_Mutex)); pthread_mutex_unlock( &( LV2_Base_Ptr->Load_Mutex));
LV2_Base_Ptr->Sample_Number = Kit_Ptr->Instrument_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Node_Number; LV2_Base_Ptr->Sample_Number = Kit_Ptr->Instrument_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Node_Number;
fprintf( stderr, "Loaded: (%d) samples!\n", LV2_Base_Ptr->Sample_Number); fprintf( stderr, "Loaded: (%d) instruments!\n", LV2_Base_Ptr->Sample_Number);
// DR_Kit_Dump( Kit_Ptr, 0); // DR_Kit_Dump( Kit_Ptr, 0);
} }
@ -95,14 +95,32 @@ DRT_Status DR_LV2_CurKit_Sample_Load( DRT_LV2_Base *LV2_Base_Ptr)
if( kit_id == LV2_Base_Ptr->Kit_Id) if( kit_id == LV2_Base_Ptr->Kit_Id)
{ {
fprintf( stderr, "Same 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); 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);
status = DRS_OK; status = DRS_OK;
} }
else else
{ {
if( ( status = DR_Kit_Id_Find( &Kit_Ptr, LV2_Base_Ptr->Base.Kit_DS_Ptr, kit_id)) == DRS_OK) if( ( status = DR_Kit_Logical_Id_Find( &Kit_Ptr, LV2_Base_Ptr->Base.Kit_DS_Ptr, kit_id)) != DRS_OK)
{ {
fprintf( stderr, "New 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); 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);
if( LV2_Base_Ptr->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);
}
}
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);
LV2_Base_Ptr->Bank_Id_LSB = LV2_Base_Ptr->Bank_Id_LSB_New; 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->Bank_Id_MSB = LV2_Base_Ptr->Bank_Id_MSB_New;
@ -480,7 +498,7 @@ static LV2_Handle DR_LV2_Instantiate( const LV2_Descriptor *LV2_Descriptor
lv2_base_ptr->Bank_Id_LSB_New = 0; lv2_base_ptr->Bank_Id_LSB_New = 0;
lv2_base_ptr->Bank_Id_MSB_New = 0; lv2_base_ptr->Bank_Id_MSB_New = 0;
lv2_base_ptr->Program_Id_New = 0; lv2_base_ptr->Program_Id_New = 0;
lv2_base_ptr->Kit_Id = -1; lv2_base_ptr->Kit_Id = DRD_ID_UNKNOWN;
lv2_base_ptr->Current_Path = NULL; lv2_base_ptr->Current_Path = NULL;
lv2_base_ptr->CurReq = -1; lv2_base_ptr->CurReq = -1;
@ -569,21 +587,21 @@ static LV2_Handle DR_LV2_Instantiate( const LV2_Descriptor *LV2_Descriptor
lv2_base_ptr->Pans[i] = NULL; lv2_base_ptr->Pans[i] = NULL;
} }
if( ( status = DR_DataStruct_Init( &( lv2_base_ptr->Base), (DRT_SampleRate)SampleRate)) != DRS_OK) 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) !", status); fprintf( stderr, "Can't init data structures (%d)!\n", status);
} }
else else
{ {
if( ( status = DR_Kits_Load( & ( lv2_base_ptr->Base))) != DRS_OK) if( ( status = DR_Kits_Load( & ( lv2_base_ptr->Base))) != DRS_OK)
{ {
fprintf( stderr, "Can't load kits (%d) !", status); fprintf( stderr, "Can't load kits (%d)!\n", status);
} }
else else
{ {
if( ( status = DR_LV2_CurKit_Sample_Load( lv2_base_ptr)) != DRS_OK) if( ( status = DR_LV2_CurKit_Sample_Load( lv2_base_ptr)) != DRS_OK)
{ {
fprintf( stderr, "Can't load kit sample (%d) !", status); fprintf( stderr, "Can't load kit sample (%d)!\n", status);
} }
else else
{ {
@ -723,7 +741,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) LV2_ATOM_SEQUENCE_FOREACH( lv2_base_ptr->Control_Port, ev_ptr)
{ {
fprintf( stderr, "LV2 Event!\n"); // fprintf( stderr, "LV2 Event!\n");
if( ev_ptr->body.type == lv2_base_ptr->URIS.midi_event) if( ev_ptr->body.type == lv2_base_ptr->URIS.midi_event)
{ {
@ -735,7 +753,7 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples)
uint8_t value; uint8_t value;
fprintf( stderr, " Midi Event!\n"); // fprintf( stderr, " Midi Event!\n");
if( ( lv2_base_ptr->Channel_Nb == 0) || ( channel == ( lv2_base_ptr->Channel_Nb - 1))) if( ( lv2_base_ptr->Channel_Nb == 0) || ( channel == ( lv2_base_ptr->Channel_Nb - 1)))
{ {
@ -834,7 +852,7 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples)
default: default:
{ {
fprintf( stderr, "Unhandeled status: (%i) Data 1: (%i) Data 2: (%d)\n", ( *data) >> 4, data[1], data[2]); // fprintf( stderr, "Unhandeled status: (%i) Data 1: (%i) Data 2: (%d)\n", ( *data) >> 4, data[1], data[2]);
break; break;
} }
} }
@ -1072,6 +1090,10 @@ static void DR_LV2_Cleanup( LV2_Handle Instance_Ptr)
fprintf( stderr, "LV2 Cleanup!\n"); fprintf( stderr, "LV2 Cleanup!\n");
DR_Tasks_Dump( &( lv2_base_ptr->Base));
DR_Kits_Stats_Dump( &( lv2_base_ptr->Base));
if( ( status = DR_DataStruct_DeInit( &( lv2_base_ptr->Base))) != DRS_OK) if( ( status = DR_DataStruct_DeInit( &( lv2_base_ptr->Base))) != DRS_OK)
{ {
printf( "Can't deinit data structures (%d)!\n", status); printf( "Can't deinit data structures (%d)!\n", status);