- Add kit load status suport
- Optimize kit sample loading - Normalize some macro and constant naming
This commit is contained in:
parent
103f3b8135
commit
5dfe9feb17
359
datastruct.c
359
datastruct.c
@ -1,6 +1,6 @@
|
|||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* Includes */
|
/* Includes */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#define _DATASTRUCT_C_
|
#define _DATASTRUCT_C_
|
||||||
|
|
||||||
@ -12,9 +12,9 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* */
|
/* */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
NDT_Status DR_Layer_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Command, va_list *Args_Ptr)
|
NDT_Status DR_Layer_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Command, va_list *Args_Ptr)
|
||||||
{
|
{
|
||||||
@ -88,7 +88,7 @@ NDT_Status DR_Layer_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_N
|
|||||||
{
|
{
|
||||||
( *Layer_Ptr_Ptr)->Id = Root_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Node_Number;
|
( *Layer_Ptr_Ptr)->Id = Root_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Node_Number;
|
||||||
|
|
||||||
strncpy( ( *Layer_Ptr_Ptr)->FileName, Layer_Template_Ptr->FileName, FILENAME_SIZE);
|
strncpy( ( *Layer_Ptr_Ptr)->FileName, Layer_Template_Ptr->FileName, DRD_FILENAME_SIZE);
|
||||||
|
|
||||||
( *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;
|
||||||
@ -98,8 +98,6 @@ NDT_Status DR_Layer_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_N
|
|||||||
( *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
|
||||||
@ -149,7 +147,7 @@ NDT_Status DR_Layer_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_N
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
printf( "Unknown COMP idx (%d) !\n", Index_Id);
|
printf( "Unknown COMP idx (%d)!\n", Index_Id);
|
||||||
return( NDS_KO);
|
return( NDS_KO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -310,7 +308,7 @@ NDT_Status DR_Layer_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_N
|
|||||||
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
|
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
|
||||||
|
|
||||||
ND_VA_ARG_GET( Kit_Ptr, user_args, DRT_Kit *);
|
ND_VA_ARG_GET( Kit_Ptr, user_args, DRT_Kit *);
|
||||||
ND_VA_ARG_GET( SampleRate, user_args, double);
|
ND_VA_ARG_GET( SampleRate, user_args, DRT_SampleRate);
|
||||||
|
|
||||||
ND_VA_LIST_CLOSE( user_args);
|
ND_VA_LIST_CLOSE( user_args);
|
||||||
|
|
||||||
@ -321,7 +319,7 @@ NDT_Status DR_Layer_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_N
|
|||||||
|
|
||||||
if( DR_Layer_Sample_Load( Layer_Ptr, Kit_Ptr, SampleRate) != DRS_OK)
|
if( DR_Layer_Sample_Load( Layer_Ptr, Kit_Ptr, SampleRate) != DRS_OK)
|
||||||
{
|
{
|
||||||
return( NDS_OK);
|
return( NDS_OK); // Continue even if sample loading fail...
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -346,7 +344,7 @@ NDT_Status DR_Layer_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_N
|
|||||||
|
|
||||||
if( DR_Layer_Sample_UnLoad( Layer_Ptr) != DRS_OK)
|
if( DR_Layer_Sample_UnLoad( Layer_Ptr) != DRS_OK)
|
||||||
{
|
{
|
||||||
return( NDS_OK);
|
return( NDS_OK); // Continue even if sample unloading fail...
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -370,9 +368,9 @@ NDT_Status DR_Layer_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_N
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* */
|
/* */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
NDT_Status DR_Instrument_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Command, va_list *Args_Ptr)
|
NDT_Status DR_Instrument_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Command, va_list *Args_Ptr)
|
||||||
{
|
{
|
||||||
@ -448,7 +446,7 @@ NDT_Status DR_Instrument_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id,
|
|||||||
{
|
{
|
||||||
( *Instrument_Ptr_Ptr)->Id = Root_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Node_Number;
|
( *Instrument_Ptr_Ptr)->Id = Root_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Node_Number;
|
||||||
|
|
||||||
strncpy( ( *Instrument_Ptr_Ptr)->Name, Instrument_Template_Ptr->Name, NAME_SIZE);
|
strncpy( ( *Instrument_Ptr_Ptr)->Name, Instrument_Template_Ptr->Name, DRD_NAME_SIZE);
|
||||||
|
|
||||||
( *Instrument_Ptr_Ptr)->Gain = Instrument_Template_Ptr->Gain;
|
( *Instrument_Ptr_Ptr)->Gain = Instrument_Template_Ptr->Gain;
|
||||||
( *Instrument_Ptr_Ptr)->Pan_Left = Instrument_Template_Ptr->Pan_Left;
|
( *Instrument_Ptr_Ptr)->Pan_Left = Instrument_Template_Ptr->Pan_Left;
|
||||||
@ -457,7 +455,7 @@ NDT_Status DR_Instrument_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id,
|
|||||||
|
|
||||||
if( ( nd_status = ND_DataStruct_Open( &((*Instrument_Ptr_Ptr)->Layer_DS_Ptr), DRD_LAYER_DS_INDEX_NB, DRG_Layer_DS_Index_Tab_Initial, "Layer_Manager", DR_Layer_Manager, NULL, NULL, NULL, NULL, NDD_TRUE, NULL)) != NDS_OK)
|
if( ( nd_status = ND_DataStruct_Open( &((*Instrument_Ptr_Ptr)->Layer_DS_Ptr), DRD_LAYER_DS_INDEX_NB, DRG_Layer_DS_Index_Tab_Initial, "Layer_Manager", DR_Layer_Manager, NULL, NULL, NULL, NULL, NDD_TRUE, NULL)) != NDS_OK)
|
||||||
{
|
{
|
||||||
printf( "DR_Instrument_Manager: ND_DataStruct_Open() failed (%d) !\n", nd_status);
|
printf( "DR_Instrument_Manager: ND_DataStruct_Open() failed (%d)!\n", nd_status);
|
||||||
return( NDS_KO);
|
return( NDS_KO);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -517,7 +515,7 @@ NDT_Status DR_Instrument_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id,
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
printf( "Unknown COMP idx (%d) !\n", Index_Id);
|
printf( "Unknown COMP idx (%d)!\n", Index_Id);
|
||||||
return( NDS_KO);
|
return( NDS_KO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -631,7 +629,7 @@ NDT_Status DR_Instrument_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id,
|
|||||||
|
|
||||||
if( ( nd_status = ND_DataStruct_Info_Print( Out, Instrument_Ptr->Layer_DS_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0)) != NDS_OK)
|
if( ( nd_status = ND_DataStruct_Info_Print( Out, Instrument_Ptr->Layer_DS_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0)) != NDS_OK)
|
||||||
{
|
{
|
||||||
printf( "DR_Instrument_Manager: ND_DataStruct_Info_Print() failed (%d) !\n", nd_status);
|
printf( "DR_Instrument_Manager: ND_DataStruct_Info_Print() failed (%d)!\n", nd_status);
|
||||||
return( DRS_KO);
|
return( DRS_KO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -698,7 +696,7 @@ NDT_Status DR_Instrument_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id,
|
|||||||
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
|
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
|
||||||
|
|
||||||
ND_VA_ARG_GET( Kit_Ptr, user_args, DRT_Kit *);
|
ND_VA_ARG_GET( Kit_Ptr, user_args, DRT_Kit *);
|
||||||
ND_VA_ARG_GET( SampleRate, user_args, double);
|
ND_VA_ARG_GET( SampleRate, user_args, DRT_SampleRate);
|
||||||
|
|
||||||
ND_VA_LIST_CLOSE( user_args);
|
ND_VA_LIST_CLOSE( user_args);
|
||||||
|
|
||||||
@ -742,9 +740,9 @@ NDT_Status DR_Instrument_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* */
|
/* */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
NDT_Status DR_Kit_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Command, va_list *Args_Ptr)
|
NDT_Status DR_Kit_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Command, va_list *Args_Ptr)
|
||||||
{
|
{
|
||||||
@ -842,15 +840,16 @@ NDT_Status DR_Kit_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
|
|||||||
|
|
||||||
if( ( *Kit_Ptr_Ptr = (DRT_Kit *)malloc( sizeof( DRT_Kit))) != NULL)
|
if( ( *Kit_Ptr_Ptr = (DRT_Kit *)malloc( sizeof( DRT_Kit))) != NULL)
|
||||||
{
|
{
|
||||||
( *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;
|
||||||
|
( *Kit_Ptr_Ptr)->Status = Kit_Template_Ptr->Status;
|
||||||
|
|
||||||
strncpy( ( *Kit_Ptr_Ptr)->Name, Kit_Template_Ptr->Name, NAME_SIZE);
|
strncpy( ( *Kit_Ptr_Ptr)->Name, Kit_Template_Ptr->Name, DRD_NAME_SIZE);
|
||||||
strncpy( ( *Kit_Ptr_Ptr)->Desc, Kit_Template_Ptr->Desc, DESC_SIZE);
|
strncpy( ( *Kit_Ptr_Ptr)->Desc, Kit_Template_Ptr->Desc, DRD_DESC_SIZE);
|
||||||
strncpy( ( *Kit_Ptr_Ptr)->DirName, Kit_Template_Ptr->DirName, DIRNAME_SIZE);
|
strncpy( ( *Kit_Ptr_Ptr)->DirName, Kit_Template_Ptr->DirName, DRD_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)
|
||||||
{
|
{
|
||||||
printf( "DR_Kit_Manager: ND_DataStruct_Open() failed (%d) !\n", nd_status);
|
printf( "DR_Kit_Manager: ND_DataStruct_Open() failed (%d)!\n", nd_status);
|
||||||
return( NDS_KO);
|
return( NDS_KO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -908,7 +907,7 @@ NDT_Status DR_Kit_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
printf( "Unknown COMP idx (%d) !\n", Index_Id);
|
printf( "Unknown COMP idx (%d)!\n", Index_Id);
|
||||||
return( NDS_KO);
|
return( NDS_KO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1022,7 +1021,7 @@ NDT_Status DR_Kit_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
|
|||||||
|
|
||||||
if( ( nd_status = ND_DataStruct_Info_Print( Out, Kit_Ptr->Instrument_DS_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0)) != NDS_OK)
|
if( ( nd_status = ND_DataStruct_Info_Print( Out, Kit_Ptr->Instrument_DS_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0)) != NDS_OK)
|
||||||
{
|
{
|
||||||
printf( "DR_Kit_Manager: ND_DataStruct_Info_Print() failed (%d) !\n", nd_status);
|
printf( "DR_Kit_Manager: ND_DataStruct_Info_Print() failed (%d)!\n", nd_status);
|
||||||
return( DRS_KO);
|
return( DRS_KO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1085,7 +1084,7 @@ NDT_Status DR_Kit_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
|
|||||||
|
|
||||||
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
|
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
|
||||||
|
|
||||||
ND_VA_ARG_GET( SampleRate, user_args, double);
|
ND_VA_ARG_GET( SampleRate, user_args, DRT_SampleRate);
|
||||||
|
|
||||||
ND_VA_LIST_CLOSE( user_args);
|
ND_VA_LIST_CLOSE( user_args);
|
||||||
|
|
||||||
@ -1094,7 +1093,33 @@ NDT_Status DR_Kit_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
|
|||||||
|
|
||||||
Command_Name = "NDD_CMD_SAMPLE_LOAD";
|
Command_Name = "NDD_CMD_SAMPLE_LOAD";
|
||||||
|
|
||||||
return( ND_DataStruct_Traverse( Kit_Ptr->Instrument_DS_Ptr, NDD_CMD_SAMPLE_LOAD, Kit_Ptr, SampleRate));
|
if( DR_Kit_Sample_Load( Kit_Ptr, SampleRate) != DRS_OK)
|
||||||
|
{
|
||||||
|
return( NDS_KO);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return( NDS_OK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case NDD_CMD_SAMPLE_UNLOAD:
|
||||||
|
{
|
||||||
|
ND_VA_ARG_GET( Next_Node_Ptr, *Args_Ptr, NDT_Node *);
|
||||||
|
|
||||||
|
DRT_Kit *Kit_Ptr = Node_Ptr->Value;
|
||||||
|
|
||||||
|
|
||||||
|
Command_Name = "NDD_CMD_SAMPLE_UNLOAD";
|
||||||
|
|
||||||
|
if( DR_Kit_Sample_UnLoad( Kit_Ptr) != DRS_OK)
|
||||||
|
{
|
||||||
|
return( NDS_KO);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return( NDS_OK);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1145,9 +1170,9 @@ NDT_Status DR_Kit_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* DR_Layer_Add */
|
/* DR_Layer_Add */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
DRT_Status DR_Layer_Add( DRT_Layer **Layer_Ptr_Ptr, NDT_Root *DS_Ptr, DRT_Layer *Layer_Template_Ptr)
|
DRT_Status DR_Layer_Add( DRT_Layer **Layer_Ptr_Ptr, NDT_Root *DS_Ptr, DRT_Layer *Layer_Template_Ptr)
|
||||||
{
|
{
|
||||||
@ -1156,14 +1181,14 @@ DRT_Status DR_Layer_Add( DRT_Layer **Layer_Ptr_Ptr, NDT_Root *DS_Ptr, DRT_Lay
|
|||||||
|
|
||||||
if( ( nd_status = ND_Value_Alloc( DS_Ptr, (void **)Layer_Ptr_Ptr, Layer_Template_Ptr)) != NDS_OK)
|
if( ( nd_status = ND_Value_Alloc( DS_Ptr, (void **)Layer_Ptr_Ptr, Layer_Template_Ptr)) != NDS_OK)
|
||||||
{
|
{
|
||||||
printf( "Can't allocate new layer: ND_Value_Alloc() failed (%d) !\n", nd_status);
|
printf( "Can't allocate new layer: ND_Value_Alloc() failed (%d)!\n", nd_status);
|
||||||
return( DRS_KO);
|
return( DRS_KO);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( ( nd_status = ND_DataStruct_Value_Add( DS_Ptr, (void *)*Layer_Ptr_Ptr)) != NDS_OK)
|
if( ( nd_status = ND_DataStruct_Value_Add( DS_Ptr, (void *)*Layer_Ptr_Ptr)) != NDS_OK)
|
||||||
{
|
{
|
||||||
printf( "Can't add new layer: ND_Value_Add() failed (%d) !\n", nd_status);
|
printf( "Can't add new layer: ND_Value_Add() failed (%d)!\n", nd_status);
|
||||||
return( DRS_KO);
|
return( DRS_KO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1175,28 +1200,28 @@ DRT_Status DR_Layer_Add( DRT_Layer **Layer_Ptr_Ptr, NDT_Root *DS_Ptr, DRT_Lay
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* DR_Layer_Sample_Load */
|
/* DR_Layer_Sample_Load */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
DRT_Status DR_Layer_Sample_Load( DRT_Layer *Layer_Ptr, DRT_Kit *Kit_Ptr, double SampleRate)
|
DRT_Status DR_Layer_Sample_Load( DRT_Layer *Layer_Ptr, DRT_Kit *Kit_Ptr, DRT_SampleRate SampleRate)
|
||||||
{
|
{
|
||||||
DRT_Status status;
|
DRT_Status status;
|
||||||
SNDFILE *sndf_ptr;
|
SNDFILE *sndf_ptr;
|
||||||
|
|
||||||
|
|
||||||
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->SF_Info_Ptr != NULL)
|
||||||
{
|
{
|
||||||
if( Layer_Ptr->Sample_Ptr != NULL)
|
if( Layer_Ptr->Sample_Ptr != NULL)
|
||||||
{
|
{
|
||||||
fprintf( stderr, "Skiping: [%s]\n", Layer_Ptr->FileName);
|
// fprintf( stderr, "Skiping: [%s]\n", Layer_Ptr->FileName);
|
||||||
return( DRS_OK);
|
return( DRS_OK);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf( stderr, "Freeing SF_Info: [%s]\n", Layer_Ptr->FileName);
|
// fprintf( stderr, "Freeing SF_Info: [%s]\n", Layer_Ptr->FileName);
|
||||||
free( Layer_Ptr->SF_Info_Ptr );
|
free( Layer_Ptr->SF_Info_Ptr );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1204,14 +1229,14 @@ DRT_Status DR_Layer_Sample_Load( DRT_Layer *Layer_Ptr, DRT_Kit *Kit_Ptr, doub
|
|||||||
{
|
{
|
||||||
if( Layer_Ptr->Sample_Ptr != NULL)
|
if( Layer_Ptr->Sample_Ptr != NULL)
|
||||||
{
|
{
|
||||||
fprintf( stderr, "Freeing Sample: [%s]\n", Layer_Ptr->FileName);
|
// fprintf( stderr, "Freeing Sample: [%s]\n", Layer_Ptr->FileName);
|
||||||
free( Layer_Ptr->Sample_Ptr);
|
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");
|
||||||
return( DRS_KO);
|
return( DRS_KO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1252,11 +1277,11 @@ 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);
|
// fprintf( stderr, "Resampling: [%s] (%d)->(%d)\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 = (double)SampleRate / Layer_Ptr->SF_Info_Ptr->samplerate;
|
||||||
src_data.output_frames = (long)ceil( Layer_Ptr->SF_Info_Ptr->frames * src_data.src_ratio);
|
src_data.output_frames = (long)ceil( Layer_Ptr->SF_Info_Ptr->frames * src_data.src_ratio);
|
||||||
|
|
||||||
out_size = src_data.output_frames * Layer_Ptr->SF_Info_Ptr->channels * sizeof( float);
|
out_size = src_data.output_frames * Layer_Ptr->SF_Info_Ptr->channels * sizeof( float);
|
||||||
@ -1269,7 +1294,7 @@ DRT_Status DR_Layer_Sample_Load( DRT_Layer *Layer_Ptr, DRT_Kit *Kit_Ptr, doub
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
if( ( src_status = src_simple( &src_data, RATE_CONV_QUALITY, Layer_Ptr->SF_Info_Ptr->channels)) != 0)
|
if( ( src_status = src_simple( &src_data, DRD_RATE_CONV_QUALITY, Layer_Ptr->SF_Info_Ptr->channels)) != 0)
|
||||||
{
|
{
|
||||||
fprintf( stderr,"Can't convert rate for [%s]: [%s]\n", Layer_Ptr->FileName, src_strerror( src_status));
|
fprintf( stderr,"Can't convert rate for [%s]: [%s]\n", Layer_Ptr->FileName, src_strerror( src_status));
|
||||||
|
|
||||||
@ -1298,10 +1323,6 @@ DRT_Status DR_Layer_Sample_Load( DRT_Layer *Layer_Ptr, DRT_Kit *Kit_Ptr, doub
|
|||||||
sf_close( sndf_ptr);
|
sf_close( sndf_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fprintf( stderr, "Debug !\n");
|
|
||||||
// DR_Layer_Dump(Layer_Ptr, 0);
|
|
||||||
// free( Layer_Ptr->SF_Info_Ptr);
|
|
||||||
|
|
||||||
return( status);
|
return( status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1309,24 +1330,24 @@ DRT_Status DR_Layer_Sample_Load( DRT_Layer *Layer_Ptr, DRT_Kit *Kit_Ptr, doub
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* DR_Layer_Sample_UnLoad */
|
/* DR_Layer_Sample_UnLoad */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
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);
|
// fprintf( stderr, "UnLoading: [%s]\n", Layer_Ptr->FileName);
|
||||||
|
|
||||||
|
|
||||||
if( Layer_Ptr->Sample_Ptr != NULL)
|
if( Layer_Ptr->Sample_Ptr != NULL)
|
||||||
{
|
{
|
||||||
fprintf( stderr, "Freeing Sample!\n");
|
// fprintf( stderr, "Freeing Sample!\n");
|
||||||
free( Layer_Ptr->Sample_Ptr);
|
free( Layer_Ptr->Sample_Ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( Layer_Ptr->SF_Info_Ptr != NULL)
|
if( Layer_Ptr->SF_Info_Ptr != NULL)
|
||||||
{
|
{
|
||||||
fprintf( stderr, "Freeing SF_Info!\n");
|
// fprintf( stderr, "Freeing SF_Info!\n");
|
||||||
free( Layer_Ptr->SF_Info_Ptr);
|
free( Layer_Ptr->SF_Info_Ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1337,9 +1358,9 @@ DRT_Status DR_Layer_Sample_UnLoad( DRT_Layer *Layer_Ptr)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* DR_Layer_Dump */
|
/* DR_Layer_Dump */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
DRT_Status DR_Layer_Dump( DRT_Layer *Layer_Ptr, long count)
|
DRT_Status DR_Layer_Dump( DRT_Layer *Layer_Ptr, long count)
|
||||||
{
|
{
|
||||||
@ -1366,9 +1387,9 @@ DRT_Status DR_Layer_Dump( DRT_Layer *Layer_Ptr, long count)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* DR_Instrument_Add */
|
/* DR_Instrument_Add */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
DRT_Status DR_Instrument_Add( DRT_Instrument **Instrument_Ptr_Ptr, NDT_Root *DS_Ptr, DRT_Instrument *Instrument_Template_Ptr)
|
DRT_Status DR_Instrument_Add( DRT_Instrument **Instrument_Ptr_Ptr, NDT_Root *DS_Ptr, DRT_Instrument *Instrument_Template_Ptr)
|
||||||
{
|
{
|
||||||
@ -1377,14 +1398,14 @@ DRT_Status DR_Instrument_Add( DRT_Instrument **Instrument_Ptr_Ptr, NDT_Root *
|
|||||||
|
|
||||||
if( ( nd_status = ND_Value_Alloc( DS_Ptr, (void **)Instrument_Ptr_Ptr, Instrument_Template_Ptr)) != NDS_OK)
|
if( ( nd_status = ND_Value_Alloc( DS_Ptr, (void **)Instrument_Ptr_Ptr, Instrument_Template_Ptr)) != NDS_OK)
|
||||||
{
|
{
|
||||||
printf( "Can't allocate new instrument: ND_Value_Alloc() failed (%d) !\n", nd_status);
|
printf( "Can't allocate new instrument: ND_Value_Alloc() failed (%d)!\n", nd_status);
|
||||||
return( DRS_KO);
|
return( DRS_KO);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( ( nd_status = ND_DataStruct_Value_Add( DS_Ptr, (void *)*Instrument_Ptr_Ptr)) != NDS_OK)
|
if( ( nd_status = ND_DataStruct_Value_Add( DS_Ptr, (void *)*Instrument_Ptr_Ptr)) != NDS_OK)
|
||||||
{
|
{
|
||||||
printf( "Can't add new instrument: ND_Value_Add() failed (%d) !\n", nd_status);
|
printf( "Can't add new instrument: ND_Value_Add() failed (%d)!\n", nd_status);
|
||||||
return( DRS_KO);
|
return( DRS_KO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1396,9 +1417,9 @@ 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)
|
||||||
{
|
{
|
||||||
@ -1422,7 +1443,7 @@ DRT_Status DR_Instrument_Dump( DRT_Instrument *Instrument_Ptr, long Count)
|
|||||||
|
|
||||||
if( ( nd_status = ND_DataStruct_Value_Print( stderr, Instrument_Ptr->Layer_DS_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0, &count2)) != NDS_OK)
|
if( ( nd_status = ND_DataStruct_Value_Print( stderr, Instrument_Ptr->Layer_DS_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0, &count2)) != NDS_OK)
|
||||||
{
|
{
|
||||||
printf( "Cant't dump layers: ND_DataStruct_Traverse() failed (%d) !\n", nd_status);
|
printf( "Cant't dump layers: ND_DataStruct_Traverse() failed (%d)!\n", nd_status);
|
||||||
return( DRS_KO);
|
return( DRS_KO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1436,9 +1457,9 @@ DRT_Status DR_Instrument_Dump( DRT_Instrument *Instrument_Ptr, long Count)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* DR_Kit_Add */
|
/* DR_Kit_Add */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
DRT_Status DR_Kit_Add( DRT_Kit **Kit_Ptr_Ptr, NDT_Root *DS_Ptr, DRT_Kit *Kit_Template_Ptr)
|
DRT_Status DR_Kit_Add( DRT_Kit **Kit_Ptr_Ptr, NDT_Root *DS_Ptr, DRT_Kit *Kit_Template_Ptr)
|
||||||
{
|
{
|
||||||
@ -1447,14 +1468,14 @@ DRT_Status DR_Kit_Add( DRT_Kit **Kit_Ptr_Ptr, NDT_Root *DS_Ptr, DRT_Kit *Kit
|
|||||||
|
|
||||||
if( ( nd_status = ND_Value_Alloc( DS_Ptr, (void **)Kit_Ptr_Ptr, Kit_Template_Ptr)) != NDS_OK)
|
if( ( nd_status = ND_Value_Alloc( DS_Ptr, (void **)Kit_Ptr_Ptr, Kit_Template_Ptr)) != NDS_OK)
|
||||||
{
|
{
|
||||||
printf( "Can't allocate new kit: ND_Value_Alloc() failed (%d) !\n", nd_status);
|
printf( "Can't allocate new kit: ND_Value_Alloc() failed (%d)!\n", nd_status);
|
||||||
return( DRS_KO);
|
return( DRS_KO);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( ( nd_status = ND_DataStruct_Value_Add( DS_Ptr, (void **)*Kit_Ptr_Ptr)) != NDS_OK)
|
if( ( nd_status = ND_DataStruct_Value_Add( DS_Ptr, (void **)*Kit_Ptr_Ptr)) != NDS_OK)
|
||||||
{
|
{
|
||||||
printf( "Can't add new kit: ND_Value_Add() failed (%d) !\n", nd_status);
|
printf( "Can't add new kit: ND_Value_Add() failed (%d)!\n", nd_status);
|
||||||
return( DRS_KO);
|
return( DRS_KO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1466,9 +1487,9 @@ DRT_Status DR_Kit_Add( DRT_Kit **Kit_Ptr_Ptr, NDT_Root *DS_Ptr, DRT_Kit *Kit
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* DR_Kit_Id_Find */
|
/* DR_Kit_Id_Find */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
DRT_Status DR_Kit_Id_Find( DRT_Kit **Kit_Ptr_Ptr, NDT_Root *DS_Ptr, DRT_Kit_Id Kit_Id)
|
DRT_Status DR_Kit_Id_Find( DRT_Kit **Kit_Ptr_Ptr, NDT_Root *DS_Ptr, DRT_Kit_Id Kit_Id)
|
||||||
{
|
{
|
||||||
@ -1505,9 +1526,9 @@ DRT_Status DR_Kit_Id_Find( DRT_Kit **Kit_Ptr_Ptr, NDT_Root *DS_Ptr, DRT_Kit_I
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* DR_Kit_Name_Find */
|
/* DR_Kit_Name_Find */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
extern DRT_Status DR_Kit_Name_Find( DRT_Kit **Kit_Ptr_Ptr, NDT_Root *DS_Ptr, char *Kit_Name)
|
extern DRT_Status DR_Kit_Name_Find( DRT_Kit **Kit_Ptr_Ptr, NDT_Root *DS_Ptr, char *Kit_Name)
|
||||||
{
|
{
|
||||||
@ -1517,7 +1538,7 @@ extern DRT_Status DR_Kit_Name_Find( DRT_Kit **Kit_Ptr_Ptr, NDT_Root *DS_Ptr,
|
|||||||
|
|
||||||
|
|
||||||
kit_template.Id = 1;
|
kit_template.Id = 1;
|
||||||
strncpy( kit_template.Name, Kit_Name, NAME_LEN);
|
strncpy( kit_template.Name, Kit_Name, DRD_NAME_LEN);
|
||||||
|
|
||||||
if( ( nd_status = ND_DataStruct_Value_Find( (void **)Kit_Ptr_Ptr, DS_Ptr, &kit_template)) != NDS_OK)
|
if( ( nd_status = ND_DataStruct_Value_Find( (void **)Kit_Ptr_Ptr, DS_Ptr, &kit_template)) != NDS_OK)
|
||||||
{
|
{
|
||||||
@ -1544,9 +1565,9 @@ extern DRT_Status DR_Kit_Name_Find( DRT_Kit **Kit_Ptr_Ptr, NDT_Root *DS_Ptr,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* DR_Kit_Dump */
|
/* DR_Kit_Dump */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
DRT_Status DR_Kit_Dump( DRT_Kit *Kit_Ptr, long Count)
|
DRT_Status DR_Kit_Dump( DRT_Kit *Kit_Ptr, long Count)
|
||||||
{
|
{
|
||||||
@ -1556,7 +1577,7 @@ DRT_Status DR_Kit_Dump( DRT_Kit *Kit_Ptr, long Count)
|
|||||||
|
|
||||||
|
|
||||||
fprintf( stderr, " %03ld) 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) Status: [%s] Name: [%s] Descrition: [%.32s] Dir Name: [%s]\n", Kit_Ptr->Id, DR_LOAD_STATUS_ASCII_GET( Kit_Ptr), Kit_Ptr->Name, Kit_Ptr->Desc, Kit_Ptr->DirName);
|
||||||
fprintf( stderr, " Instruments List:\n");
|
fprintf( stderr, " Instruments List:\n");
|
||||||
|
|
||||||
if( Kit_Ptr->Instrument_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Node_Number == 0)
|
if( Kit_Ptr->Instrument_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Node_Number == 0)
|
||||||
@ -1569,7 +1590,7 @@ DRT_Status DR_Kit_Dump( DRT_Kit *Kit_Ptr, long Count)
|
|||||||
|
|
||||||
if( ( nd_status = ND_DataStruct_Value_Print( stderr, Kit_Ptr->Instrument_DS_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0, &count2)) != NDS_OK)
|
if( ( nd_status = ND_DataStruct_Value_Print( stderr, Kit_Ptr->Instrument_DS_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0, &count2)) != NDS_OK)
|
||||||
{
|
{
|
||||||
printf( "Cant't dump intruments: ND_DataStruct_Traverse() failed (%d) !\n", nd_status);
|
printf( "Cant't dump intruments: ND_DataStruct_Traverse() failed (%d)!\n", nd_status);
|
||||||
return( DRS_KO);
|
return( DRS_KO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1583,9 +1604,9 @@ DRT_Status DR_Kit_Dump( DRT_Kit *Kit_Ptr, long Count)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* DR_XML_Node_Exist */
|
/* DR_XML_Node_Exist */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
DRT_Status DR_XML_Node_Exist( xmlDocPtr Xml_Doc, xmlXPathContextPtr Xml_XpathCtx, char *Xpath_Request)
|
DRT_Status DR_XML_Node_Exist( xmlDocPtr Xml_Doc, xmlXPathContextPtr Xml_XpathCtx, char *Xpath_Request)
|
||||||
{
|
{
|
||||||
@ -1626,9 +1647,9 @@ DRT_Status DR_XML_Node_Exist( xmlDocPtr Xml_Doc, xmlXPathContextPtr Xml_Xpath
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* DR_XML_Value_Get */
|
/* DR_XML_Value_Get */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
DRT_Status DR_XML_Value_Get( char *Value_Ptr, long Max_Len, xmlDocPtr Xml_Doc, xmlXPathContextPtr Xml_XpathCtx, char *Xpath_HeadRequest, char *Xpath_TailRequest)
|
DRT_Status DR_XML_Value_Get( char *Value_Ptr, long Max_Len, xmlDocPtr Xml_Doc, xmlXPathContextPtr Xml_XpathCtx, char *Xpath_HeadRequest, char *Xpath_TailRequest)
|
||||||
{
|
{
|
||||||
@ -1693,14 +1714,14 @@ DRT_Status DR_XML_Value_Get( char *Value_Ptr, long Max_Len, xmlDocPtr Xml_Do
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* DR_XML_Query_Tab_Exec */
|
/* DR_XML_Query_Tab_Exec */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
DRT_Status DR_XML_Query_Tab_Exec( void *Value_Ptr, xmlDocPtr XML_Doc, xmlXPathContextPtr XML_XpathCtx, char *Xpath_Head, DRT_XML_Query *XML_Query_Tab)
|
DRT_Status DR_XML_Query_Tab_Exec( void *Value_Ptr, xmlDocPtr XML_Doc, xmlXPathContextPtr XML_XpathCtx, char *Xpath_Head, DRT_XML_Query *XML_Query_Tab)
|
||||||
{
|
{
|
||||||
DRT_Status status;
|
DRT_Status status;
|
||||||
char reply_str[DESC_SIZE];
|
char reply_str[DRD_DESC_SIZE];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|
||||||
@ -1708,44 +1729,44 @@ DRT_Status DR_XML_Query_Tab_Exec( void *Value_Ptr, xmlDocPtr XML_Doc, xmlXPat
|
|||||||
|
|
||||||
while( XML_Query_Tab[i].XPath_Query != NULL)
|
while( XML_Query_Tab[i].XPath_Query != NULL)
|
||||||
{
|
{
|
||||||
if( ( status = DR_XML_Value_Get( reply_str, DESC_LEN, XML_Doc, XML_XpathCtx, Xpath_Head, XML_Query_Tab[i].XPath_Query)) != DRS_OK)
|
if( ( status = DR_XML_Value_Get( reply_str, DRD_DESC_LEN, XML_Doc, XML_XpathCtx, Xpath_Head, XML_Query_Tab[i].XPath_Query)) != DRS_OK)
|
||||||
{
|
{
|
||||||
strcpy( reply_str, "");
|
strcpy( reply_str, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
switch( XML_Query_Tab[i].Value_Type)
|
switch( XML_Query_Tab[i].Value_Type)
|
||||||
{
|
{
|
||||||
case XML_QUERY_VALUE_STRING:
|
case DRD_XML_QUERY_VALUE_STRING:
|
||||||
{
|
{
|
||||||
strncpy( ( Value_Ptr + XML_Query_Tab[i].Value_Offset), reply_str, XML_Query_Tab[i].Value_Len);
|
strncpy( ( Value_Ptr + XML_Query_Tab[i].Value_Offset), reply_str, XML_Query_Tab[i].Value_Len);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case XML_QUERY_VALUE_INT:
|
case DRD_XML_QUERY_VALUE_INT:
|
||||||
{
|
{
|
||||||
*( (int *)( Value_Ptr + XML_Query_Tab[i].Value_Offset)) = atoi( reply_str);
|
*( (int *)( Value_Ptr + XML_Query_Tab[i].Value_Offset)) = atoi( reply_str);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case XML_QUERY_VALUE_LONG:
|
case DRD_XML_QUERY_VALUE_LONG:
|
||||||
{
|
{
|
||||||
*( (long *)( Value_Ptr + XML_Query_Tab[i].Value_Offset)) = strtol( reply_str, NULL, 10);
|
*( (long *)( Value_Ptr + XML_Query_Tab[i].Value_Offset)) = strtol( reply_str, NULL, 10);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case XML_QUERY_VALUE_LONGLONG:
|
case DRD_XML_QUERY_VALUE_LONGLONG:
|
||||||
{
|
{
|
||||||
*( (long long *)( Value_Ptr + XML_Query_Tab[i].Value_Offset)) = strtoll( reply_str, NULL, 10);
|
*( (long long *)( Value_Ptr + XML_Query_Tab[i].Value_Offset)) = strtoll( reply_str, NULL, 10);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case XML_QUERY_VALUE_FLOAT:
|
case DRD_XML_QUERY_VALUE_FLOAT:
|
||||||
{
|
{
|
||||||
*( (float *)( Value_Ptr + XML_Query_Tab[i].Value_Offset)) = strtof( reply_str, NULL);
|
*( (float *)( Value_Ptr + XML_Query_Tab[i].Value_Offset)) = strtof( reply_str, NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case XML_QUERY_VALUE_DOUBLE:
|
case DRD_XML_QUERY_VALUE_DOUBLE:
|
||||||
{
|
{
|
||||||
*( (double *)( Value_Ptr + XML_Query_Tab[i].Value_Offset)) = strtod( reply_str, NULL);
|
*( (double *)( Value_Ptr + XML_Query_Tab[i].Value_Offset)) = strtod( reply_str, NULL);
|
||||||
break;
|
break;
|
||||||
@ -1767,9 +1788,9 @@ DRT_Status DR_XML_Query_Tab_Exec( void *Value_Ptr, xmlDocPtr XML_Doc, xmlXPat
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* DR_Kit_Load */
|
/* DR_Kit_Load */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
DRT_Status DR_Kit_Load( DRT_Base *Base_Ptr, char *FileName)
|
DRT_Status DR_Kit_Load( DRT_Base *Base_Ptr, char *FileName)
|
||||||
{
|
{
|
||||||
@ -1787,7 +1808,7 @@ DRT_Status DR_Kit_Load( DRT_Base *Base_Ptr, char *FileName)
|
|||||||
xmlXPathContextPtr xml_xpathCtx;
|
xmlXPathContextPtr xml_xpathCtx;
|
||||||
xmlXPathObjectPtr xml_xpathObj;
|
xmlXPathObjectPtr xml_xpathObj;
|
||||||
|
|
||||||
char tmp_filename[FILENAME_SIZE];
|
char tmp_filename[DRD_FILENAME_SIZE];
|
||||||
char xpath_head[1024];
|
char xpath_head[1024];
|
||||||
char reply_str[256];
|
char reply_str[256];
|
||||||
|
|
||||||
@ -1795,6 +1816,7 @@ DRT_Status DR_Kit_Load( DRT_Base *Base_Ptr, char *FileName)
|
|||||||
short i;
|
short i;
|
||||||
|
|
||||||
|
|
||||||
|
kit_template.Status = DRD_LOAD_STATUS_UNLOADED;
|
||||||
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;
|
layer_template.SF_Info_Ptr = NULL;
|
||||||
@ -1802,7 +1824,7 @@ DRT_Status DR_Kit_Load( DRT_Base *Base_Ptr, char *FileName)
|
|||||||
|
|
||||||
fprintf( stderr, "Loading: [%s]...\n", FileName);
|
fprintf( stderr, "Loading: [%s]...\n", FileName);
|
||||||
|
|
||||||
if( strlen( FileName) > FILENAME_LEN)
|
if( strlen( FileName) > DRD_FILENAME_LEN)
|
||||||
{
|
{
|
||||||
fprintf( stderr, "Kit file name too long [%s]!", FileName);
|
fprintf( stderr, "Kit file name too long [%s]!", FileName);
|
||||||
status = DRS_KO;
|
status = DRS_KO;
|
||||||
@ -1832,13 +1854,13 @@ DRT_Status DR_Kit_Load( DRT_Base *Base_Ptr, char *FileName)
|
|||||||
status = DRS_KO;
|
status = DRS_KO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ( status = DR_XML_Node_Exist( xml_doc, xml_xpathCtx, XML_XPATH_DRUMKIT_BASE_STR) != DRS_OK))
|
if( ( status = DR_XML_Node_Exist( xml_doc, xml_xpathCtx, DRD_XML_XPATH_DRUMKIT_BASE_STR) != DRS_OK))
|
||||||
{
|
{
|
||||||
fprintf( stderr, "Bad drumkit file!\n");
|
fprintf( stderr, "Bad drumkit file!\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DR_XML_Query_Tab_Exec( &kit_template, xml_doc, xml_xpathCtx, XML_XPATH_DRUMKIT_BASE_STR, DRG_XML_Query_Tab_Kit);
|
DR_XML_Query_Tab_Exec( &kit_template, xml_doc, xml_xpathCtx, DRD_XML_XPATH_DRUMKIT_BASE_STR, DRG_XML_Query_Tab_Kit);
|
||||||
|
|
||||||
if( ( status = DR_Kit_Add( &kit_ptr, Base_Ptr->Kit_DS_Ptr, &kit_template)) != DRS_OK)
|
if( ( status = DR_Kit_Add( &kit_ptr, Base_Ptr->Kit_DS_Ptr, &kit_template)) != DRS_OK)
|
||||||
{
|
{
|
||||||
@ -1851,7 +1873,7 @@ DRT_Status DR_Kit_Load( DRT_Base *Base_Ptr, char *FileName)
|
|||||||
status = DRS_OK;
|
status = DRS_OK;
|
||||||
instrument = 1;
|
instrument = 1;
|
||||||
while( ( status == DRS_OK)
|
while( ( status == DRS_OK)
|
||||||
&& ( sprintf( xpath_head, XML_XPATH_DRUMKIT_INSTRUMENT_FULL, instrument) > 0)
|
&& ( sprintf( xpath_head, DRD_XML_XPATH_DRUMKIT_INSTRUMENT_FULL, instrument) > 0)
|
||||||
&& ( DR_XML_Node_Exist( xml_doc, xml_xpathCtx, xpath_head) == DRS_OK))
|
&& ( DR_XML_Node_Exist( xml_doc, xml_xpathCtx, xpath_head) == DRS_OK))
|
||||||
{
|
{
|
||||||
instrument_template.Id = -1;
|
instrument_template.Id = -1;
|
||||||
@ -1875,7 +1897,7 @@ DRT_Status DR_Kit_Load( DRT_Base *Base_Ptr, char *FileName)
|
|||||||
|
|
||||||
layer = 1;
|
layer = 1;
|
||||||
while( ( status == DRS_OK)
|
while( ( status == DRS_OK)
|
||||||
&& ( sprintf( xpath_head, XML_XPATH_DRUMKIT_LAYER_FULL, instrument, layer) > 0)
|
&& ( sprintf( xpath_head, DRD_XML_XPATH_DRUMKIT_LAYER_FULL, instrument, layer) > 0)
|
||||||
&& ( DR_XML_Node_Exist( xml_doc, xml_xpathCtx, xpath_head) == DRS_OK))
|
&& ( DR_XML_Node_Exist( xml_doc, xml_xpathCtx, xpath_head) == DRS_OK))
|
||||||
{
|
{
|
||||||
DR_XML_Query_Tab_Exec( &layer_template, xml_doc, xml_xpathCtx, xpath_head, DRG_XML_Query_Tab_Layer);
|
DR_XML_Query_Tab_Exec( &layer_template, xml_doc, xml_xpathCtx, xpath_head, DRG_XML_Query_Tab_Layer);
|
||||||
@ -1918,21 +1940,32 @@ DRT_Status DR_Kit_Load( DRT_Base *Base_Ptr, char *FileName)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* DR_Kit_Sample_Load */
|
/* DR_Kit_Sample_Load */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
DRT_Status DR_Kit_Sample_Load( DRT_Kit *Kit_Ptr, double SampleRate)
|
DRT_Status DR_Kit_Sample_Load( DRT_Kit *Kit_Ptr, DRT_SampleRate SampleRate)
|
||||||
{
|
{
|
||||||
NDT_Status nd_status;
|
NDT_Status nd_status;
|
||||||
|
|
||||||
|
|
||||||
if( ( nd_status = ND_DataStruct_Traverse( Kit_Ptr->Instrument_DS_Ptr, NDD_CMD_SAMPLE_LOAD, Kit_Ptr, SampleRate)) != NDS_OK)
|
if( DR_LOAD_STATUS_LOADED_IS( Kit_Ptr))
|
||||||
{
|
{
|
||||||
printf( "Cant't load kit samples: ND_DataStruct_Traverse() failed (%d) !\n", nd_status);
|
fprintf( stderr, "Loading kit samples: [%s] Skiped!\n", Kit_Ptr->Name);
|
||||||
return( DRS_KO);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf( stderr, "Loading kit samples: [%s]!\n", Kit_Ptr->Name);
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
Kit_Ptr->Status = DRD_LOAD_STATUS_LOADED;
|
||||||
|
}
|
||||||
|
|
||||||
return( DRS_OK);
|
return( DRS_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1940,19 +1973,30 @@ DRT_Status DR_Kit_Sample_Load( DRT_Kit *Kit_Ptr, double SampleRate)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* DR_Kit_Sample_UnLoad */
|
/* DR_Kit_Sample_UnLoad */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
DRT_Status DR_Kit_Sample_UnLoad( DRT_Kit *Kit_Ptr)
|
DRT_Status DR_Kit_Sample_UnLoad( DRT_Kit *Kit_Ptr)
|
||||||
{
|
{
|
||||||
NDT_Status nd_status;
|
NDT_Status nd_status;
|
||||||
|
|
||||||
|
|
||||||
if( ( nd_status = ND_DataStruct_Traverse( Kit_Ptr->Instrument_DS_Ptr, NDD_CMD_SAMPLE_UNLOAD, Kit_Ptr)) != NDS_OK)
|
if( !DR_LOAD_STATUS_LOADED_IS( Kit_Ptr))
|
||||||
{
|
{
|
||||||
printf( "Cant't unload kit samples: ND_DataStruct_Traverse() failed (%d) !\n", nd_status);
|
fprintf( stderr, "UnLoading kit samples: [%s] Skiped!\n", Kit_Ptr->Name);
|
||||||
return( DRS_KO);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf( stderr, "UnLoading kit samples: [%s]!\n", Kit_Ptr->Name);
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
Kit_Ptr->Status = DRD_LOAD_STATUS_UNLOADED;
|
||||||
}
|
}
|
||||||
|
|
||||||
return( DRS_OK);
|
return( DRS_OK);
|
||||||
@ -1962,24 +2006,24 @@ DRT_Status DR_Kit_Sample_UnLoad( DRT_Kit *Kit_Ptr)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* DR_DataStruct_Init */
|
/* DR_DataStruct_Init */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
DRT_Status DR_DataStruct_Init( DRT_Base *Base_Ptr, double SampleRate)
|
DRT_Status DR_DataStruct_Init( DRT_Base *Base_Ptr, DRT_SampleRate SampleRate)
|
||||||
{
|
{
|
||||||
NDT_Status nd_status;
|
NDT_Status nd_status;
|
||||||
|
|
||||||
|
|
||||||
if( ( nd_status = ND_Library_Open( NDD_TRUE)) != NDS_OK)
|
if( ( nd_status = ND_Library_Open( NDD_TRUE)) != NDS_OK)
|
||||||
{
|
{
|
||||||
fprintf( stderr, "Can't open node library (%d) !", nd_status);
|
fprintf( stderr, "Can't open node library (%d)!\n", nd_status);
|
||||||
return( DRS_KO);
|
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)
|
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);
|
printf( "Kit_DS: ND_DataStruct_Open() failed (%d)!\n", nd_status);
|
||||||
return( DRS_KO);
|
return( DRS_KO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1992,9 +2036,9 @@ DRT_Status DR_DataStruct_Init( DRT_Base *Base_Ptr, double SampleRate)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* DR_DataStruct_DeInit */
|
/* DR_DataStruct_DeInit */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
DRT_Status DR_DataStruct_DeInit( DRT_Base *Base_Ptr)
|
DRT_Status DR_DataStruct_DeInit( DRT_Base *Base_Ptr)
|
||||||
{
|
{
|
||||||
@ -2009,7 +2053,7 @@ DRT_Status DR_DataStruct_DeInit( DRT_Base *Base_Ptr)
|
|||||||
|
|
||||||
if( ( nd_status = ND_Library_Close()) != NDS_OK)
|
if( ( nd_status = ND_Library_Close()) != NDS_OK)
|
||||||
{
|
{
|
||||||
fprintf( stderr, "Can't close node library (%d)!", nd_status);
|
fprintf( stderr, "Can't close node library (%d)!\n", nd_status);
|
||||||
return( DRS_KO);
|
return( DRS_KO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2020,18 +2064,20 @@ DRT_Status DR_DataStruct_DeInit( DRT_Base *Base_Ptr)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* DR_Kits_Sample_Load */
|
/* DR_Kits_Sample_Load */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
DRT_Status DR_Kits_Sample_Load( DRT_Base *Base_Ptr)
|
DRT_Status DR_Kits_Sample_Load( DRT_Base *Base_Ptr)
|
||||||
{
|
{
|
||||||
NDT_Status nd_status;
|
NDT_Status nd_status;
|
||||||
|
|
||||||
|
|
||||||
|
fprintf( stderr, "Loading kits samples!\n");
|
||||||
|
|
||||||
if( ( nd_status = ND_DataStruct_Traverse( Base_Ptr->Kit_DS_Ptr, NDD_CMD_SAMPLE_LOAD, Base_Ptr->SampleRate)) != NDS_OK)
|
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);
|
printf( "Cant't load kit samples: ND_DataStruct_Traverse() failed (%d)!\n", nd_status);
|
||||||
return( DRS_KO);
|
return( DRS_KO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2042,18 +2088,20 @@ DRT_Status DR_Kits_Sample_Load( DRT_Base *Base_Ptr)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* DR_Kits_Sample_UnLoad */
|
/* DR_Kits_Sample_UnLoad */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
DRT_Status DR_Kits_Sample_UnLoad( DRT_Base *Base_Ptr)
|
DRT_Status DR_Kits_Sample_UnLoad( DRT_Base *Base_Ptr)
|
||||||
{
|
{
|
||||||
NDT_Status nd_status;
|
NDT_Status nd_status;
|
||||||
|
|
||||||
|
|
||||||
|
fprintf( stderr, "UnLoading kits samples!\n");
|
||||||
|
|
||||||
if( ( nd_status = ND_DataStruct_Traverse( Base_Ptr->Kit_DS_Ptr, NDD_CMD_SAMPLE_UNLOAD, Base_Ptr->SampleRate)) != NDS_OK)
|
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);
|
printf( "Cant't unload kit samples: ND_DataStruct_Traverse() failed (%d)!\n", nd_status);
|
||||||
return( DRS_KO);
|
return( DRS_KO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2064,18 +2112,18 @@ DRT_Status DR_Kits_Sample_UnLoad( DRT_Base *Base_Ptr)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* DR_Kits_Load */
|
/* DR_Kits_Load */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
DRT_Status DR_Kits_Load( DRT_Base *Base_Ptr)
|
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";
|
// char glob_pattern[] = "~/.hydrogen/data/drumkits/Mars Mod */drumkit.xml";
|
||||||
glob_t glob_struct;
|
glob_t glob_struct;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -2101,7 +2149,7 @@ DRT_Status DR_Kits_Load( DRT_Base *Base_Ptr)
|
|||||||
|
|
||||||
if( ( nd_status = ND_DataStruct_Convert( Base_Ptr->Kit_DS_Ptr, DRG_Kit_DS_Index_Tab_Final)) != NDS_OK)
|
if( ( nd_status = ND_DataStruct_Convert( Base_Ptr->Kit_DS_Ptr, DRG_Kit_DS_Index_Tab_Final)) != NDS_OK)
|
||||||
{
|
{
|
||||||
fprintf( stderr, "ND_DataStruct_Convert() failed (%d) !\n", status);
|
fprintf( stderr, "ND_DataStruct_Convert() failed (%d)!\n", status);
|
||||||
status = DRS_KO;
|
status = DRS_KO;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2122,6 +2170,7 @@ DRT_Status DR_Kits_Load( DRT_Base *Base_Ptr)
|
|||||||
->Layer_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Head->Value),
|
->Layer_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Head->Value),
|
||||||
(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);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if( Base_Ptr->Kit_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Head != NULL)
|
if( Base_Ptr->Kit_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Head != NULL)
|
||||||
{
|
{
|
||||||
@ -2130,7 +2179,7 @@ DRT_Status DR_Kits_Load( DRT_Base *Base_Ptr)
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
status = DR_Kits_Sample_Load( Base_Ptr);
|
// status = DR_Kits_Sample_Load( Base_Ptr);
|
||||||
|
|
||||||
return( status);
|
return( status);
|
||||||
}
|
}
|
||||||
@ -2139,9 +2188,9 @@ DRT_Status DR_Kits_Load( DRT_Base *Base_Ptr)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* DR_Kits_Dump */
|
/* DR_Kits_Dump */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
DRT_Status DR_Kits_Dump( DRT_Base *Base_Ptr)
|
DRT_Status DR_Kits_Dump( DRT_Base *Base_Ptr)
|
||||||
{
|
{
|
||||||
@ -2155,12 +2204,12 @@ 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, "Sample Rate: (%d)\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)
|
||||||
{
|
{
|
||||||
printf( "ND_DataStruct_Info_Print() failed (%d) !\n", nd_status);
|
printf( "ND_DataStruct_Info_Print() failed (%d)!\n", nd_status);
|
||||||
return( DRS_KO);
|
return( DRS_KO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2177,7 +2226,7 @@ DRT_Status DR_Kits_Dump( DRT_Base *Base_Ptr)
|
|||||||
{
|
{
|
||||||
if( ( nd_status = ND_DataStruct_Traverse( Base_Ptr->Kit_DS_Ptr, (NDD_CMD_INDEX0_PRINT + index), stderr, &count)) != NDS_OK)
|
if( ( nd_status = ND_DataStruct_Traverse( Base_Ptr->Kit_DS_Ptr, (NDD_CMD_INDEX0_PRINT + index), stderr, &count)) != NDS_OK)
|
||||||
{
|
{
|
||||||
printf( "Can't dump kits: ND_DataStruct_Traverse() failed (%d) !\n", nd_status);
|
printf( "Can't dump kits: ND_DataStruct_Traverse() failed (%d)!\n", nd_status);
|
||||||
return( DRS_KO);
|
return( DRS_KO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2188,13 +2237,13 @@ DRT_Status DR_Kits_Dump( DRT_Base *Base_Ptr)
|
|||||||
|
|
||||||
if( ( nd_status = ND_DataStruct_Value_Print( stderr, Base_Ptr->Kit_DS_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0, &count)) != NDS_OK)
|
if( ( nd_status = ND_DataStruct_Value_Print( stderr, Base_Ptr->Kit_DS_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0, &count)) != NDS_OK)
|
||||||
{
|
{
|
||||||
printf( "Can't dump kits: ND_DataStruct_Value_Print() failed (%d) !\n", nd_status);
|
printf( "Can't dump kits: ND_DataStruct_Value_Print() failed (%d)!\n", nd_status);
|
||||||
return( DRS_KO);
|
return( DRS_KO);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ( nd_status = ND_DataStruct_Traverse( Base_Ptr->Kit_DS_Ptr, NDD_CMD_STATS_GET, &kit_count, &instrument_count, &layer_count, &sample_count)) != NDS_OK)
|
if( ( nd_status = ND_DataStruct_Traverse( Base_Ptr->Kit_DS_Ptr, NDD_CMD_STATS_GET, &kit_count, &instrument_count, &layer_count, &sample_count)) != NDS_OK)
|
||||||
{
|
{
|
||||||
printf( "Can't compute stats: ND_DataStruct_Traverse() failed (%d) !\n", nd_status);
|
printf( "Can't compute stats: ND_DataStruct_Traverse() failed (%d)!\n", nd_status);
|
||||||
return( DRS_KO);
|
return( DRS_KO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
214
datastruct.h
214
datastruct.h
@ -11,43 +11,49 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* Global definitions */
|
/* Global definitions */
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
typedef short DRT_Boolean;
|
|
||||||
|
|
||||||
#define DRD_FALSE ( DRT_Boolean) 0
|
|
||||||
#define DRD_TRUE ( DRT_Boolean) 1
|
|
||||||
|
|
||||||
#define DRD_NO 'n'
|
|
||||||
#define DRD_YES 'y'
|
|
||||||
|
|
||||||
#define DRD_MAX(A,B) (((A) < (B)) ? (B) : (A))
|
|
||||||
#define DRD_MIN(A,B) (((A) > (B)) ? (B) : (A))
|
|
||||||
|
|
||||||
#define NDD_CMD_STATS_GET ( NDT_Command) 65
|
#define NDD_CMD_STATS_GET ( NDT_Command) 65
|
||||||
#define NDD_CMD_SAMPLE_LOAD ( NDT_Command) 66
|
#define NDD_CMD_SAMPLE_LOAD ( NDT_Command) 66
|
||||||
#define NDD_CMD_SAMPLE_UNLOAD ( NDT_Command) 67
|
#define NDD_CMD_SAMPLE_UNLOAD ( NDT_Command) 67
|
||||||
#define NDD_CMD_INDEX0_PRINT ( NDT_Command) 68
|
#define NDD_CMD_INDEX0_PRINT ( NDT_Command) 68
|
||||||
#define NDD_CMD_INDEX1_PRINT ( NDT_Command) 69
|
#define NDD_CMD_INDEX1_PRINT ( NDT_Command) 69
|
||||||
|
|
||||||
#define NAME_LEN (short) 256
|
#define DRD_NAME_LEN (short) 256
|
||||||
#define NAME_SIZE (NAME_LEN + 1)
|
#define DRD_NAME_SIZE (DRD_NAME_LEN + 1)
|
||||||
#define DIRNAME_LEN (short) 1024
|
#define DRD_DIRNAME_LEN (short) 1024
|
||||||
#define DIRNAME_SIZE (DIRNAME_LEN)
|
#define DRD_DIRNAME_SIZE (DRD_DIRNAME_LEN)
|
||||||
#define FILENAME_LEN (short) 1024
|
#define DRD_FILENAME_LEN (short) 1024
|
||||||
#define FILENAME_SIZE (FILENAME_LEN)
|
#define DRD_FILENAME_SIZE (DRD_FILENAME_LEN)
|
||||||
#define DESC_LEN (short) 4096
|
#define DRD_DESC_LEN (short) 4096
|
||||||
#define DESC_SIZE (DESC_LEN + 1)
|
#define DRD_DESC_SIZE (DRD_DESC_LEN + 1)
|
||||||
|
|
||||||
typedef long DRT_Layer_Id;
|
typedef long DRT_Layer_Id;
|
||||||
|
|
||||||
typedef long DRT_Instrument_Id;
|
typedef long DRT_Instrument_Id;
|
||||||
typedef long DRT_Kit_Id;
|
|
||||||
|
typedef long DRT_Kit_Id;
|
||||||
|
typedef short DRT_Load_Status;
|
||||||
|
|
||||||
|
#define DRD_LOAD_STATUS_UNKNOWN ( DRT_Load_Status) 0
|
||||||
|
#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
|
||||||
|
|
||||||
|
#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_LOADED_IS( v) ( (v) == DRD_LOAD_STATUS_LOADED)
|
||||||
|
#define DR_LOAD_STATUS_VALUE_TRANSIENT_IS( v) ( (v) == DRD_LOAD_STATUS_TRANSIENT)
|
||||||
|
|
||||||
|
#define DR_LOAD_STATUS_UNKNOWN_IS( s) DR_LOAD_STATUS_VALUE_UNKNOWN_IS( (s)->Status)
|
||||||
|
#define DR_LOAD_STATUS_UNLOADED_IS( s) DR_LOAD_STATUS_VALUE_UNLOADED_IS( (s)->Status)
|
||||||
|
#define DR_LOAD_STATUS_LOADED_IS( s) DR_LOAD_STATUS_VALUE_LOADED_IS( (s)->Status)
|
||||||
|
#define DR_LOAD_STATUS_TRANSIENT_IS( s) DR_LOAD_STATUS_VALUE_TRANSIENT_IS( (s)->Status)
|
||||||
|
|
||||||
|
#define DR_LOAD_STATUS_VALUE_ASCII_GET( v) ( DR_LOAD_STATUS_VALUE_UNKNOWN_IS( (v)) ? "UNKNOWN" : ( DR_LOAD_STATUS_VALUE_UNLOADED_IS( (v)) ? "UNLOADED" : ( DR_LOAD_STATUS_VALUE_LOADED_IS( (v)) ? "LOADED" : ( DR_LOAD_STATUS_VALUE_TRANSIENT_IS( (v)) ? "TRANSIENT" : "???"))))
|
||||||
|
#define DR_LOAD_STATUS_ASCII_GET( s) DR_LOAD_STATUS_VALUE_ASCII_GET( (s)->Status)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -59,15 +65,16 @@ typedef long DRT_Kit_Id;
|
|||||||
|
|
||||||
typedef struct DRT_Layer
|
typedef struct DRT_Layer
|
||||||
{
|
{
|
||||||
DRT_Layer_Id Id;
|
DRT_Layer_Id Id;
|
||||||
char FileName[ FILENAME_SIZE];
|
DRT_Load_Status Status;
|
||||||
float *Sample_Ptr;
|
char FileName[ DRD_FILENAME_SIZE];
|
||||||
long Sample_Size;
|
float *Sample_Ptr;
|
||||||
SF_INFO *SF_Info_Ptr;
|
long Sample_Size;
|
||||||
double Min;
|
SF_INFO *SF_Info_Ptr;
|
||||||
double Max;
|
double Min;
|
||||||
double Gain;
|
double Max;
|
||||||
double Pitch;
|
double Gain;
|
||||||
|
double Pitch;
|
||||||
} DRT_Layer;
|
} DRT_Layer;
|
||||||
|
|
||||||
|
|
||||||
@ -75,7 +82,8 @@ typedef struct DRT_Layer
|
|||||||
typedef struct DRT_Instrument
|
typedef struct DRT_Instrument
|
||||||
{
|
{
|
||||||
DRT_Instrument_Id Id;
|
DRT_Instrument_Id Id;
|
||||||
char Name[ NAME_SIZE];
|
DRT_Load_Status Status;
|
||||||
|
char Name[ DRD_NAME_SIZE];
|
||||||
double Gain;
|
double Gain;
|
||||||
double Pan_Left;
|
double Pan_Left;
|
||||||
double Pan_Right;
|
double Pan_Right;
|
||||||
@ -86,11 +94,12 @@ typedef struct DRT_Instrument
|
|||||||
|
|
||||||
typedef struct DRT_Kit
|
typedef struct DRT_Kit
|
||||||
{
|
{
|
||||||
DRT_Kit_Id Id;
|
DRT_Kit_Id Id;
|
||||||
char Name[ NAME_SIZE];
|
DRT_Load_Status Status;
|
||||||
char Desc[ DESC_SIZE];
|
char Name[ DRD_NAME_SIZE];
|
||||||
char DirName[ DIRNAME_SIZE];
|
char Desc[ DRD_DESC_SIZE];
|
||||||
NDT_Root *Instrument_DS_Ptr;
|
char DirName[ DRD_DIRNAME_SIZE];
|
||||||
|
NDT_Root *Instrument_DS_Ptr;
|
||||||
} DRT_Kit;
|
} DRT_Kit;
|
||||||
|
|
||||||
|
|
||||||
@ -169,45 +178,45 @@ static NDT_Index_Type DRG_Kit_DS_Index_Tab_Final[DRD_KIT_DS_INDEX_NB] =
|
|||||||
/* XML XPATH Tags */
|
/* XML XPATH Tags */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#define STR(A) #A
|
#define DR_STR(A) #A
|
||||||
#define TAG(A) STR(A)
|
#define DR_TAG(A) DR_STR(A)
|
||||||
|
|
||||||
#define XML_XPATH_ELEMENT(A) *[local-name()=(A)]
|
#define DR_XML_XPATH_ELEMENT(A) *[local-name()=(A)]
|
||||||
#define XML_SLASH /
|
#define DRD_XML_SLASH /
|
||||||
|
|
||||||
#define XML_XPATH_DRUMKIT_BASE_TAG XML_XPATH_ELEMENT('drumkit_info')
|
#define DRD_XML_XPATH_DRUMKIT_BASE_TAG DR_XML_XPATH_ELEMENT('drumkit_info')
|
||||||
#define XML_XPATH_DRUMKIT_NAME_TAG XML_XPATH_ELEMENT('name')
|
#define DRD_XML_XPATH_DRUMKIT_NAME_TAG DR_XML_XPATH_ELEMENT('name')
|
||||||
#define XML_XPATH_DRUMKIT_INFO_TAG XML_XPATH_ELEMENT('info')
|
#define DRD_XML_XPATH_DRUMKIT_INFO_TAG DR_XML_XPATH_ELEMENT('info')
|
||||||
#define XML_XPATH_DRUMKIT_INSTRUMENTLIST_TAG XML_XPATH_ELEMENT('instrumentList')
|
#define DRD_XML_XPATH_DRUMKIT_INSTRUMENTLIST_TAG DR_XML_XPATH_ELEMENT('instrumentList')
|
||||||
#define XML_XPATH_DRUMKIT_INSTRUMENT_TAG XML_XPATH_ELEMENT('instrument')
|
#define DRD_XML_XPATH_DRUMKIT_INSTRUMENT_TAG DR_XML_XPATH_ELEMENT('instrument')
|
||||||
#define XML_XPATH_DRUMKIT_ID_TAG XML_XPATH_ELEMENT('id')
|
#define DRD_XML_XPATH_DRUMKIT_ID_TAG DR_XML_XPATH_ELEMENT('id')
|
||||||
#define XML_XPATH_DRUMKIT_GAIN_TAG XML_XPATH_ELEMENT('gain')
|
#define DRD_XML_XPATH_DRUMKIT_GAIN_TAG DR_XML_XPATH_ELEMENT('gain')
|
||||||
#define XML_XPATH_DRUMKIT_PAN_LEFT_TAG XML_XPATH_ELEMENT('pan_L')
|
#define DRD_XML_XPATH_DRUMKIT_PAN_LEFT_TAG DR_XML_XPATH_ELEMENT('pan_L')
|
||||||
#define XML_XPATH_DRUMKIT_PAN_RIGHT_TAG XML_XPATH_ELEMENT('pan_R')
|
#define DRD_XML_XPATH_DRUMKIT_PAN_RIGHT_TAG DR_XML_XPATH_ELEMENT('pan_R')
|
||||||
#define XML_XPATH_DRUMKIT_INSTRUMENTCOMPONENT_TAG XML_XPATH_ELEMENT('instrumentComponent')
|
#define DRD_XML_XPATH_DRUMKIT_INSTRUMENTCOMPONENT_TAG DR_XML_XPATH_ELEMENT('instrumentComponent')
|
||||||
#define XML_XPATH_DRUMKIT_LAYER_TAG XML_XPATH_ELEMENT('layer')
|
#define DRD_XML_XPATH_DRUMKIT_LAYER_TAG DR_XML_XPATH_ELEMENT('layer')
|
||||||
#define XML_XPATH_DRUMKIT_FILENAME_TAG XML_XPATH_ELEMENT('filename')
|
#define DRD_XML_XPATH_DRUMKIT_FILENAME_TAG DR_XML_XPATH_ELEMENT('filename')
|
||||||
#define XML_XPATH_DRUMKIT_MIN_TAG XML_XPATH_ELEMENT('min')
|
#define DRD_XML_XPATH_DRUMKIT_MIN_TAG DR_XML_XPATH_ELEMENT('min')
|
||||||
#define XML_XPATH_DRUMKIT_MAX_TAG XML_XPATH_ELEMENT('max')
|
#define DRD_XML_XPATH_DRUMKIT_MAX_TAG DR_XML_XPATH_ELEMENT('max')
|
||||||
#define XML_XPATH_DRUMKIT_PITCH_TAG XML_XPATH_ELEMENT('pitch')
|
#define DRD_XML_XPATH_DRUMKIT_PITCH_TAG DR_XML_XPATH_ELEMENT('pitch')
|
||||||
|
|
||||||
#define XML_XPATH_DRUMKIT_BASE_STR TAG(/XML_XPATH_DRUMKIT_BASE_TAG)
|
#define DRD_XML_XPATH_DRUMKIT_BASE_STR DR_TAG(/DRD_XML_XPATH_DRUMKIT_BASE_TAG)
|
||||||
#define XML_XPATH_DRUMKIT_NAME_STR TAG(/XML_XPATH_DRUMKIT_NAME_TAG)
|
#define DRD_XML_XPATH_DRUMKIT_NAME_STR DR_TAG(/DRD_XML_XPATH_DRUMKIT_NAME_TAG)
|
||||||
#define XML_XPATH_DRUMKIT_INFO_STR TAG(/XML_XPATH_DRUMKIT_INFO_TAG)
|
#define DRD_XML_XPATH_DRUMKIT_INFO_STR DR_TAG(/DRD_XML_XPATH_DRUMKIT_INFO_TAG)
|
||||||
#define XML_XPATH_DRUMKIT_ID_STR TAG(/XML_XPATH_DRUMKIT_ID_TAG)
|
#define DRD_XML_XPATH_DRUMKIT_ID_STR DR_TAG(/DRD_XML_XPATH_DRUMKIT_ID_TAG)
|
||||||
#define XML_XPATH_DRUMKIT_GAIN_STR TAG(/XML_XPATH_DRUMKIT_GAIN_TAG)
|
#define DRD_XML_XPATH_DRUMKIT_GAIN_STR DR_TAG(/DRD_XML_XPATH_DRUMKIT_GAIN_TAG)
|
||||||
#define XML_XPATH_DRUMKIT_PAN_LEFT_STR TAG(/XML_XPATH_DRUMKIT_PAN_LEFT_TAG)
|
#define DRD_XML_XPATH_DRUMKIT_PAN_LEFT_STR DR_TAG(/DRD_XML_XPATH_DRUMKIT_PAN_LEFT_TAG)
|
||||||
#define XML_XPATH_DRUMKIT_PAN_RIGHT_STR TAG(/XML_XPATH_DRUMKIT_PAN_RIGHT_TAG)
|
#define DRD_XML_XPATH_DRUMKIT_PAN_RIGHT_STR DR_TAG(/DRD_XML_XPATH_DRUMKIT_PAN_RIGHT_TAG)
|
||||||
#define XML_XPATH_DRUMKIT_FILENAME_STR TAG(/XML_XPATH_DRUMKIT_FILENAME_TAG)
|
#define DRD_XML_XPATH_DRUMKIT_FILENAME_STR DR_TAG(/DRD_XML_XPATH_DRUMKIT_FILENAME_TAG)
|
||||||
#define XML_XPATH_DRUMKIT_MIN_STR TAG(/XML_XPATH_DRUMKIT_MIN_TAG)
|
#define DRD_XML_XPATH_DRUMKIT_MIN_STR DR_TAG(/DRD_XML_XPATH_DRUMKIT_MIN_TAG)
|
||||||
#define XML_XPATH_DRUMKIT_MAX_STR TAG(/XML_XPATH_DRUMKIT_MAX_TAG)
|
#define DRD_XML_XPATH_DRUMKIT_MAX_STR DR_TAG(/DRD_XML_XPATH_DRUMKIT_MAX_TAG)
|
||||||
#define XML_XPATH_DRUMKIT_PITCH_STR TAG(/XML_XPATH_DRUMKIT_PITCH_TAG)
|
#define DRD_XML_XPATH_DRUMKIT_PITCH_STR DR_TAG(/DRD_XML_XPATH_DRUMKIT_PITCH_TAG)
|
||||||
|
|
||||||
#define XML_XPATH_DRUMKIT_KIT_NAME_FULL TAG(/XML_XPATH_DRUMKIT_BASE_TAG/XML_XPATH_DRUMKIT_NAME_TAG)
|
#define DRD_XML_XPATH_DRUMKIT_KIT_NAME_FULL DR_TAG(/DRD_XML_XPATH_DRUMKIT_BASE_TAG/DRD_XML_XPATH_DRUMKIT_NAME_TAG)
|
||||||
#define XML_XPATH_DRUMKIT_KIT_INFO_FULL TAG(/XML_XPATH_DRUMKIT_BASE_TAG/XML_XPATH_DRUMKIT_INFO_TAG)
|
#define DRD_XML_XPATH_DRUMKIT_KIT_INFO_FULL DR_TAG(/DRD_XML_XPATH_DRUMKIT_BASE_TAG/DRD_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 DRD_XML_XPATH_DRUMKIT_INSTRUMENT_FULL DR_TAG(/DRD_XML_XPATH_DRUMKIT_BASE_TAG/DRD_XML_XPATH_DRUMKIT_INSTRUMENTLIST_TAG/DRD_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 DRD_XML_XPATH_DRUMKIT_LAYER_FULL2 DR_TAG(/DRD_XML_XPATH_DRUMKIT_BASE_TAG/DRD_XML_XPATH_DRUMKIT_INSTRUMENTLIST_TAG/DRD_XML_XPATH_DRUMKIT_INSTRUMENT_TAG[%i]/DRD_XML_XPATH_DRUMKIT_INSTRUMENTCOMPONENT_TAG/DRD_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])
|
#define DRD_XML_XPATH_DRUMKIT_LAYER_FULL DR_TAG(/DRD_XML_XPATH_DRUMKIT_BASE_TAG/DRD_XML_XPATH_DRUMKIT_INSTRUMENTLIST_TAG/DRD_XML_XPATH_DRUMKIT_INSTRUMENT_TAG[%i]DRD_XML_SLASH/DRD_XML_XPATH_DRUMKIT_LAYER_TAG[%i])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -219,7 +228,8 @@ static NDT_Index_Type DRG_Kit_DS_Index_Tab_Final[DRD_KIT_DS_INDEX_NB] =
|
|||||||
// Quality of conversion for libsamplerate.
|
// Quality of conversion for libsamplerate.
|
||||||
// See http://www.mega-nerd.com/SRC/api_misc.html#Converters
|
// See http://www.mega-nerd.com/SRC/api_misc.html#Converters
|
||||||
// for info about availble qualities
|
// for info about availble qualities
|
||||||
#define RATE_CONV_QUALITY SRC_SINC_MEDIUM_QUALITY
|
//#define RATE_CONV_QUALITY SRC_SINC_BEST_QUALITY
|
||||||
|
#define DRD_RATE_CONV_QUALITY SRC_SINC_MEDIUM_QUALITY
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -229,13 +239,13 @@ static NDT_Index_Type DRG_Kit_DS_Index_Tab_Final[DRD_KIT_DS_INDEX_NB] =
|
|||||||
/* XML_Query */
|
/* XML_Query */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#define XML_QUERY_VALUE_UNKNOWN (short) 0
|
#define DRD_XML_QUERY_VALUE_UNKNOWN (short) 0
|
||||||
#define XML_QUERY_VALUE_STRING (short) 1
|
#define DRD_XML_QUERY_VALUE_STRING (short) 1
|
||||||
#define XML_QUERY_VALUE_INT (short) 2
|
#define DRD_XML_QUERY_VALUE_INT (short) 2
|
||||||
#define XML_QUERY_VALUE_LONG (short) 3
|
#define DRD_XML_QUERY_VALUE_LONG (short) 3
|
||||||
#define XML_QUERY_VALUE_LONGLONG (short) 4
|
#define DRD_XML_QUERY_VALUE_LONGLONG (short) 4
|
||||||
#define XML_QUERY_VALUE_FLOAT (short) 5
|
#define DRD_XML_QUERY_VALUE_FLOAT (short) 5
|
||||||
#define XML_QUERY_VALUE_DOUBLE (short) 6
|
#define DRD_XML_QUERY_VALUE_DOUBLE (short) 6
|
||||||
|
|
||||||
typedef struct DRT_XML_Query
|
typedef struct DRT_XML_Query
|
||||||
{
|
{
|
||||||
@ -250,29 +260,29 @@ typedef struct DRT_XML_Query
|
|||||||
|
|
||||||
DRT_XML_Query DRG_XML_Query_Tab_Layer[] =
|
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 },
|
{ "File Name", DRD_XML_XPATH_DRUMKIT_FILENAME_STR, DRD_XML_QUERY_VALUE_STRING, offsetof( DRT_Layer, FileName), DRD_FILENAME_LEN },
|
||||||
{ "Min", XML_XPATH_DRUMKIT_MIN_STR, XML_QUERY_VALUE_DOUBLE, offsetof( DRT_Layer, Min), 0 },
|
{ "Min", DRD_XML_XPATH_DRUMKIT_MIN_STR, DRD_XML_QUERY_VALUE_DOUBLE, offsetof( DRT_Layer, Min), 0 },
|
||||||
{ "Max", XML_XPATH_DRUMKIT_MAX_STR, XML_QUERY_VALUE_DOUBLE, offsetof( DRT_Layer, Max), 0 },
|
{ "Max", DRD_XML_XPATH_DRUMKIT_MAX_STR, DRD_XML_QUERY_VALUE_DOUBLE, offsetof( DRT_Layer, Max), 0 },
|
||||||
{ "Gain", XML_XPATH_DRUMKIT_GAIN_STR, XML_QUERY_VALUE_DOUBLE, offsetof( DRT_Layer, Gain), 0 },
|
{ "Gain", DRD_XML_XPATH_DRUMKIT_GAIN_STR, DRD_XML_QUERY_VALUE_DOUBLE, offsetof( DRT_Layer, Gain), 0 },
|
||||||
{ "Pitch", XML_XPATH_DRUMKIT_PITCH_STR, XML_QUERY_VALUE_DOUBLE, offsetof( DRT_Layer, Pitch), 0 },
|
{ "Pitch", DRD_XML_XPATH_DRUMKIT_PITCH_STR, DRD_XML_QUERY_VALUE_DOUBLE, offsetof( DRT_Layer, Pitch), 0 },
|
||||||
{ NULL, NULL, XML_QUERY_VALUE_UNKNOWN, 0, 0 }
|
{ NULL, NULL, DRD_XML_QUERY_VALUE_UNKNOWN, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
DRT_XML_Query DRG_XML_Query_Tab_Instrument[] =
|
DRT_XML_Query DRG_XML_Query_Tab_Instrument[] =
|
||||||
{
|
{
|
||||||
{ "Id", XML_XPATH_DRUMKIT_ID_STR, XML_QUERY_VALUE_LONG, offsetof( DRT_Instrument, Id), 0 },
|
{ "Id", DRD_XML_XPATH_DRUMKIT_ID_STR, DRD_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 },
|
{ "Name", DRD_XML_XPATH_DRUMKIT_NAME_STR, DRD_XML_QUERY_VALUE_STRING, offsetof( DRT_Instrument, Name), DRD_NAME_LEN },
|
||||||
{ "Gain", XML_XPATH_DRUMKIT_GAIN_STR, XML_QUERY_VALUE_DOUBLE, offsetof( DRT_Instrument, Gain), 0 },
|
{ "Gain", DRD_XML_XPATH_DRUMKIT_GAIN_STR, DRD_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_Left", DRD_XML_XPATH_DRUMKIT_PAN_LEFT_STR, DRD_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 },
|
{ "Pan_Right", DRD_XML_XPATH_DRUMKIT_PAN_RIGHT_STR, DRD_XML_QUERY_VALUE_DOUBLE, offsetof( DRT_Instrument, Pan_Right), 0 },
|
||||||
{ NULL, NULL, XML_QUERY_VALUE_UNKNOWN, 0, 0 }
|
{ NULL, NULL, DRD_XML_QUERY_VALUE_UNKNOWN, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
DRT_XML_Query DRG_XML_Query_Tab_Kit[] =
|
DRT_XML_Query DRG_XML_Query_Tab_Kit[] =
|
||||||
{
|
{
|
||||||
{ "File", XML_XPATH_DRUMKIT_NAME_STR, XML_QUERY_VALUE_STRING, offsetof( DRT_Kit, Name), NAME_LEN },
|
{ "File", DRD_XML_XPATH_DRUMKIT_NAME_STR, DRD_XML_QUERY_VALUE_STRING, offsetof( DRT_Kit, Name), DRD_NAME_LEN },
|
||||||
{ "Desc", XML_XPATH_DRUMKIT_INFO_STR, XML_QUERY_VALUE_STRING, offsetof( DRT_Kit, Desc), DESC_LEN },
|
{ "Desc", DRD_XML_XPATH_DRUMKIT_INFO_STR, DRD_XML_QUERY_VALUE_STRING, offsetof( DRT_Kit, Desc), DRD_DESC_LEN },
|
||||||
{ NULL, NULL, XML_QUERY_VALUE_UNKNOWN, 0, 0 }
|
{ NULL, NULL, DRD_XML_QUERY_VALUE_UNKNOWN, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
# endif // ifdef _DATASTRUCT_C_
|
# endif // ifdef _DATASTRUCT_C_
|
||||||
@ -331,7 +341,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 *, double);
|
extern DRT_Status DR_Kit_Sample_Load( DRT_Kit *, DRT_SampleRate);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -347,7 +357,7 @@ extern DRT_Status DR_Kit_Sample_UnLoad( DRT_Kit *);
|
|||||||
/* DR_DataStruct_Init */
|
/* DR_DataStruct_Init */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
extern DRT_Status DR_DataStruct_Init( DRT_Base *, double);
|
extern DRT_Status DR_DataStruct_Init( DRT_Base *, DRT_SampleRate);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -421,7 +431,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 *, double);
|
DRT_Status DR_Layer_Sample_Load( DRT_Layer *, DRT_Kit *, DRT_SampleRate);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -525,7 +535,7 @@ DRT_Status DR_Kit_Load( DRT_Base *, char *);
|
|||||||
/* DR_Kit_Sample_Load */
|
/* DR_Kit_Sample_Load */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
DRT_Status DR_Kit_Sample_Load( DRT_Kit *, double);
|
DRT_Status DR_Kit_Sample_Load( DRT_Kit *, DRT_SampleRate);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -541,7 +551,7 @@ DRT_Status DR_Kit_Sample_UnLoad( DRT_Kit *);
|
|||||||
/* DR_DataStruct_Init */
|
/* DR_DataStruct_Init */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
DRT_Status DR_DataStruct_Init( DRT_Base *, double);
|
DRT_Status DR_DataStruct_Init( DRT_Base *, DRT_SampleRate);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
14
drummer.h
14
drummer.h
@ -45,8 +45,8 @@ typedef short DRT_Boolean;
|
|||||||
#define DRD_NO 'n'
|
#define DRD_NO 'n'
|
||||||
#define DRD_YES 'y'
|
#define DRD_YES 'y'
|
||||||
|
|
||||||
#define DRD_MAX(A,B) (((A) < (B)) ? (B) : (A))
|
#define DR_MAX(A,B) (((A) < (B)) ? (B) : (A))
|
||||||
#define DRD_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
|
||||||
|
|
||||||
@ -78,10 +78,12 @@ typedef short DRT_Status;
|
|||||||
/* DRT_Base */
|
/* DRT_Base */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
typedef int DRT_SampleRate;
|
||||||
|
|
||||||
typedef struct DRT_Base
|
typedef struct DRT_Base
|
||||||
{
|
{
|
||||||
NDT_Root *Kit_DS_Ptr;
|
NDT_Root *Kit_DS_Ptr;
|
||||||
double SampleRate;
|
DRT_SampleRate SampleRate;
|
||||||
} DRT_Base;
|
} DRT_Base;
|
||||||
|
|
||||||
|
|
||||||
@ -96,7 +98,7 @@ typedef struct DRT_Base
|
|||||||
/* DR_Init */
|
/* DR_Init */
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
DRT_Status DRT_Init( DRT_Base *);
|
DRT_Status DR_Init( DRT_Base *);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -104,7 +106,7 @@ DRT_Status DRT_Init( DRT_Base *);
|
|||||||
/* DeInit */
|
/* DeInit */
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
DRT_Status DRT_DeInit( DRT_Base *);
|
DRT_Status DR_DeInit( DRT_Base *);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
234
lv2_plugin.c
234
lv2_plugin.c
@ -17,6 +17,108 @@ static int current_kit_changed = 0;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------------*/
|
||||||
|
/* */
|
||||||
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
DRT_Status DR_LV2_Kit_Sample_Load( DRT_LV2_Base *LV2_Base_Ptr, DRT_Kit *Kit_Ptr)
|
||||||
|
{
|
||||||
|
DRT_Status status;
|
||||||
|
NDT_Node *cur_node_ptr;
|
||||||
|
int sample_id = 0;
|
||||||
|
|
||||||
|
|
||||||
|
if( Kit_Ptr != NULL)
|
||||||
|
{
|
||||||
|
// 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)
|
||||||
|
{
|
||||||
|
LV2_Base_Ptr->Kit_Cur_Ptr = Kit_Ptr;
|
||||||
|
|
||||||
|
cur_node_ptr = Kit_Ptr->Instrument_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Head;
|
||||||
|
|
||||||
|
pthread_mutex_lock( &( LV2_Base_Ptr->Load_Mutex));
|
||||||
|
|
||||||
|
for( sample_id = 0; sample_id < DRD_PORT_NUMBER_MAX; sample_id++)
|
||||||
|
{
|
||||||
|
LV2_Base_Ptr->Samples[sample_id].Active = 0;
|
||||||
|
LV2_Base_Ptr->Samples[sample_id].Offset = 0;
|
||||||
|
LV2_Base_Ptr->Samples[sample_id].Limit = 0;
|
||||||
|
LV2_Base_Ptr->Samples[sample_id].Velocity = 0;
|
||||||
|
LV2_Base_Ptr->Samples[sample_id].Layer_Ptr = 0;
|
||||||
|
LV2_Base_Ptr->Samples[sample_id].Data_Ptr = NULL;
|
||||||
|
LV2_Base_Ptr->Samples[sample_id].Data_Offset = 0;
|
||||||
|
|
||||||
|
if( cur_node_ptr == NULL)
|
||||||
|
{
|
||||||
|
// fprintf( stderr, "Skip sample\n");
|
||||||
|
LV2_Base_Ptr->Samples[sample_id].Instrument_Ptr = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LV2_Base_Ptr->Samples[sample_id].Instrument_Ptr = (DRT_Instrument *)cur_node_ptr->Value;
|
||||||
|
cur_node_ptr = cur_node_ptr->Right;
|
||||||
|
|
||||||
|
// fprintf( stderr, "Add sample: [%s]\n", LV2_Base_Ptr->Samples[sample_id].Instrument_Ptr->Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
fprintf( stderr, "Loaded: (%d) samples!\n", LV2_Base_Ptr->Sample_Number);
|
||||||
|
|
||||||
|
// DR_Kit_Dump( Kit_Ptr, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return( status);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------------*/
|
||||||
|
/* */
|
||||||
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
DRT_Status DR_LV2_CurKit_Sample_Load( DRT_LV2_Base *LV2_Base_Ptr)
|
||||||
|
{
|
||||||
|
DRT_Status status;
|
||||||
|
DRT_Kit *Kit_Ptr;
|
||||||
|
DRT_Kit_Id kit_id;
|
||||||
|
|
||||||
|
|
||||||
|
kit_id = ( LV2_Base_Ptr->Bank_Id_LSB_New * 128 + LV2_Base_Ptr->Bank_Id_MSB_New) * 128 + LV2_Base_Ptr->Program_Id_New;
|
||||||
|
|
||||||
|
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);
|
||||||
|
status = DRS_OK;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( ( status = DR_Kit_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);
|
||||||
|
|
||||||
|
LV2_Base_Ptr->Bank_Id_LSB = LV2_Base_Ptr->Bank_Id_LSB_New;
|
||||||
|
LV2_Base_Ptr->Bank_Id_MSB = LV2_Base_Ptr->Bank_Id_MSB_New;
|
||||||
|
LV2_Base_Ptr->Program_Id = LV2_Base_Ptr->Program_Id_New;
|
||||||
|
LV2_Base_Ptr->Kit_Id = kit_id;
|
||||||
|
LV2_Base_Ptr->Kit_Cur_Ptr = Kit_Ptr;
|
||||||
|
|
||||||
|
status = DR_LV2_Kit_Sample_Load( LV2_Base_Ptr, Kit_Ptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return( status);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* */
|
/* */
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
@ -24,25 +126,30 @@ static int current_kit_changed = 0;
|
|||||||
static void *DR_LV2_Load_Thread( DRT_LV2_Base *LV2_Base_Ptr)
|
static void *DR_LV2_Load_Thread( DRT_LV2_Base *LV2_Base_Ptr)
|
||||||
{
|
{
|
||||||
|
|
||||||
// drmr_sample *loaded_samples,*old_samples;
|
DRT_Status status;
|
||||||
DRT_Sample *loaded_samples = NULL, *old_samples = NULL;
|
|
||||||
int loaded_count, old_scount;
|
|
||||||
char *request, *request_orig;
|
|
||||||
|
|
||||||
|
|
||||||
fprintf( stderr, "Start Load Thread!\n");
|
fprintf( stderr, "Start Load Thread!\n");
|
||||||
|
|
||||||
return(0);
|
|
||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock( &( LV2_Base_Ptr->Load_Mutex));
|
pthread_mutex_lock( &( LV2_Base_Ptr->Load_Mutex));
|
||||||
pthread_cond_wait( &( LV2_Base_Ptr->Load_Cond), &( LV2_Base_Ptr->Load_Mutex));
|
pthread_cond_wait( &( LV2_Base_Ptr->Load_Cond), &( LV2_Base_Ptr->Load_Mutex));
|
||||||
|
|
||||||
fprintf( stderr, "Load_Thread: New load!\n");
|
fprintf( stderr, "Load_Thread: New load!\n");
|
||||||
|
|
||||||
pthread_mutex_unlock( &(LV2_Base_Ptr->Load_Mutex));
|
pthread_mutex_unlock( &(LV2_Base_Ptr->Load_Mutex));
|
||||||
|
|
||||||
|
if( ( status = DR_LV2_CurKit_Sample_Load( LV2_Base_Ptr)) != DRS_OK)
|
||||||
|
{
|
||||||
|
fprintf( stderr, "Can't load kit sample (%d) !", status);
|
||||||
|
}
|
||||||
|
|
||||||
|
pthread_mutex_lock( &(LV2_Base_Ptr->Load_Mutex));
|
||||||
|
pthread_mutex_unlock( &(LV2_Base_Ptr->Load_Mutex));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
// old_samples = LV2_Base_Ptr->Samples;
|
// old_samples = LV2_Base_Ptr->Samples;
|
||||||
// old_scount = LV2_Base_Ptr->Num_Samples;
|
// old_scount = LV2_Base_Ptr->Num_Samples;
|
||||||
|
|
||||||
@ -83,6 +190,7 @@ static void *DR_LV2_Load_Thread( DRT_LV2_Base *LV2_Base_Ptr)
|
|||||||
|
|
||||||
LV2_Base_Ptr->Current_Path = request_orig;
|
LV2_Base_Ptr->Current_Path = request_orig;
|
||||||
current_kit_changed = 1;
|
current_kit_changed = 1;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -172,104 +280,6 @@ static inline LV2_Atom *DR_LV2_Message_Midi_Info_Build( DRT_LV2_Base *LV2_Base
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
|
||||||
/* */
|
|
||||||
/*----------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
DRT_Status DR_LV2_Kit_Sample_Load( DRT_LV2_Base *LV2_Base_Ptr, DRT_Kit *Kit_Ptr)
|
|
||||||
{
|
|
||||||
DRT_Status status;
|
|
||||||
NDT_Node *cur_node_ptr;
|
|
||||||
int sample_id = 0;
|
|
||||||
|
|
||||||
|
|
||||||
if( Kit_Ptr != NULL)
|
|
||||||
{
|
|
||||||
fprintf( stderr, "Sample Rate: (%lf)\n", LV2_Base_Ptr->Base.SampleRate);
|
|
||||||
|
|
||||||
if( ( status = DR_Kit_Sample_Load( Kit_Ptr, LV2_Base_Ptr->Base.SampleRate)) == DRS_OK)
|
|
||||||
{
|
|
||||||
LV2_Base_Ptr->Kit_Cur_Ptr = Kit_Ptr;
|
|
||||||
|
|
||||||
cur_node_ptr = Kit_Ptr->Instrument_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Head;
|
|
||||||
|
|
||||||
for( sample_id = 0; sample_id < DRD_PORT_NUMBER_MAX; sample_id++)
|
|
||||||
{
|
|
||||||
LV2_Base_Ptr->Samples[sample_id].Active = 0;
|
|
||||||
LV2_Base_Ptr->Samples[sample_id].Offset = 0;
|
|
||||||
LV2_Base_Ptr->Samples[sample_id].Limit = 0;
|
|
||||||
LV2_Base_Ptr->Samples[sample_id].Velocity = 0;
|
|
||||||
LV2_Base_Ptr->Samples[sample_id].Layer_Ptr = 0;
|
|
||||||
LV2_Base_Ptr->Samples[sample_id].Data_Ptr = NULL;
|
|
||||||
LV2_Base_Ptr->Samples[sample_id].Data_Offset = 0;
|
|
||||||
|
|
||||||
if( cur_node_ptr == NULL)
|
|
||||||
{
|
|
||||||
fprintf( stderr, "Skip sample\n");
|
|
||||||
LV2_Base_Ptr->Samples[sample_id].Instrument_Ptr = NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LV2_Base_Ptr->Samples[sample_id].Instrument_Ptr = (DRT_Instrument *)cur_node_ptr->Value;
|
|
||||||
cur_node_ptr = cur_node_ptr->Right;
|
|
||||||
|
|
||||||
fprintf( stderr, "Add sample: [%s]\n", LV2_Base_Ptr->Samples[sample_id].Instrument_Ptr->Name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
DR_Kit_Dump( Kit_Ptr, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return( status);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
|
||||||
/* */
|
|
||||||
/*----------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
DRT_Status DR_LV2_CurKit_Sample_Load( DRT_LV2_Base *LV2_Base_Ptr)
|
|
||||||
{
|
|
||||||
DRT_Status status;
|
|
||||||
DRT_Kit *Kit_Ptr;
|
|
||||||
DRT_Kit_Id kit_id;
|
|
||||||
|
|
||||||
|
|
||||||
kit_id = ( LV2_Base_Ptr->Bank_Id_LSB_New * 128 + LV2_Base_Ptr->Bank_Id_MSB_New) * 128 + LV2_Base_Ptr->Program_Id_New;
|
|
||||||
|
|
||||||
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);
|
|
||||||
status = DRS_OK;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if( ( status = DR_Kit_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);
|
|
||||||
|
|
||||||
LV2_Base_Ptr->Bank_Id_LSB = LV2_Base_Ptr->Bank_Id_LSB_New;
|
|
||||||
LV2_Base_Ptr->Bank_Id_MSB = LV2_Base_Ptr->Bank_Id_MSB_New;
|
|
||||||
LV2_Base_Ptr->Program_Id = LV2_Base_Ptr->Program_Id_New;
|
|
||||||
LV2_Base_Ptr->Kit_Id = kit_id;
|
|
||||||
LV2_Base_Ptr->Kit_Cur_Ptr = Kit_Ptr;
|
|
||||||
|
|
||||||
status = DR_LV2_Kit_Sample_Load( LV2_Base_Ptr, Kit_Ptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return( status);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* */
|
/* */
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
@ -445,7 +455,7 @@ static inline void DR_Sample_Untrigger( DRT_LV2_Base *LV2_Base_Ptr, int Sampl
|
|||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
static LV2_Handle DR_LV2_Instantiate( const LV2_Descriptor *LV2_Descriptor_Ptr,
|
static LV2_Handle DR_LV2_Instantiate( const LV2_Descriptor *LV2_Descriptor_Ptr,
|
||||||
double Rate,
|
double SampleRate,
|
||||||
const char *Bundle_Path,
|
const char *Bundle_Path,
|
||||||
const LV2_Feature* const *LV2_Features_Ptr)
|
const LV2_Feature* const *LV2_Features_Ptr)
|
||||||
{
|
{
|
||||||
@ -559,7 +569,7 @@ 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), Rate)) != DRS_OK)
|
if( ( status = DR_DataStruct_Init( &( lv2_base_ptr->Base), (DRT_SampleRate)SampleRate)) != DRS_OK)
|
||||||
{
|
{
|
||||||
fprintf( stderr, "Can't init data structures (%d) !", status);
|
fprintf( stderr, "Can't init data structures (%d) !", status);
|
||||||
}
|
}
|
||||||
@ -795,11 +805,15 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples)
|
|||||||
|
|
||||||
lv2_base_ptr->Program_Id_New = value;
|
lv2_base_ptr->Program_Id_New = value;
|
||||||
|
|
||||||
|
pthread_cond_signal( &( lv2_base_ptr->Load_Cond));
|
||||||
|
|
||||||
|
/*
|
||||||
if( ( status = DR_LV2_CurKit_Sample_Load( lv2_base_ptr)) != DRS_OK)
|
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) !", status);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
int reqpos = ( lv2_base_ptr->CurReq + 1) % DRD_REQ_BUF_SIZE;
|
int reqpos = ( lv2_base_ptr->CurReq + 1) % DRD_REQ_BUF_SIZE;
|
||||||
char *tmp = NULL;
|
char *tmp = NULL;
|
||||||
@ -955,7 +969,7 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples)
|
|||||||
lv2_base_ptr->Master_Right[j] = 0.0f;
|
lv2_base_ptr->Master_Right[j] = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
for( i = 0; i < lv2_base_ptr->Sample_Number; i++)
|
for( i = 0; i < DR_MIN( lv2_base_ptr->Sample_Number, 32); i++)
|
||||||
{
|
{
|
||||||
int pos,lim;
|
int pos,lim;
|
||||||
DRT_Sample *cur_sample = lv2_base_ptr->Samples + i;
|
DRT_Sample *cur_sample = lv2_base_ptr->Samples + i;
|
||||||
|
Loading…
Reference in New Issue
Block a user