- Add Sample loading and unloading support,

- Add preliminary LV2 sample loading support,
- Add LV2 multy layer sample play,
- Add LV2 Bank select & Program change midi message support,
- Fix minor bugs...
- No GFX
This commit is contained in:
Arnaud G. GIBERT 2022-04-20 12:37:32 +02:00
parent 6be9e0f582
commit 84e23826c3
9 changed files with 2054 additions and 2494 deletions

View File

@ -92,11 +92,14 @@ NDT_Status DR_Layer_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_N
( *Layer_Ptr_Ptr)->Sample_Ptr = Layer_Template_Ptr->Sample_Ptr; ( *Layer_Ptr_Ptr)->Sample_Ptr = Layer_Template_Ptr->Sample_Ptr;
( *Layer_Ptr_Ptr)->Sample_Size = Layer_Template_Ptr->Sample_Size; ( *Layer_Ptr_Ptr)->Sample_Size = Layer_Template_Ptr->Sample_Size;
( *Layer_Ptr_Ptr)->SF_Info_Ptr = Layer_Template_Ptr->SF_Info_Ptr;
( *Layer_Ptr_Ptr)->Min = Layer_Template_Ptr->Min; ( *Layer_Ptr_Ptr)->Min = Layer_Template_Ptr->Min;
( *Layer_Ptr_Ptr)->Max = Layer_Template_Ptr->Max; ( *Layer_Ptr_Ptr)->Max = Layer_Template_Ptr->Max;
( *Layer_Ptr_Ptr)->Gain = Layer_Template_Ptr->Gain; ( *Layer_Ptr_Ptr)->Gain = Layer_Template_Ptr->Gain;
( *Layer_Ptr_Ptr)->Pitch = Layer_Template_Ptr->Pitch; ( *Layer_Ptr_Ptr)->Pitch = Layer_Template_Ptr->Pitch;
// fprintf( stderr, "");
return( NDS_OK); return( NDS_OK);
} }
else else
@ -113,10 +116,7 @@ NDT_Status DR_Layer_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_N
Command_Name = "NDD_CMD_VALUE_FREE"; Command_Name = "NDD_CMD_VALUE_FREE";
if( Layer_Ptr->Sample_Ptr != NULL) DR_Layer_Sample_UnLoad( Layer_Ptr);
{
free(Layer_Ptr->Sample_Ptr);
}
free( Layer_Ptr); free( Layer_Ptr);
@ -329,7 +329,32 @@ NDT_Status DR_Layer_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_N
} }
} }
default: case NDD_CMD_SAMPLE_UNLOAD:
{
ND_VA_ARG_GET( Next_Node_Ptr, *Args_Ptr, NDT_Node *);
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
ND_VA_ARG_GET( Kit_Ptr, user_args, DRT_Kit *);
ND_VA_LIST_CLOSE( user_args);
DRT_Layer *Layer_Ptr = Node_Ptr->Value;
Command_Name = "NDD_CMD_SAMPLE_UNLOAD";
if( DR_Layer_Sample_UnLoad( Layer_Ptr) != DRS_OK)
{
return( NDS_OK);
}
else
{
return( NDS_OK);
}
}
default:
{ {
printf( "Layer_Manager() called with an undefined command %d\n", Command); printf( "Layer_Manager() called with an undefined command %d\n", Command);
return( NDS_ERRAPI); return( NDS_ERRAPI);
@ -684,6 +709,23 @@ NDT_Status DR_Instrument_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id,
return( ND_DataStruct_Traverse( Instrument_Ptr->Layer_DS_Ptr, NDD_CMD_SAMPLE_LOAD, Kit_Ptr, SampleRate)); return( ND_DataStruct_Traverse( Instrument_Ptr->Layer_DS_Ptr, NDD_CMD_SAMPLE_LOAD, Kit_Ptr, SampleRate));
} }
case NDD_CMD_SAMPLE_UNLOAD:
{
ND_VA_ARG_GET( Next_Node_Ptr, *Args_Ptr, NDT_Node *);
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
ND_VA_ARG_GET( Kit_Ptr, user_args, DRT_Kit *);
ND_VA_LIST_CLOSE( user_args);
DRT_Instrument *Instrument_Ptr = Node_Ptr->Value;
Command_Name = "NDD_CMD_SAMPLE_UNLOAD";
return( ND_DataStruct_Traverse( Instrument_Ptr->Layer_DS_Ptr, NDD_CMD_SAMPLE_UNLOAD, Kit_Ptr));
}
default: default:
{ {
printf( "Instrument_Manager() called with an undefined command %d\n", Command); printf( "Instrument_Manager() called with an undefined command %d\n", Command);
@ -745,7 +787,22 @@ NDT_Status DR_Kit_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
... ...
*/ */
case NDD_CMD_INDEX0_PRINT: case NDD_CMD_VALUE_FIND:
{
if( Kit_Ptr->Name[0] == 0)
{
*Reply_Index_Id_Ptr = 0;
}
else
{
*Reply_Index_Id_Ptr = 1;
}
*Reply_Command_Ptr = Cmd;
break;
}
case NDD_CMD_INDEX0_PRINT:
{ {
*Reply_Index_Id_Ptr = 0; *Reply_Index_Id_Ptr = 0;
*Reply_Command_Ptr = Cmd; *Reply_Command_Ptr = Cmd;
@ -787,8 +844,8 @@ NDT_Status DR_Kit_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
{ {
( *Kit_Ptr_Ptr)->Id = Root_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Node_Number; ( *Kit_Ptr_Ptr)->Id = Root_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Node_Number;
strncpy( ( *Kit_Ptr_Ptr)->Name, Kit_Template_Ptr->Name, NAME_SIZE); strncpy( ( *Kit_Ptr_Ptr)->Name, Kit_Template_Ptr->Name, NAME_SIZE);
strncpy( ( *Kit_Ptr_Ptr)->Desc, Kit_Template_Ptr->Desc, DESC_SIZE); strncpy( ( *Kit_Ptr_Ptr)->Desc, Kit_Template_Ptr->Desc, DESC_SIZE);
strncpy( ( *Kit_Ptr_Ptr)->DirName, Kit_Template_Ptr->DirName, DIRNAME_SIZE); strncpy( ( *Kit_Ptr_Ptr)->DirName, Kit_Template_Ptr->DirName, DIRNAME_SIZE);
if( ( nd_status = ND_DataStruct_Open( &((*Kit_Ptr_Ptr)->Instrument_DS_Ptr), DRD_INSTRUMENT_DS_INDEX_NB, DRG_Instrument_DS_Index_Tab_Initial, "Instrument_Manager", DR_Instrument_Manager, NULL, NULL, NULL, NULL, NDD_TRUE, NULL)) != NDS_OK) if( ( nd_status = ND_DataStruct_Open( &((*Kit_Ptr_Ptr)->Instrument_DS_Ptr), DRD_INSTRUMENT_DS_INDEX_NB, DRG_Instrument_DS_Index_Tab_Initial, "Instrument_Manager", DR_Instrument_Manager, NULL, NULL, NULL, NULL, NDD_TRUE, NULL)) != NDS_OK)
@ -1043,7 +1100,7 @@ NDT_Status DR_Kit_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
/* /*
case NDD_CMD_PHONEBOOK_SAVE: case NDD_CMD_PHONEBOOK_SAVE:
{ {
/* */ /*
ND_VA_ARG_GET( Next_Node_Ptr, *Args_Ptr, NDT_Node *); ND_VA_ARG_GET( Next_Node_Ptr, *Args_Ptr, NDT_Node *);
ND_VA_LIST_OPEN( user_args, *Args_Ptr); ND_VA_LIST_OPEN( user_args, *Args_Ptr);
@ -1127,12 +1184,31 @@ DRT_Status DR_Layer_Sample_Load( DRT_Layer *Layer_Ptr, DRT_Kit *Kit_Ptr, doub
DRT_Status status; DRT_Status status;
SNDFILE *sndf_ptr; SNDFILE *sndf_ptr;
// int load_sample(char* path, drmr_layer* layer, double target_rate) {
// long size;
fprintf( stderr, "Loading: [%s]\n", Layer_Ptr->FileName); fprintf( stderr, "Loading: [%s]\n", Layer_Ptr->FileName);
if( Layer_Ptr->SF_Info_Ptr != NULL)
{
if( Layer_Ptr->Sample_Ptr != NULL)
{
fprintf( stderr, "Skiping: [%s]\n", Layer_Ptr->FileName);
return( DRS_OK);
}
else
{
fprintf( stderr, "Freeing SF_Info: [%s]\n", Layer_Ptr->FileName);
free( Layer_Ptr->SF_Info_Ptr );
}
}
else
{
if( Layer_Ptr->Sample_Ptr != NULL)
{
fprintf( stderr, "Freeing Sample: [%s]\n", Layer_Ptr->FileName);
free( Layer_Ptr->Sample_Ptr);
}
}
if( ( Layer_Ptr->SF_Info_Ptr = malloc( sizeof(SF_INFO))) == NULL) if( ( Layer_Ptr->SF_Info_Ptr = malloc( sizeof(SF_INFO))) == NULL)
{ {
fprintf( stderr, "Can't allocate SF_Info buffer !\n"); fprintf( stderr, "Can't allocate SF_Info buffer !\n");
@ -1143,7 +1219,7 @@ DRT_Status DR_Layer_Sample_Load( DRT_Layer *Layer_Ptr, DRT_Kit *Kit_Ptr, doub
if( ( sndf_ptr = sf_open( Layer_Ptr->FileName, SFM_READ, Layer_Ptr->SF_Info_Ptr)) == NULL) if( ( sndf_ptr = sf_open( Layer_Ptr->FileName, SFM_READ, Layer_Ptr->SF_Info_Ptr)) == NULL)
{ {
fprintf( stderr, "Can't open sample file [%s] (%d)!\n", Layer_Ptr->FileName, sf_strerror( (SNDFILE *)( Layer_Ptr->Sample_Ptr))); fprintf( stderr, "Can't open sample file [%s] (%ld)!\n", Layer_Ptr->FileName, (long)sf_strerror( (SNDFILE *)( Layer_Ptr->Sample_Ptr)));
status = DRS_KO; status = DRS_KO;
} }
else else
@ -1155,16 +1231,16 @@ DRT_Status DR_Layer_Sample_Load( DRT_Layer *Layer_Ptr, DRT_Kit *Kit_Ptr, doub
} }
else else
{ {
Layer_Ptr->Sample_Size = Layer_Ptr->SF_Info_Ptr->frames * Layer_Ptr->SF_Info_Ptr->channels * sizeof( float); Layer_Ptr->Sample_Size = Layer_Ptr->SF_Info_Ptr->frames * Layer_Ptr->SF_Info_Ptr->channels;
if( ( Layer_Ptr->Sample_Ptr = malloc( Layer_Ptr->Sample_Size)) == NULL) if( ( Layer_Ptr->Sample_Ptr = malloc( Layer_Ptr->Sample_Size * sizeof( float))) == NULL)
{ {
fprintf(stderr,"Can't allocate sample memory: (%d) for [%s]!\n", Layer_Ptr->Sample_Size, Layer_Ptr->FileName); fprintf(stderr,"Can't allocate sample memory: (%ld) for [%s]!\n", Layer_Ptr->Sample_Size, Layer_Ptr->FileName);
status = DRS_KO; status = DRS_KO;
} }
else else
{ {
sf_read_float( sndf_ptr, Layer_Ptr->Sample_Ptr, ( Layer_Ptr->Sample_Size / sizeof( float))); sf_read_float( sndf_ptr, Layer_Ptr->Sample_Ptr, ( Layer_Ptr->Sample_Size));
status = DRS_OK; status = DRS_OK;
@ -1176,6 +1252,8 @@ DRT_Status DR_Layer_Sample_Load( DRT_Layer *Layer_Ptr, DRT_Kit *Kit_Ptr, doub
long out_size; long out_size;
fprintf( stderr, "Resampling: [%s] (%d)->(%lf)\n", Layer_Ptr->FileName, Layer_Ptr->SF_Info_Ptr->samplerate, SampleRate);
src_data.data_in = Layer_Ptr->Sample_Ptr; src_data.data_in = Layer_Ptr->Sample_Ptr;
src_data.input_frames = Layer_Ptr->SF_Info_Ptr->frames; src_data.input_frames = Layer_Ptr->SF_Info_Ptr->frames;
src_data.src_ratio = SampleRate / Layer_Ptr->SF_Info_Ptr->samplerate; src_data.src_ratio = SampleRate / Layer_Ptr->SF_Info_Ptr->samplerate;
@ -1185,7 +1263,7 @@ DRT_Status DR_Layer_Sample_Load( DRT_Layer *Layer_Ptr, DRT_Kit *Kit_Ptr, doub
if( ( src_data.data_out = malloc( out_size)) == NULL) if( ( src_data.data_out = malloc( out_size)) == NULL)
{ {
fprintf( stderr,"Can't allocate resample memory: (%d) for [%s]!\n", out_size, Layer_Ptr->FileName); fprintf( stderr,"Can't allocate resample memory: (%ld) for [%s]!\n", out_size, Layer_Ptr->FileName);
status = DRS_KO; status = DRS_KO;
} }
else else
@ -1208,7 +1286,7 @@ DRT_Status DR_Layer_Sample_Load( DRT_Layer *Layer_Ptr, DRT_Kit *Kit_Ptr, doub
free( Layer_Ptr->Sample_Ptr); free( Layer_Ptr->Sample_Ptr);
Layer_Ptr->Sample_Ptr = src_data.data_out; Layer_Ptr->Sample_Ptr = src_data.data_out;
Layer_Ptr->Sample_Size = src_data.output_frames_gen * Layer_Ptr->SF_Info_Ptr->channels * sizeof( float); Layer_Ptr->Sample_Size = src_data.output_frames_gen * Layer_Ptr->SF_Info_Ptr->channels;
Layer_Ptr->SF_Info_Ptr->samplerate = SampleRate; Layer_Ptr->SF_Info_Ptr->samplerate = SampleRate;
Layer_Ptr->SF_Info_Ptr->frames = src_data.output_frames_gen; Layer_Ptr->SF_Info_Ptr->frames = src_data.output_frames_gen;
} }
@ -1220,7 +1298,9 @@ DRT_Status DR_Layer_Sample_Load( DRT_Layer *Layer_Ptr, DRT_Kit *Kit_Ptr, doub
sf_close( sndf_ptr); sf_close( sndf_ptr);
} }
free( Layer_Ptr->SF_Info_Ptr); // fprintf( stderr, "Debug !\n");
// DR_Layer_Dump(Layer_Ptr, 0);
// free( Layer_Ptr->SF_Info_Ptr);
return( status); return( status);
} }
@ -1235,6 +1315,22 @@ DRT_Status DR_Layer_Sample_Load( DRT_Layer *Layer_Ptr, DRT_Kit *Kit_Ptr, doub
DRT_Status DR_Layer_Sample_UnLoad( DRT_Layer *Layer_Ptr) DRT_Status DR_Layer_Sample_UnLoad( DRT_Layer *Layer_Ptr)
{ {
fprintf( stderr, "UnLoading: [%s]\n", Layer_Ptr->FileName);
if( Layer_Ptr->Sample_Ptr != NULL)
{
fprintf( stderr, "Freeing Sample!\n");
free( Layer_Ptr->Sample_Ptr);
}
if( Layer_Ptr->SF_Info_Ptr != NULL)
{
fprintf( stderr, "Freeing SF_Info!\n");
free( Layer_Ptr->SF_Info_Ptr);
}
return( NDS_OK);
} }
@ -1250,10 +1346,18 @@ DRT_Status DR_Layer_Dump( DRT_Layer *Layer_Ptr, long count)
NDT_Status nd_status; NDT_Status nd_status;
fprintf( stderr, " %03d) Layer: ", count); fprintf( stderr, " %03ld) Layer: ", count);
fprintf( stderr, " Id: (% 3d) File Name: [%s] Sample: [%lx] Sample Size: (%d) Min: (%f) Max: (%f) Gain: (%f) Pitch: (%f)\n", fprintf( stderr, " Id: (% 3d) File Name: [%s] Sample: [%lx] Sample Size: (%ld) Min: (%f) Max: (%f) Gain: (%f) Pitch: (%f)",
Layer_Ptr->Id, Layer_Ptr->FileName, Layer_Ptr->Sample_Ptr, Layer_Ptr->Sample_Size, Layer_Ptr->Min, Layer_Ptr->Max, Layer_Ptr->Gain, Layer_Ptr->Pitch); Layer_Ptr->Id, Layer_Ptr->FileName, (long)Layer_Ptr->Sample_Ptr, Layer_Ptr->Sample_Size, Layer_Ptr->Min, Layer_Ptr->Max, Layer_Ptr->Gain, Layer_Ptr->Pitch);
// fprintf( stderr, "\n");
if( Layer_Ptr->SF_Info_Ptr != NULL)
{
fprintf( stderr, " Channels: (%d) Rate: (%d)\n", Layer_Ptr->SF_Info_Ptr->channels, Layer_Ptr->SF_Info_Ptr->samplerate);
}
else
{
fprintf( stderr, "\n");
}
return( DRS_OK); return( DRS_OK);
} }
@ -1293,7 +1397,7 @@ DRT_Status DR_Instrument_Add( DRT_Instrument **Instrument_Ptr_Ptr, NDT_Root *
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
/* DR_Instrument_Dump */ /* DR_Instrument_Dump */
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
DRT_Status DR_Instrument_Dump( DRT_Instrument *Instrument_Ptr, long Count) DRT_Status DR_Instrument_Dump( DRT_Instrument *Instrument_Ptr, long Count)
@ -1302,7 +1406,7 @@ DRT_Status DR_Instrument_Dump( DRT_Instrument *Instrument_Ptr, long Count)
long count2; long count2;
fprintf( stderr, " %03d) Instrument: ", Count); fprintf( stderr, " %03ld) Instrument: ", Count);
fprintf( stderr, " Id: (% 3d) Name: [%s] Gain: (%f) Pan Left: (%f) Pan Right: (%f)\n", fprintf( stderr, " Id: (% 3d) Name: [%s] Gain: (%f) Pan Left: (%f) Pan Right: (%f)\n",
Instrument_Ptr->Id, Instrument_Ptr->Name, Instrument_Ptr->Gain, Instrument_Ptr->Pan_Left, Instrument_Ptr->Pan_Right); Instrument_Ptr->Id, Instrument_Ptr->Name, Instrument_Ptr->Gain, Instrument_Ptr->Pan_Left, Instrument_Ptr->Pan_Right);
// fprintf( stderr, "\n"); // fprintf( stderr, "\n");
@ -1363,21 +1467,77 @@ DRT_Status DR_Kit_Add( DRT_Kit **Kit_Ptr_Ptr, NDT_Root *DS_Ptr, DRT_Kit *Kit
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
/* DR_Kit_Sample_Load */ /* DR_Kit_Id_Find */
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
DRT_Status DR_Kit_Sample_Load( DRT_Kit *Kit_Ptr, double SampleRate) DRT_Status DR_Kit_Id_Find( DRT_Kit **Kit_Ptr_Ptr, NDT_Root *DS_Ptr, DRT_Kit_Id Kit_Id)
{ {
DRT_Status status;
NDT_Status nd_status; NDT_Status nd_status;
DRT_Kit kit_template;
if( ( nd_status = ND_DataStruct_Traverse( Kit_Ptr->Instrument_DS_Ptr, NDD_CMD_SAMPLE_LOAD, Kit_Ptr, SampleRate)) != NDS_OK) kit_template.Id = Kit_Id;
kit_template.Name[0] = '\0';
if( ( nd_status = ND_DataStruct_Value_Find( (void **)Kit_Ptr_Ptr, DS_Ptr, &kit_template)) != NDS_OK)
{ {
printf( "Cant't load kit samples: ND_DataStruct_Traverse() failed (%d) !\n", nd_status); fprintf( stderr, "DR_Kit_Id_Find: Find error: (%d)!\n", nd_status);
return( DRS_KO); status = DRS_KO;
}
else
{
if( *Kit_Ptr_Ptr == NULL)
{
fprintf( stderr, "Can't find: Kit with id: (%ld)!\n", Kit_Id);
status = DRS_KO;
}
else
{
status = DRS_OK;
}
} }
return( DRS_OK); return( status);
}
/*---------------------------------------------------------------------------------*/
/* DR_Kit_Name_Find */
/*---------------------------------------------------------------------------------*/
extern DRT_Status DR_Kit_Name_Find( DRT_Kit **Kit_Ptr_Ptr, NDT_Root *DS_Ptr, char *Kit_Name)
{
DRT_Status status;
NDT_Status nd_status;
DRT_Kit kit_template;
kit_template.Id = 1;
strncpy( kit_template.Name, Kit_Name, NAME_LEN);
if( ( nd_status = ND_DataStruct_Value_Find( (void **)Kit_Ptr_Ptr, DS_Ptr, &kit_template)) != NDS_OK)
{
fprintf( stderr, "DR_Kit_Name_Find: Find error: (%d)!\n", nd_status);
status = DRS_KO;
}
else
{
if( *Kit_Ptr_Ptr == NULL)
{
fprintf( stderr, "Can't find: Kit with name: [%s]!\n", Kit_Name);
status = DRS_KO;
}
else
{
status = DRS_OK;
}
}
return( status);
} }
@ -1395,7 +1555,7 @@ DRT_Status DR_Kit_Dump( DRT_Kit *Kit_Ptr, long Count)
fprintf( stderr, " %03d) DrumKit:", Count); fprintf( stderr, " %03ld) DrumKit:", Count);
fprintf( stderr, " Id: (% 3d) Name: [%s] Descrition: [%.32s] Dir Name: [%s]\n", Kit_Ptr->Id, Kit_Ptr->Name, Kit_Ptr->Desc, Kit_Ptr->DirName); fprintf( stderr, " Id: (% 3d) Name: [%s] Descrition: [%.32s] Dir Name: [%s]\n", Kit_Ptr->Id, Kit_Ptr->Name, Kit_Ptr->Desc, Kit_Ptr->DirName);
fprintf( stderr, " Instruments List:\n"); fprintf( stderr, " Instruments List:\n");
@ -1436,7 +1596,7 @@ DRT_Status DR_XML_Node_Exist( xmlDocPtr Xml_Doc, xmlXPathContextPtr Xml_Xpath
long tmpval_len; long tmpval_len;
if( ( xml_xpathobj = xmlXPathEvalExpression( Xpath_Request, Xml_XpathCtx)) == NULL) if( ( xml_xpathobj = xmlXPathEvalExpression( (xmlChar *)Xpath_Request, Xml_XpathCtx)) == NULL)
{ {
fprintf( stderr, "DR_XML_Node_Exist: xmlXPathEvalExpression failed [%s]!\n", Xpath_Request); fprintf( stderr, "DR_XML_Node_Exist: xmlXPathEvalExpression failed [%s]!\n", Xpath_Request);
status = DRS_KO; status = DRS_KO;
@ -1483,7 +1643,7 @@ DRT_Status DR_XML_Value_Get( char *Value_Ptr, long Max_Len, xmlDocPtr Xml_Do
strcpy( xpath_request, Xpath_HeadRequest); strcpy( xpath_request, Xpath_HeadRequest);
strcat( xpath_request, Xpath_TailRequest); strcat( xpath_request, Xpath_TailRequest);
if( ( xml_xpathobj = xmlXPathEvalExpression( xpath_request, Xml_XpathCtx)) == NULL) if( ( xml_xpathobj = xmlXPathEvalExpression( (xmlChar *)xpath_request, Xml_XpathCtx)) == NULL)
{ {
fprintf( stderr, "DR_XML_Value_Get: xmlXPathEvalExpression failed! [%s]\n", xpath_request); fprintf( stderr, "DR_XML_Value_Get: xmlXPathEvalExpression failed! [%s]\n", xpath_request);
status = DRS_KO; status = DRS_KO;
@ -1499,7 +1659,7 @@ DRT_Status DR_XML_Value_Get( char *Value_Ptr, long Max_Len, xmlDocPtr Xml_Do
} }
else else
{ {
if( ( tmpval_ptr = xmlNodeListGetString( Xml_Doc, nodeset->nodeTab[0]->xmlChildrenNode, 1)) == NULL) if( ( tmpval_ptr = (char *)xmlNodeListGetString( Xml_Doc, nodeset->nodeTab[0]->xmlChildrenNode, 1)) == NULL)
{ {
fprintf( stderr, "[%s] value not found!\n", xpath_request); fprintf( stderr, "[%s] value not found!\n", xpath_request);
status = DRS_KO; status = DRS_KO;
@ -1510,7 +1670,7 @@ DRT_Status DR_XML_Value_Get( char *Value_Ptr, long Max_Len, xmlDocPtr Xml_Do
if( ( tmpval_len = strlen( tmpval_ptr)) > Max_Len) if( ( tmpval_len = strlen( tmpval_ptr)) > Max_Len)
{ {
fprintf( stderr, "Value too long (%d)>(%d)!\n", tmpval_len, Max_Len); fprintf( stderr, "Value too long (%ld)>(%ld)!\n", tmpval_len, Max_Len);
status = DRS_OK; status = DRS_OK;
} }
else else
@ -1637,6 +1797,7 @@ DRT_Status DR_Kit_Load( DRT_Base *Base_Ptr, char *FileName)
layer_template.Sample_Ptr = NULL; layer_template.Sample_Ptr = NULL;
layer_template.Sample_Size = 0; layer_template.Sample_Size = 0;
layer_template.SF_Info_Ptr = NULL;
fprintf( stderr, "Loading: [%s]...\n", FileName); fprintf( stderr, "Loading: [%s]...\n", FileName);
@ -1665,7 +1826,7 @@ DRT_Status DR_Kit_Load( DRT_Base *Base_Ptr, char *FileName)
} }
else else
{ {
if( xmlXPathRegisterNs( xml_xpathCtx, "drumkit", "http://www.hydrogen-music.org/drumkit") != 0) if( xmlXPathRegisterNs( xml_xpathCtx, (xmlChar *)"drumkit", (xmlChar *)"http://www.hydrogen-music.org/drumkit") != 0)
{ {
fprintf( stderr,"Error: unable to register default NS!\n"); fprintf( stderr,"Error: unable to register default NS!\n");
status = DRS_KO; status = DRS_KO;
@ -1757,6 +1918,152 @@ DRT_Status DR_Kit_Load( DRT_Base *Base_Ptr, char *FileName)
/*---------------------------------------------------------------------------------*/
/* DR_Kit_Sample_Load */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_Kit_Sample_Load( DRT_Kit *Kit_Ptr, double SampleRate)
{
NDT_Status nd_status;
if( ( nd_status = ND_DataStruct_Traverse( Kit_Ptr->Instrument_DS_Ptr, NDD_CMD_SAMPLE_LOAD, Kit_Ptr, SampleRate)) != NDS_OK)
{
printf( "Cant't load kit samples: ND_DataStruct_Traverse() failed (%d) !\n", nd_status);
return( DRS_KO);
}
return( DRS_OK);
}
/*---------------------------------------------------------------------------------*/
/* DR_Kit_Sample_UnLoad */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_Kit_Sample_UnLoad( DRT_Kit *Kit_Ptr)
{
NDT_Status nd_status;
if( ( nd_status = ND_DataStruct_Traverse( Kit_Ptr->Instrument_DS_Ptr, NDD_CMD_SAMPLE_UNLOAD, Kit_Ptr)) != NDS_OK)
{
printf( "Cant't unload kit samples: ND_DataStruct_Traverse() failed (%d) !\n", nd_status);
return( DRS_KO);
}
return( DRS_OK);
}
/*---------------------------------------------------------------------------------*/
/* DR_DataStruct_Init */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_DataStruct_Init( DRT_Base *Base_Ptr, double SampleRate)
{
NDT_Status nd_status;
if( ( nd_status = ND_Library_Open( NDD_TRUE)) != NDS_OK)
{
fprintf( stderr, "Can't open node library (%d) !", nd_status);
return( DRS_KO);
}
if( ( nd_status = ND_DataStruct_Open( &(Base_Ptr->Kit_DS_Ptr), DRD_KIT_DS_INDEX_NB, DRG_Kit_DS_Index_Tab_Initial, "Kit_Manager", DR_Kit_Manager, NULL, NULL, NULL, NULL, NDD_TRUE, NULL)) != NDS_OK)
{
printf( "Kit_DS: ND_DataStruct_Open() failed (%d) !\n", nd_status);
return( DRS_KO);
}
Base_Ptr->SampleRate = SampleRate;
return( DRS_OK);
}
/*---------------------------------------------------------------------------------*/
/* DR_DataStruct_DeInit */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_DataStruct_DeInit( DRT_Base *Base_Ptr)
{
NDT_Status nd_status;
if( ( nd_status = ND_DataStruct_Close( Base_Ptr->Kit_DS_Ptr)) != NDS_OK)
{
printf( "Can't close Kit_DS (%d)!\n", nd_status);
return( DRS_KO);
}
if( ( nd_status = ND_Library_Close()) != NDS_OK)
{
fprintf( stderr, "Can't close node library (%d)!", nd_status);
return( DRS_KO);
}
return( DRS_OK);
}
/*---------------------------------------------------------------------------------*/
/* DR_Kits_Sample_Load */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_Kits_Sample_Load( DRT_Base *Base_Ptr)
{
NDT_Status nd_status;
if( ( nd_status = ND_DataStruct_Traverse( Base_Ptr->Kit_DS_Ptr, NDD_CMD_SAMPLE_LOAD, Base_Ptr->SampleRate)) != NDS_OK)
{
printf( "Cant't load kit samples: ND_DataStruct_Traverse() failed (%d) !\n", nd_status);
return( DRS_KO);
}
return( DRS_OK);
}
/*---------------------------------------------------------------------------------*/
/* DR_Kits_Sample_UnLoad */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_Kits_Sample_UnLoad( DRT_Base *Base_Ptr)
{
NDT_Status nd_status;
if( ( nd_status = ND_DataStruct_Traverse( Base_Ptr->Kit_DS_Ptr, NDD_CMD_SAMPLE_UNLOAD, Base_Ptr->SampleRate)) != NDS_OK)
{
printf( "Cant't unload kit samples: ND_DataStruct_Traverse() failed (%d) !\n", nd_status);
return( DRS_KO);
}
return( DRS_OK);
}
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
/* DR_Kits_Load */ /* DR_Kits_Load */
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
@ -1765,9 +2072,10 @@ DRT_Status DR_Kits_Load( DRT_Base *Base_Ptr)
{ {
DRT_Status status; DRT_Status status;
NDT_Status nd_status; NDT_Status nd_status;
char glob_pattern[] = "~/.hydrogen/data/drumkits/*/drumkit.xml"; // char glob_pattern[] = "~/.hydrogen/data/drumkits/*/drumkit.xml";
// char glob_pattern[] = "~/.hydrogen/data/drumkits/AVL-BlackPearl-4A-1.1/drumkit.xml"; // char glob_pattern[] = "~/.hydrogen/data/drumkits/AVL-BlackPearl-4A-1.1/drumkit.xml";
// char glob_pattern[] = "~/.hydrogen/data/drumkits/Mars Lindrum: 02-Kit 2/drumkit.xml"; // char glob_pattern[] = "~/.hydrogen/data/drumkits/Mars Lindrum: 02-Kit 2/drumkit.xml";
char glob_pattern[] = "~/.hydrogen/data/drumkits/Mars Mod */drumkit.xml";
glob_t glob_struct; glob_t glob_struct;
int i; int i;
@ -1804,7 +2112,7 @@ DRT_Status DR_Kits_Load( DRT_Base *Base_Ptr)
globfree( &glob_struct); globfree( &glob_struct);
Base_Ptr->SampleRate=44100; // Base_Ptr->SampleRate=44100;
/* /*
status = DR_Layer_Sample_Load( (DRT_Layer *)( status = DR_Layer_Sample_Load( (DRT_Layer *)(
@ -1815,15 +2123,14 @@ DRT_Status DR_Kits_Load( DRT_Base *Base_Ptr)
(DRT_Kit *)(Base_Ptr->Kit_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Head->Value), Base_Ptr->SampleRate); (DRT_Kit *)(Base_Ptr->Kit_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Head->Value), Base_Ptr->SampleRate);
*/ */
/* /*
status = DR_Kit_Sample_Load( (DRT_Kit *)(Base_Ptr->Kit_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Head->Value), if( Base_Ptr->Kit_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Head != NULL)
Base_Ptr->SampleRate); {
status = DR_Kit_Sample_Load( (DRT_Kit *)(Base_Ptr->Kit_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Head->Value),
Base_Ptr->SampleRate);
}
*/ */
if( ( nd_status = ND_DataStruct_Traverse( Base_Ptr->Kit_DS_Ptr, NDD_CMD_SAMPLE_LOAD, Base_Ptr->SampleRate)) != NDS_OK) status = DR_Kits_Sample_Load( Base_Ptr);
{
printf( "Cant't load kit samples: ND_DataStruct_Traverse() failed (%d) !\n", nd_status);
return( DRS_KO);
}
return( status); return( status);
} }
@ -1848,6 +2155,7 @@ DRT_Status DR_Kits_Dump( DRT_Base *Base_Ptr)
fprintf( stderr, "\n"); fprintf( stderr, "\n");
fprintf( stderr, "Sample Rate: (%lf)\n", Base_Ptr->SampleRate);
fprintf( stderr, "DrumKit List:\n"); fprintf( stderr, "DrumKit List:\n");
/* /*
if( ( nd_status = ND_DataStruct_Info_Print( stderr, Base_Ptr->Kit_DS_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0)) != NDS_OK) if( ( nd_status = ND_DataStruct_Info_Print( stderr, Base_Ptr->Kit_DS_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0)) != NDS_OK)
@ -1894,59 +2202,3 @@ DRT_Status DR_Kits_Dump( DRT_Base *Base_Ptr)
return( DRS_OK); return( DRS_OK);
} }
/*---------------------------------------------------------------------------------*/
/* DR_DataStruct_Init */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_DataStruct_Init( DRT_Base *Base_Ptr)
{
NDT_Status nd_status;
if( ( nd_status = ND_Library_Open( NDD_TRUE)) != NDS_OK)
{
fprintf( stderr, "Can't open node library (%d) !", nd_status);
return( DRS_KO);
}
if( ( nd_status = ND_DataStruct_Open( &(Base_Ptr->Kit_DS_Ptr), DRD_KIT_DS_INDEX_NB, DRG_Kit_DS_Index_Tab_Initial, "Kit_Manager", DR_Kit_Manager, NULL, NULL, NULL, NULL, NDD_TRUE, NULL)) != NDS_OK)
{
printf( "Kit_DS: ND_DataStruct_Open() failed (%d) !\n", nd_status);
return( DRS_KO);
}
return( DRS_OK);
}
/*---------------------------------------------------------------------------------*/
/* DR_DataStruct_DeInit */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_DataStruct_DeInit( DRT_Base *Base_Ptr)
{
NDT_Status nd_status;
if( ( nd_status = ND_DataStruct_Close( Base_Ptr->Kit_DS_Ptr)) != NDS_OK)
{
printf( "Can't close Kit_DS (%d)!\n", nd_status);
return( DRS_KO);
}
if( ( nd_status = ND_Library_Close()) != NDS_OK)
{
fprintf( stderr, "Can't close node library (%d)!", nd_status);
return( DRS_KO);
}
return( DRS_OK);
}

View File

@ -45,6 +45,10 @@ typedef short DRT_Boolean;
#define DESC_LEN (short) 4096 #define DESC_LEN (short) 4096
#define DESC_SIZE (DESC_LEN + 1) #define DESC_SIZE (DESC_LEN + 1)
typedef long DRT_Layer_Id;
typedef long DRT_Instrument_Id;
typedef long DRT_Kit_Id;
@ -55,38 +59,38 @@ typedef short DRT_Boolean;
typedef struct DRT_Layer typedef struct DRT_Layer
{ {
short Id; DRT_Layer_Id Id;
char FileName[ FILENAME_SIZE]; char FileName[ FILENAME_SIZE];
float *Sample_Ptr; float *Sample_Ptr;
long Sample_Size; long Sample_Size;
SF_INFO *SF_Info_Ptr; SF_INFO *SF_Info_Ptr;
double Min; double Min;
double Max; double Max;
double Gain; double Gain;
double Pitch; double Pitch;
} DRT_Layer; } DRT_Layer;
typedef struct DRT_Instrument typedef struct DRT_Instrument
{ {
short Id; DRT_Instrument_Id Id;
char Name[ NAME_SIZE]; char Name[ NAME_SIZE];
double Gain; double Gain;
double Pan_Left; double Pan_Left;
double Pan_Right; double Pan_Right;
NDT_Root *Layer_DS_Ptr; NDT_Root *Layer_DS_Ptr;
} DRT_Instrument; } DRT_Instrument;
typedef struct DRT_Kit typedef struct DRT_Kit
{ {
short Id; DRT_Kit_Id Id;
char Name[ NAME_SIZE]; char Name[ NAME_SIZE];
char Desc[ DESC_SIZE]; char Desc[ DESC_SIZE];
char DirName[ DIRNAME_SIZE]; char DirName[ DIRNAME_SIZE];
NDT_Root *Instrument_DS_Ptr; NDT_Root *Instrument_DS_Ptr;
} DRT_Kit; } DRT_Kit;
@ -283,11 +287,35 @@ DRT_XML_Query DRG_XML_Query_Tab_Kit[] =
/* Public Prototypes */ /* Public Prototypes */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* DR_Layer_Dump */
/*----------------------------------------------------------------------------*/
extern DRT_Status DR_Layer_Dump( DRT_Layer *, long);
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
/* DR_Kit_Sample_Load */ /* DR_Kit_Id_Find */
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
extern DRT_Status DR_Kit_Sample_Load( DRT_Kit *, double); extern DRT_Status DR_Kit_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);
@ -299,8 +327,56 @@ extern DRT_Status DR_Kit_Load( DRT_Base *, char *);
/*---------------------------------------------------------------------------------*/
/* DR_Kit_Sample_Load */
/*---------------------------------------------------------------------------------*/
extern DRT_Status DR_Kit_Sample_Load( DRT_Kit *, double);
/*---------------------------------------------------------------------------------*/
/* DR_Kit_Sample_UnLoad */
/*---------------------------------------------------------------------------------*/
extern DRT_Status DR_Kit_Sample_UnLoad( DRT_Kit *);
/*---------------------------------------------------------------------------------*/
/* DR_DataStruct_Init */
/*---------------------------------------------------------------------------------*/
extern DRT_Status DR_DataStruct_Init( DRT_Base *, double);
/*---------------------------------------------------------------------------------*/
/* DR_DataStruct_DeInit */
/*---------------------------------------------------------------------------------*/
extern DRT_Status DR_DataStruct_DeInit( DRT_Base *);
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* DR_Kits_Load */ /* 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 *); extern DRT_Status DR_Kits_Load( DRT_Base *);
@ -315,22 +391,6 @@ extern DRT_Status DR_Kits_Dump( DRT_Base *);
/*---------------------------------------------------------------------------------*/
/* DR_DataStruct_Init */
/*---------------------------------------------------------------------------------*/
extern DRT_Status DR_DataStruct_Init( DRT_Base *);
/*---------------------------------------------------------------------------------*/
/* DR_DataStruct_DeInit */
/*---------------------------------------------------------------------------------*/
extern DRT_Status DR_DataStruct_DeInit( DRT_Base *);
# else // ifndef _DATA_STRUCT_C_ # else // ifndef _DATA_STRUCT_C_
@ -406,10 +466,18 @@ DRT_Status DR_Kit_Add( DRT_Kit **, NDT_Root *, DRT_Kit *);
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
/* DR_Kit_Sample_Load */ /* DR_Kit_Id_Find */
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
DRT_Status DR_Kit_Sample_Load( DRT_Kit *, double); DRT_Status DR_Kit_Id_Find( DRT_Kit **, NDT_Root *, DRT_Kit_Id);
/*---------------------------------------------------------------------------------*/
/* DR_Kit_Name_Find */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_Kit_Name_Find( DRT_Kit **, NDT_Root *, char *);
@ -453,8 +521,56 @@ DRT_Status DR_Kit_Load( DRT_Base *, char *);
/*---------------------------------------------------------------------------------*/
/* DR_Kit_Sample_Load */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_Kit_Sample_Load( DRT_Kit *, double);
/*---------------------------------------------------------------------------------*/
/* DR_Kit_Sample_UnLoad */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_Kit_Sample_UnLoad( DRT_Kit *);
/*---------------------------------------------------------------------------------*/
/* DR_DataStruct_Init */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_DataStruct_Init( DRT_Base *, double);
/*---------------------------------------------------------------------------------*/
/* DR_DataStruct_DeInit */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_DataStruct_DeInit( DRT_Base *);
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* DR_Kits_Load */ /* DR_Kits_Sample_Load */
/*----------------------------------------------------------------------------*/
DRT_Status DR_Kits_Sample_Load( DRT_Base *);
/*----------------------------------------------------------------------------*/
/* DR_Kits_Sample_UnLoad */
/*----------------------------------------------------------------------------*/
DRT_Status DR_Kits_Sample_UnLoad( DRT_Base *);
/*----------------------------------------------------------------------------*/
/* DR_Kits_Load */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
DRT_Status DR_Kits_Load( DRT_Base *); DRT_Status DR_Kits_Load( DRT_Base *);
@ -469,20 +585,6 @@ DRT_Status DR_Kits_Dump( DRT_Base *);
/*---------------------------------------------------------------------------------*/
/* DR_DataStruct_Init */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_DataStruct_Init( DRT_Base *);
/*---------------------------------------------------------------------------------*/
/* DR_DataStruct_DeInit */
/*---------------------------------------------------------------------------------*/
DRT_Status DR_DataStruct_DeInit( DRT_Base *);
# endif // ifndef _DATASTRUCT_C_ # endif // ifndef _DATASTRUCT_C_

1906
drummer.c

File diff suppressed because it is too large Load Diff

371
drummer.h
View File

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

31
go.sh
View File

@ -1,6 +1,31 @@
gcc -g -c -I . -o libnode.o libnode.c #!/bin/bash
module_list="libnode.c datastruct.c"
main_list="drummer.c lv2_plugin.c"
for module in ${module_list} ${main_list}
do
cmd="gcc -g -c -I. -I/usr/include/libxml2 -o ${module//.c/.o} -fPIC ${module}"
echo ${cmd}
eval ${cmd}
done
cmd="gcc -g -o drummer ${module_list//.c/.o} drummer.o -fPIC -ldl -lxml2 -lz -llzma -lm -lsndfile -lsamplerate"
echo ${cmd}
eval ${cmd}
cmd="gcc -g -o drummer.so ${module_list//.c/.o} lv2_plugin.o -shared -fPIC -ldl -lxml2 -lz -llzma -lm -lsndfile -lsamplerate"
echo ${cmd}
eval ${cmd}
cmd="./drummer-mkttl"
#echo ${cmd}
#eval ${cmd}
#gcc -g -I . -L . -shared -o drummer.so -fPIC drummer.c #gcc -g -I . -L . -shared -o drummer.so -fPIC drummer.c
gcc -g -I. -I/usr/include/libxml2 -o drummer -fPIC libnode.o -ldl -lxml2 -lz -llzma -lm -lsndfile -lsamplerate drummer.c
#gcc -g -I. -I/usr/include/libxml2 -o xpath -fPIC -ldl -lxml2 -lz -llzma -lm xpath.c #gcc -g -I. -I/usr/include/libxml2 -o xpath -fPIC -ldl -lxml2 -lz -llzma -lm xpath.c

View File

@ -2281,7 +2281,7 @@ NDT_Status ND_Index_Info_Print_I( FILE *Out, NDT_Root *Root_Ptr, NDT_Index_Id
memset( offset, ' ', Recursive_Offset * ND_RECURSIVE_PRINT_OFFSET); memset( offset, ' ', Recursive_Offset * ND_RECURSIVE_PRINT_OFFSET);
offset[Recursive_Offset * ND_RECURSIVE_PRINT_OFFSET] = '\0'; offset[Recursive_Offset * ND_RECURSIVE_PRINT_OFFSET] = '\0';
fprintf( Out, "%s Index Id: (%d)\tType: (%#06x) [%s:%s:%s]\tNode Nb: (%d)\tHead: (%s%p)\tTail: (%s%p)\n%s Min Depth: (%d)\tMax Depth: (%d)\tMax Dif: (%d)\tNb Equ: (%d)\tSave: (%s%p)\n\n", fprintf( Out, "%s Index Id: (%d)\tType: (%#06x) [%s:%s:%s]\tNode Nb: (%ld)\tHead: (%s%p)\tTail: (%s%p)\n%s Min Depth: (%ld)\tMax Depth: (%ld)\tMax Dif: (%ld)\tNb Equ: (%ld)\tSave: (%s%p)\n\n",
offset, Index_Id, Root_Ptr->Index_Tab[Index_Id].Type, ND_INDEX_STATUS_ASCII_GET( Root_Ptr, Index_Id), ND_INDEX_TYPE_ASCII_GET( Root_Ptr, Index_Id), ND_INDEX_SUBTYPE_ASCII_GET( Root_Ptr, Index_Id), offset, Index_Id, Root_Ptr->Index_Tab[Index_Id].Type, ND_INDEX_STATUS_ASCII_GET( Root_Ptr, Index_Id), ND_INDEX_TYPE_ASCII_GET( Root_Ptr, Index_Id), ND_INDEX_SUBTYPE_ASCII_GET( Root_Ptr, Index_Id),
Root_Ptr->Index_Tab[Index_Id].Node_Number, Root_Ptr->Index_Tab[Index_Id].Node_Number,
NDD_PRINTF_PTR_PREFIX, Root_Ptr->Index_Tab[Index_Id].Head, NDD_PRINTF_PTR_PREFIX, Root_Ptr->Index_Tab[Index_Id].Tail, NDD_PRINTF_PTR_PREFIX, Root_Ptr->Index_Tab[Index_Id].Head, NDD_PRINTF_PTR_PREFIX, Root_Ptr->Index_Tab[Index_Id].Tail,
@ -2565,7 +2565,7 @@ NDT_Status ND_DataStruct_Value_Add_C( NDT_Root *Root_Ptr, void *Value_Ptr)
if( !Value_Ptr) if( !Value_Ptr)
{ {
sprintf( NDG_Base.Err_String, "Error ND_DatatStruct_Value_Add_C: the value to add is null"); sprintf( NDG_Base.Err_String, "Error ND_DataStruct_Value_Add_C: the value to add is null");
ND_Error_Print(); ND_Error_Print();
return( NDS_ERRAPI); return( NDS_ERRAPI);

File diff suppressed because it is too large Load Diff

View File

@ -26,9 +26,23 @@
// lv2 stuff // lv2 stuff
#define DRD_DRUMMER_URI "http://rx3.net/AlkorZ3/drummer" #define DRD_DRUMMER_URI "http://rx3.net/AlkorZ3/drummer"
#define DRD_GAIN_MIN -60.0f #define DRD_GAIN_MIN -60.0f
#define DRD_GAIN_MAX 6.0f #define DRD_GAIN_MAX 6.0f
#define DRD_VELOCITY_MIN 0
#define DRD_VELOCITY_MAX 127
#define DRD_DB3SCALE -0.8317830986718104f
#define DRD_DB3SCALEPO 1.8317830986718104f
// taken from lv2 example amp plugin
#define DRD_DB_CO(g) ( ( g) > DRD_GAIN_MIN ? powf( 10.0f, ( g) * 0.05f) : 0.0f)
#define DRD_PORT_NUMBER_MAX 32
#define DRD_REQ_BUF_SIZE 10
@ -102,70 +116,70 @@ typedef enum
DRD_LV2_LEFT_31, DRD_LV2_LEFT_31,
DRD_LV2_RIGHT_31, DRD_LV2_RIGHT_31,
DRD_LV2_BASENOTE, DRD_LV2_BASENOTE,
DRD_LV2_GAIN_ONE, DRD_LV2_GAIN_00,
DRD_LV2_GAIN_TWO, DRD_LV2_GAIN_01,
DRD_LV2_GAIN_THREE, DRD_LV2_GAIN_02,
DRD_LV2_GAIN_FOUR, DRD_LV2_GAIN_03,
DRD_LV2_GAIN_FIVE, DRD_LV2_GAIN_04,
DRD_LV2_GAIN_SIX, DRD_LV2_GAIN_05,
DRD_LV2_GAIN_SEVEN, DRD_LV2_GAIN_06,
DRD_LV2_GAIN_EIGHT, DRD_LV2_GAIN_07,
DRD_LV2_GAIN_NINE, DRD_LV2_GAIN_08,
DRD_LV2_GAIN_TEN, DRD_LV2_GAIN_09,
DRD_LV2_GAIN_ELEVEN, DRD_LV2_GAIN_10,
DRD_LV2_GAIN_TWELVE, DRD_LV2_GAIN_11,
DRD_LV2_GAIN_THIRTEEN, DRD_LV2_GAIN_12,
DRD_LV2_GAIN_FOURTEEN, DRD_LV2_GAIN_13,
DRD_LV2_GAIN_FIFTEEN, DRD_LV2_GAIN_14,
DRD_LV2_GAIN_SIXTEEN, DRD_LV2_GAIN_15,
DRD_LV2_GAIN_SEVENTEEN, DRD_LV2_GAIN_16,
DRD_LV2_GAIN_EIGHTEEN, DRD_LV2_GAIN_17,
DRD_LV2_GAIN_NINETEEN, DRD_LV2_GAIN_18,
DRD_LV2_GAIN_TWENTY, DRD_LV2_GAIN_19,
DRD_LV2_GAIN_TWENTYONE, DRD_LV2_GAIN_20,
DRD_LV2_GAIN_TWENTYTWO, DRD_LV2_GAIN_21,
DRD_LV2_GAIN_TWENTYTHREE, DRD_LV2_GAIN_22,
DRD_LV2_GAIN_TWENTYFOUR, DRD_LV2_GAIN_23,
DRD_LV2_GAIN_TWENTYFIVE, DRD_LV2_GAIN_24,
DRD_LV2_GAIN_TWENTYSIX, DRD_LV2_GAIN_25,
DRD_LV2_GAIN_TWENTYSEVEN, DRD_LV2_GAIN_26,
DRD_LV2_GAIN_TWENTYEIGHT, DRD_LV2_GAIN_27,
DRD_LV2_GAIN_TWENTYNINE, DRD_LV2_GAIN_28,
DRD_LV2_GAIN_THIRTY, DRD_LV2_GAIN_29,
DRD_LV2_GAIN_THIRTYONE, DRD_LV2_GAIN_30,
DRD_LV2_GAIN_THIRTYTWO, DRD_LV2_GAIN_31,
DRD_LV2_PAN_ONE, DRD_LV2_PAN_00,
DRD_LV2_PAN_TWO, DRD_LV2_PAN_01,
DRD_LV2_PAN_THREE, DRD_LV2_PAN_02,
DRD_LV2_PAN_FOUR, DRD_LV2_PAN_03,
DRD_LV2_PAN_FIVE, DRD_LV2_PAN_04,
DRD_LV2_PAN_SIX, DRD_LV2_PAN_05,
DRD_LV2_PAN_SEVEN, DRD_LV2_PAN_06,
DRD_LV2_PAN_EIGHT, DRD_LV2_PAN_07,
DRD_LV2_PAN_NINE, DRD_LV2_PAN_08,
DRD_LV2_PAN_TEN, DRD_LV2_PAN_09,
DRD_LV2_PAN_ELEVEN, DRD_LV2_PAN_10,
DRD_LV2_PAN_TWELVE, DRD_LV2_PAN_11,
DRD_LV2_PAN_THIRTEEN, DRD_LV2_PAN_12,
DRD_LV2_PAN_FOURTEEN, DRD_LV2_PAN_13,
DRD_LV2_PAN_FIFTEEN, DRD_LV2_PAN_14,
DRD_LV2_PAN_SIXTEEN, DRD_LV2_PAN_15,
DRD_LV2_PAN_SEVENTEEN, DRD_LV2_PAN_16,
DRD_LV2_PAN_EIGHTEEN, DRD_LV2_PAN_17,
DRD_LV2_PAN_NINETEEN, DRD_LV2_PAN_18,
DRD_LV2_PAN_TWENTY, DRD_LV2_PAN_19,
DRD_LV2_PAN_TWENTYONE, DRD_LV2_PAN_20,
DRD_LV2_PAN_TWENTYTWO, DRD_LV2_PAN_21,
DRD_LV2_PAN_TWENTYTHREE, DRD_LV2_PAN_22,
DRD_LV2_PAN_TWENTYFOUR, DRD_LV2_PAN_23,
DRD_LV2_PAN_TWENTYFIVE, DRD_LV2_PAN_24,
DRD_LV2_PAN_TWENTYSIX, DRD_LV2_PAN_25,
DRD_LV2_PAN_TWENTYSEVEN, DRD_LV2_PAN_26,
DRD_LV2_PAN_TWENTYEIGHT, DRD_LV2_PAN_27,
DRD_LV2_PAN_TWENTYNINE, DRD_LV2_PAN_28,
DRD_LV2_PAN_THIRTY, DRD_LV2_PAN_29,
DRD_LV2_PAN_THIRTYONE, DRD_LV2_PAN_30,
DRD_LV2_PAN_THIRTYTWO, DRD_LV2_PAN_31,
DRD_LV2_CORE_EVENT, DRD_LV2_CORE_EVENT,
DRD_LV2_NUM_PORTS DRD_LV2_NUM_PORTS
} DRT_Port_Index; } DRT_Port_Index;
@ -194,9 +208,38 @@ typedef struct
} DRT_Drummer_URIS; } DRT_Drummer_URIS;
/*
typedef struct typedef struct
{ {
SF_INFO *Info;
char Active;
uint32_t Offset;
uint32_t Limit;
uint32_t Layer_Count;
float Velocity;
// drmr_layer *layers;
float *Data;
int Data_Offset;
} DRT_Sample;
*/
typedef struct
{
DRT_Instrument *Instrument_Ptr;
DRT_Layer *Layer_Ptr;
float *Data_Ptr;
uint32_t Limit;
SF_INFO *SF_Info_Ptr;
int Data_Offset;
char Active;
uint32_t Offset;
float Velocity;
} DRT_Sample;
typedef struct DRT_LV2_Base
{
DRT_Base Base;
// Ports // Ports
float *Master_Left; float *Master_Left;
float *Master_Right; float *Master_Right;
@ -206,10 +249,47 @@ typedef struct
LV2_Atom_Sequence *Core_Event_Port; LV2_Atom_Sequence *Core_Event_Port;
LV2_Atom_Forge Forge; LV2_Atom_Forge Forge;
// params
int Channel;
bool Ignore_Velocity;
bool Ignore_Note_Off;
int Channel_Nb;
int Zero_Position;
float **Gains;
float **Pans;
float *BaseNote;
// URIs
LV2_URID_Map *Map_Ptr;
DRT_Drummer_URIS URIS;
// Kit info
DRT_Kit *Kit_Cur_Ptr;
uint8_t Bank_Id_LSB;
uint8_t Bank_Id_MSB;
uint8_t Program_Id;
uint8_t Bank_Id_LSB_New;
uint8_t Bank_Id_MSB_New;
uint8_t Program_Id_New;
DRT_Kit_Id Kit_Id;
char *Current_Path;
char **Request_Buf;
int CurReq;
// Samples
DRT_Sample Samples[DRD_PORT_NUMBER_MAX];
uint8_t Sample_Number;
// Loading Thread Stuff
pthread_mutex_t Load_Mutex;
pthread_cond_t Load_Cond;
pthread_t Load_Thread;
} DRT_LV2_Base; } DRT_LV2_Base;
/*
typedef struct typedef struct
{ {
// Ports // Ports
@ -251,28 +331,29 @@ typedef struct
pthread_cond_t load_cond; pthread_cond_t load_cond;
pthread_t load_thread; pthread_t load_thread;
} DrMr; } DrMr;
*/
static inline void map_drmr_uris( LV2_URID_Map *map, drmr_uris *uris) static inline void DR_Map_Drummer_URIS( LV2_URID_Map *Map_Ptr, DRT_Drummer_URIS *URIS)
{ {
uris->midi_event = map->map(map->handle, "http://lv2plug.in/ns/ext/midi#MidiEvent"); URIS->midi_event = Map_Ptr->map( Map_Ptr->handle, "http://lv2plug.in/ns/ext/midi#MidiEvent");
uris->string_urid = map->map(map->handle, LV2_ATOM__String); URIS->string_urid = Map_Ptr->map( Map_Ptr->handle, LV2_ATOM__String);
uris->bool_urid = map->map(map->handle, LV2_ATOM__Bool); URIS->bool_urid = Map_Ptr->map( Map_Ptr->handle, LV2_ATOM__Bool);
uris->int_urid = map->map(map->handle, LV2_ATOM__Int); URIS->int_urid = Map_Ptr->map( Map_Ptr->handle, LV2_ATOM__Int);
uris->ui_msg = map->map(map->handle, DRD_LV2_URI "#uimsg"); URIS->ui_msg = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#uimsg");
uris->kit_path = map->map(map->handle, DRD_LV2_URI "#kitpath"); URIS->kit_path = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#kitpath");
uris->get_state = map->map(map->handle, DRD_LV2_URI "#getstate"); URIS->get_state = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#getstate");
uris->midi_info = map->map(map->handle, DRD_LV2_URI "#midiinfo"); URIS->midi_info = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#midiinfo");
uris->sample_trigger = map->map(map->handle, DRD_LV2_URI "#sampletrigger"); URIS->sample_trigger = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#sampletrigger");
uris->velocity_toggle = map->map(map->handle, DRD_LV2_URI "#velocitytoggle"); URIS->velocity_toggle = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#velocitytoggle");
uris->note_off_toggle = map->map(map->handle, DRD_LV2_URI "#noteofftoggle"); URIS->note_off_toggle = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#noteofftoggle");
uris->channel_nb = map->map(map->handle, DRD_LV2_URI "#channelnb"); URIS->channel_nb = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#channelnb");
uris->zero_position = map->map(map->handle, DRD_LV2_URI "#zeroposition"); URIS->zero_position = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#zeroposition");
uris->sample_add = map->map(map->handle, DRD_LV2_URI "#sampleadd"); URIS->sample_add = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#sampleadd");
uris->sample_remove = map->map(map->handle, DRD_LV2_URI "#sampleremove"); URIS->sample_remove = Map_Ptr->map( Map_Ptr->handle, DRD_DRUMMER_URI "#sampleremove");
uris->atom_eventTransfer = map->map(map->handle, LV2_ATOM__eventTransfer); URIS->atom_eventTransfer = Map_Ptr->map( Map_Ptr->handle, LV2_ATOM__eventTransfer);
uris->atom_object = map->map(map->handle, LV2_ATOM__Object); URIS->atom_object = Map_Ptr->map( Map_Ptr->handle, LV2_ATOM__Object);
} }
@ -289,8 +370,6 @@ static inline void map_drmr_uris( LV2_URID_Map *map, drmr_uris *uris)
/* Private Definitions */ /* Private Definitions */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
# endif // ifdef _LV2_PLUGIN_C_ # endif // ifdef _LV2_PLUGIN_C_
@ -313,6 +392,126 @@ static inline void map_drmr_uris( LV2_URID_Map *map, drmr_uris *uris)
/* Private Prototypes */ /* Private Prototypes */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
static void *DR_LV2_Load_Thread( DRT_LV2_Base *);
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
static inline LV2_Atom *DR_LV2_Message_Midi_Info_Build( DRT_LV2_Base *, uint8_t *);
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
DRT_Status DR_LV2_Kit_Samples_Load( DRT_LV2_Base *, DRT_Kit *);
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
DRT_Status DR_LV2_CurKit_Samples_Load( DRT_LV2_Base *);
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
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_Untrigger( DRT_LV2_Base *, int, uint32_t);
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
static LV2_Handle DR_LV2_Instantiate(const LV2_Descriptor *, double, const char *, const LV2_Feature * const *);
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
static void DR_LV2_Connect_Port( LV2_Handle, uint32_t, void *);
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
static void DR_LV2_Run( LV2_Handle, uint32_t);
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
static void DR_LV2_Cleanup( LV2_Handle);
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
static LV2_State_Status DR_LV2_Save_State( LV2_Handle, LV2_State_Store_Function, void *, uint32_t, const LV2_Feature *const *);
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
static LV2_State_Status DR_LV2_Restore_State( LV2_Handle, LV2_State_Retrieve_Function, void *, uint32_t, const LV2_Feature *const *);
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
static const void *DR_LV2_Extension_Data( const char *);
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
LV2_SYMBOL_EXPORT const LV2_Descriptor *lv2_descriptor( uint32_t);
# endif // ifndef _LV2_PLUGIN_C_ # endif // ifndef _LV2_PLUGIN_C_

2
node.h
View File

@ -594,7 +594,7 @@ typedef struct NDT_Index
long Max_Dif; /* Différence maximale autorisée entre la branche la plus courte et la plus longue */ long Max_Dif; /* Différence maximale autorisée entre la branche la plus courte et la plus longue */
long Nb_Equ; /* Nombre de réquilibrages réalisés sur l'arbre */ long Nb_Equ; /* Nombre de réquilibrages réalisés sur l'arbre */
struct NDT_Node *Head; /* Noeud de tête */ struct NDT_Node *Head; /* Noeud de tête */
struct NDT_Node *Tail; /* Noeud de queue */ struct NDT_Node *Tail; /* Noeud de queue */
struct NDT_Node *Save; /* Pointeur de sauvegarde (utile pour la fonction de restauration) */ struct NDT_Node *Save; /* Pointeur de sauvegarde (utile pour la fonction de restauration) */
} NDT_Index; } NDT_Index;