2022-03-20 23:46:24 +01:00
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
/* Includes */
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
#define _IMRD_C_
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <drummer.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
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)
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
|
|
|
NDT_Command_Name Command_Name;
|
|
|
|
|
|
|
|
|
|
|
|
switch( Command)
|
|
|
|
{
|
|
|
|
case NDD_CMD_MANAGER_VERSION:
|
|
|
|
{
|
|
|
|
ND_VA_ARG_GET( Version_Name_Ptr, *Args_Ptr, NDT_Version_Name *);
|
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_MANAGER_VERSION";
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
*Version_Name_Ptr = "$Revision: 1.0 $ $Name: Layer_Manager $ $Date: 2021/12/12 21:27:12 $ $Author: agibert $";
|
2022-03-20 23:46:24 +01:00
|
|
|
|
|
|
|
return( NDS_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_INDEX_GET:
|
|
|
|
{
|
|
|
|
ND_VA_ARG_GET( Reply_Index_Id_Ptr, *Args_Ptr, NDT_Index_Id *);
|
|
|
|
ND_VA_ARG_GET( Reply_Command_Ptr, *Args_Ptr, NDT_Command *);
|
|
|
|
ND_VA_ARG_GET( Cmd, *Args_Ptr, NDT_Command);
|
2022-03-23 22:57:26 +01:00
|
|
|
ND_VA_ARG_GET( Layer_Ptr, *Args_Ptr, DRT_Layer *);
|
2022-03-20 23:46:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_INDEX_GET";
|
|
|
|
|
|
|
|
switch(Cmd)
|
|
|
|
{
|
|
|
|
case NDD_CMD_INDEX0_PRINT:
|
|
|
|
{
|
|
|
|
*Reply_Index_Id_Ptr = 0;
|
|
|
|
*Reply_Command_Ptr = Cmd;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_INDEX1_PRINT:
|
|
|
|
{
|
|
|
|
*Reply_Index_Id_Ptr = 1;
|
|
|
|
*Reply_Command_Ptr = Cmd;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
*Reply_Index_Id_Ptr = Index_Id;
|
|
|
|
*Reply_Command_Ptr = Cmd;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return( NDS_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_VALUE_ALLOC:
|
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
ND_VA_ARG_GET( Layer_Ptr_Ptr, *Args_Ptr, DRT_Layer **);
|
2022-03-20 23:46:24 +01:00
|
|
|
|
|
|
|
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
|
2022-03-23 22:57:26 +01:00
|
|
|
ND_VA_ARG_GET( Layer_Template_Ptr, user_args, DRT_Layer *);
|
2022-03-20 23:46:24 +01:00
|
|
|
|
|
|
|
ND_VA_LIST_CLOSE( user_args);
|
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_VALUE_ALLOC";
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
if( ( *Layer_Ptr_Ptr = (DRT_Layer *)malloc( sizeof( DRT_Layer))) != NULL)
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
( *Layer_Ptr_Ptr)->Id = Root_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Node_Number;
|
2022-03-20 23:46:24 +01:00
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
strncpy( ( *Layer_Ptr_Ptr)->FileName, Layer_Template_Ptr->FileName, FILENAME_SIZE);
|
|
|
|
|
|
|
|
( *Layer_Ptr_Ptr)->Sample_Ptr = Layer_Template_Ptr->Sample_Ptr;
|
|
|
|
( *Layer_Ptr_Ptr)->Sample_Size = Layer_Template_Ptr->Sample_Size;
|
|
|
|
( *Layer_Ptr_Ptr)->Min = Layer_Template_Ptr->Min;
|
|
|
|
( *Layer_Ptr_Ptr)->Max = Layer_Template_Ptr->Max;
|
|
|
|
( *Layer_Ptr_Ptr)->Gain = Layer_Template_Ptr->Gain;
|
|
|
|
( *Layer_Ptr_Ptr)->Pitch = Layer_Template_Ptr->Pitch;
|
2022-03-20 23:46:24 +01:00
|
|
|
|
|
|
|
return( NDS_OK);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return( NDS_KO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_VALUE_FREE:
|
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
ND_VA_ARG_GET( Layer_Ptr, *Args_Ptr, DRT_Layer *);
|
2022-03-20 23:46:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_VALUE_FREE";
|
|
|
|
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
free( Layer_Ptr);
|
2022-03-20 23:46:24 +01:00
|
|
|
|
|
|
|
return( NDS_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_VALUE_COMP:
|
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
ND_VA_ARG_GET( Layer1_Ptr, *Args_Ptr, DRT_Layer *);
|
|
|
|
ND_VA_ARG_GET( Layer2_Ptr, *Args_Ptr, DRT_Layer *);
|
2022-03-20 23:46:24 +01:00
|
|
|
|
|
|
|
long rc;
|
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_VALUE_COMP";
|
|
|
|
|
|
|
|
switch( Index_Id)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
rc = Layer1_Ptr->Id - Layer2_Ptr->Id;
|
2022-03-20 23:46:24 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
rc = strcmp( Layer1_Ptr->FileName, Layer2_Ptr->FileName);
|
2022-03-20 23:46:24 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
printf( "Unknown COMP idx (%d) !\n", Index_Id);
|
|
|
|
return( NDS_KO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( rc < 0)
|
|
|
|
{
|
|
|
|
return( NDS_LOWER);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( rc > 0)
|
|
|
|
{
|
|
|
|
return( NDS_GREATER);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return( NDS_EQUAL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_VALUE_ADD:
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
ND_VA_ARG_GET( Value_Ptr, *Args_Ptr, void *);
|
|
|
|
|
|
|
|
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
|
|
|
|
|
|
|
|
ND_VA_ARG_GET( user_data, user_args, user_type);
|
|
|
|
ND_VA_ARG_GET( ..., user_args, ...);
|
|
|
|
|
|
|
|
ND_VA_LIST_CLOSE( user_args);
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_VALUE_ADD";
|
|
|
|
|
|
|
|
return( NDS_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_VALUE_REMOVE:
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
ND_VA_ARG_GET( Value_Ptr, *Args_Ptr, void *);
|
|
|
|
|
|
|
|
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
|
|
|
|
|
|
|
|
ND_VA_ARG_GET( user_data, user_args, user_type);
|
|
|
|
ND_VA_ARG_GET( ..., user_args, ...);
|
|
|
|
|
|
|
|
ND_VA_LIST_CLOSE( user_args);
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_VALUE_REMOVE";
|
|
|
|
|
|
|
|
return( NDS_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_VALUE_PRINT:
|
|
|
|
{
|
|
|
|
ND_VA_ARG_GET( Next_Node_Ptr, *Args_Ptr, NDT_Node *);
|
|
|
|
|
|
|
|
ND_VA_LIST_OPEN( lib_args, *Args_Ptr);
|
|
|
|
|
|
|
|
ND_VA_ARG_GET( Out, lib_args, FILE *);
|
|
|
|
ND_VA_ARG_GET( Recursive_Mode, lib_args, NDT_Recursive_Mode);
|
|
|
|
ND_VA_ARG_GET( Recursive_Depth, lib_args, NDT_Recursive_Depth);
|
|
|
|
ND_VA_ARG_GET( Recursive_Offset, lib_args, NDT_Recursive_Offset);
|
|
|
|
|
|
|
|
ND_VA_LIST_OPEN( user_args, lib_args);
|
|
|
|
|
|
|
|
ND_VA_ARG_GET( Count_Ptr, user_args, long *);
|
|
|
|
|
|
|
|
ND_VA_LIST_CLOSE( user_args);
|
|
|
|
ND_VA_LIST_CLOSE( lib_args);
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
DRT_Layer *Layer_Ptr = Node_Ptr->Value;
|
2022-03-20 23:46:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_VALUE_PRINT";
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
if( DR_Layer_Dump( Layer_Ptr, ++(*Count_Ptr)) != DRS_OK)
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
|
|
|
return( NDS_KO);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return( NDS_OK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_INFO_PRINT:
|
|
|
|
{
|
|
|
|
Command_Name = "NDD_CMD_INFO_PRINT";
|
|
|
|
|
|
|
|
return( NDS_OK);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_INDEX0_PRINT:
|
|
|
|
case NDD_CMD_INDEX1_PRINT:
|
|
|
|
{
|
|
|
|
ND_VA_ARG_GET( Next_Node_Ptr, *Args_Ptr, NDT_Node *);
|
|
|
|
|
|
|
|
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
|
|
|
|
|
|
|
|
ND_VA_ARG_GET( Out, user_args, FILE *);
|
|
|
|
ND_VA_ARG_GET( Count_Ptr, user_args, long *);
|
|
|
|
|
|
|
|
ND_VA_LIST_CLOSE( user_args);
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
DRT_Layer *Layer_Ptr = Node_Ptr->Value;
|
2022-03-20 23:46:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_INDEX_PRINT";
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
if( DR_Layer_Dump( Layer_Ptr, ++(*Count_Ptr)) != DRS_OK)
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
|
|
|
return( NDS_KO);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return( NDS_OK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
case NDD_CMD_SAMPLE_LOAD:
|
|
|
|
{
|
|
|
|
ND_VA_ARG_GET( Next_Node_Ptr, *Args_Ptr, NDT_Node *);
|
2022-03-20 23:46:24 +01:00
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
|
2022-03-20 23:46:24 +01:00
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
ND_VA_ARG_GET( Kit_Ptr, user_args, DRT_Kit *);
|
|
|
|
ND_VA_ARG_GET( SampleRate, user_args, double);
|
2022-03-20 23:46:24 +01:00
|
|
|
|
|
|
|
ND_VA_LIST_CLOSE( user_args);
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
DRT_Layer *Layer_Ptr = Node_Ptr->Value;
|
2022-03-20 23:46:24 +01:00
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_SAMPLE_LOAD";
|
2022-03-20 23:46:24 +01:00
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
if( DR_Layer_Sample_Load( Layer_Ptr, Kit_Ptr, SampleRate) != DRS_OK)
|
|
|
|
{
|
|
|
|
return( NDS_KO);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return( NDS_OK);
|
|
|
|
}
|
|
|
|
}
|
2022-03-20 23:46:24 +01:00
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
default:
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
printf( "Layer_Manager() called with an undefined command %d\n", Command);
|
2022-03-20 23:46:24 +01:00
|
|
|
return( NDS_ERRAPI);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
printf( "Layer_Manager() called with command %d (%s)\n", Command, Command_Name);
|
2022-03-20 23:46:24 +01:00
|
|
|
return( NDS_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
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)
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
|
|
|
NDT_Command_Name Command_Name;
|
|
|
|
|
|
|
|
|
|
|
|
switch( Command)
|
|
|
|
{
|
|
|
|
case NDD_CMD_MANAGER_VERSION:
|
|
|
|
{
|
|
|
|
ND_VA_ARG_GET( Version_Name_Ptr, *Args_Ptr, NDT_Version_Name *);
|
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_MANAGER_VERSION";
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
*Version_Name_Ptr = "$Revision: 1.0 $ $Name: Instrument_Manager $ $Date: 2021/12/12 21:27:12 $ $Author: agibert $";
|
2022-03-20 23:46:24 +01:00
|
|
|
|
|
|
|
return( NDS_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_INDEX_GET:
|
|
|
|
{
|
|
|
|
ND_VA_ARG_GET( Reply_Index_Id_Ptr, *Args_Ptr, NDT_Index_Id *);
|
|
|
|
ND_VA_ARG_GET( Reply_Command_Ptr, *Args_Ptr, NDT_Command *);
|
|
|
|
ND_VA_ARG_GET( Cmd, *Args_Ptr, NDT_Command);
|
2022-03-23 22:57:26 +01:00
|
|
|
ND_VA_ARG_GET( Instrument_Ptr, *Args_Ptr, DRT_Instrument *);
|
2022-03-20 23:46:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_INDEX_GET";
|
|
|
|
|
|
|
|
switch(Cmd)
|
|
|
|
{
|
|
|
|
case NDD_CMD_INDEX0_PRINT:
|
|
|
|
{
|
|
|
|
*Reply_Index_Id_Ptr = 0;
|
|
|
|
*Reply_Command_Ptr = Cmd;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_INDEX1_PRINT:
|
|
|
|
{
|
|
|
|
*Reply_Index_Id_Ptr = 1;
|
|
|
|
*Reply_Command_Ptr = Cmd;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
*Reply_Index_Id_Ptr = Index_Id;
|
|
|
|
*Reply_Command_Ptr = Cmd;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return( NDS_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_VALUE_ALLOC:
|
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
ND_VA_ARG_GET( Instrument_Ptr_Ptr, *Args_Ptr, DRT_Instrument **);
|
2022-03-20 23:46:24 +01:00
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
|
|
|
|
ND_VA_ARG_GET( Instrument_Template_Ptr, user_args, DRT_Instrument *);
|
2022-03-20 23:46:24 +01:00
|
|
|
|
|
|
|
ND_VA_LIST_CLOSE( user_args);
|
|
|
|
|
|
|
|
NDT_Status nd_status;
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
|
2022-03-20 23:46:24 +01:00
|
|
|
Command_Name = "NDD_CMD_VALUE_ALLOC";
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
if( ( *Instrument_Ptr_Ptr = (DRT_Instrument *)malloc( sizeof( DRT_Instrument))) != NULL)
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
( *Instrument_Ptr_Ptr)->Id = Root_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Node_Number;
|
|
|
|
|
|
|
|
strncpy( ( *Instrument_Ptr_Ptr)->Name, Instrument_Template_Ptr->Name, NAME_SIZE);
|
2022-03-20 23:46:24 +01:00
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
( *Instrument_Ptr_Ptr)->Gain = Instrument_Template_Ptr->Gain;
|
|
|
|
( *Instrument_Ptr_Ptr)->Pan_Left = Instrument_Template_Ptr->Pan_Left;
|
|
|
|
( *Instrument_Ptr_Ptr)->Pan_Right = Instrument_Template_Ptr->Pan_Right;
|
2022-03-20 23:46:24 +01:00
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
|
|
|
|
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)
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
|
|
|
printf( "DR_Instrument_Manager: ND_DataStruct_Open() failed (%d) !\n", nd_status);
|
|
|
|
return( NDS_KO);
|
|
|
|
}
|
2022-03-23 22:57:26 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return( NDS_OK);
|
|
|
|
}
|
2022-03-20 23:46:24 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return( NDS_KO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_VALUE_FREE:
|
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
ND_VA_ARG_GET( Instrument_Ptr, *Args_Ptr, DRT_Instrument *);
|
2022-03-20 23:46:24 +01:00
|
|
|
|
|
|
|
NDT_Status nd_status;
|
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_VALUE_FREE";
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
if( ( nd_status = ND_DataStruct_Close( Instrument_Ptr->Layer_DS_Ptr)) != NDS_OK)
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
printf( "DR_Instrument_Manager: Can't close Kit_DS (%d)!\n", nd_status);
|
2022-03-20 23:46:24 +01:00
|
|
|
return( DRS_KO);
|
|
|
|
}
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
free( Instrument_Ptr);
|
2022-03-20 23:46:24 +01:00
|
|
|
|
|
|
|
return( NDS_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_VALUE_COMP:
|
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
ND_VA_ARG_GET( Instrument1_Ptr, *Args_Ptr, DRT_Instrument *);
|
|
|
|
ND_VA_ARG_GET( Instrument2_Ptr, *Args_Ptr, DRT_Instrument *);
|
2022-03-20 23:46:24 +01:00
|
|
|
|
|
|
|
long rc;
|
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_VALUE_COMP";
|
|
|
|
|
|
|
|
switch( Index_Id)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
rc = Instrument1_Ptr->Id - Instrument2_Ptr->Id;
|
2022-03-20 23:46:24 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
rc = strcmp( Instrument1_Ptr->Name, Instrument2_Ptr->Name);
|
2022-03-20 23:46:24 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
printf( "Unknown COMP idx (%d) !\n", Index_Id);
|
|
|
|
return( NDS_KO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( rc < 0)
|
|
|
|
{
|
|
|
|
return( NDS_LOWER);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( rc > 0)
|
|
|
|
{
|
|
|
|
return( NDS_GREATER);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return( NDS_EQUAL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_VALUE_ADD:
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
ND_VA_ARG_GET( Value_Ptr, *Args_Ptr, void *);
|
|
|
|
|
|
|
|
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
|
|
|
|
|
|
|
|
ND_VA_ARG_GET( user_data, user_args, user_type);
|
|
|
|
ND_VA_ARG_GET( ..., user_args, ...);
|
|
|
|
|
|
|
|
ND_VA_LIST_CLOSE( user_args);
|
|
|
|
*/
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
|
2022-03-20 23:46:24 +01:00
|
|
|
Command_Name = "NDD_CMD_VALUE_ADD";
|
|
|
|
|
|
|
|
return( NDS_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_VALUE_REMOVE:
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
ND_VA_ARG_GET( Value_Ptr, *Args_Ptr, void *);
|
|
|
|
|
|
|
|
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
|
|
|
|
|
|
|
|
ND_VA_ARG_GET( user_data, user_args, user_type);
|
|
|
|
ND_VA_ARG_GET( ..., user_args, ...);
|
|
|
|
|
|
|
|
ND_VA_LIST_CLOSE( user_args);
|
|
|
|
*/
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
|
2022-03-20 23:46:24 +01:00
|
|
|
Command_Name = "NDD_CMD_VALUE_REMOVE";
|
|
|
|
|
|
|
|
return( NDS_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_VALUE_PRINT:
|
|
|
|
{
|
|
|
|
ND_VA_ARG_GET( Next_Node_Ptr, *Args_Ptr, NDT_Node *);
|
|
|
|
|
|
|
|
ND_VA_LIST_OPEN( lib_args, *Args_Ptr);
|
|
|
|
|
|
|
|
ND_VA_ARG_GET( Out, lib_args, FILE *);
|
|
|
|
ND_VA_ARG_GET( Recursive_Mode, lib_args, NDT_Recursive_Mode);
|
|
|
|
ND_VA_ARG_GET( Recursive_Depth, lib_args, NDT_Recursive_Depth);
|
|
|
|
ND_VA_ARG_GET( Recursive_Offset, lib_args, NDT_Recursive_Offset);
|
|
|
|
|
|
|
|
ND_VA_LIST_OPEN( user_args, lib_args);
|
|
|
|
|
|
|
|
ND_VA_ARG_GET( Count_Ptr, user_args, long *);
|
|
|
|
|
|
|
|
ND_VA_LIST_CLOSE( user_args);
|
|
|
|
ND_VA_LIST_CLOSE( lib_args);
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
DRT_Instrument *Instrument_Ptr = Node_Ptr->Value;
|
2022-03-20 23:46:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_VALUE_PRINT";
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
if( DR_Instrument_Dump( Instrument_Ptr, ++(*Count_Ptr)) != DRS_OK)
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
|
|
|
return( NDS_KO);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return( NDS_OK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_INFO_PRINT:
|
|
|
|
{
|
|
|
|
ND_VA_ARG_GET( Next_Node_Ptr, *Args_Ptr, NDT_Node *);
|
|
|
|
|
|
|
|
ND_VA_LIST_OPEN( lib_args, *Args_Ptr);
|
|
|
|
|
|
|
|
ND_VA_ARG_GET( Out, lib_args, FILE *);
|
|
|
|
ND_VA_ARG_GET( Recursive_Mode, lib_args, NDT_Recursive_Mode);
|
|
|
|
ND_VA_ARG_GET( Recursive_Depth, lib_args, NDT_Recursive_Depth);
|
|
|
|
ND_VA_ARG_GET( Recursive_Offset, lib_args, NDT_Recursive_Offset);
|
|
|
|
|
|
|
|
ND_VA_LIST_CLOSE( lib_args);
|
2022-03-23 22:57:26 +01:00
|
|
|
|
|
|
|
NDT_Status nd_status;
|
|
|
|
DRT_Instrument *Instrument_Ptr = Node_Ptr->Value;
|
2022-03-20 23:46:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_INFO_PRINT";
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
if( ( nd_status = ND_DataStruct_Info_Print( Out, Instrument_Ptr->Layer_DS_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0)) != NDS_OK)
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
printf( "DR_Instrument_Manager: ND_DataStruct_Info_Print() failed (%d) !\n", nd_status);
|
2022-03-20 23:46:24 +01:00
|
|
|
return( DRS_KO);
|
|
|
|
}
|
|
|
|
|
|
|
|
return( NDS_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_INDEX0_PRINT:
|
|
|
|
case NDD_CMD_INDEX1_PRINT:
|
|
|
|
{
|
|
|
|
ND_VA_ARG_GET( Next_Node_Ptr, *Args_Ptr, NDT_Node *);
|
|
|
|
|
|
|
|
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
|
|
|
|
|
|
|
|
ND_VA_ARG_GET( Out, user_args, FILE *);
|
|
|
|
ND_VA_ARG_GET( Count_Ptr, user_args, long *);
|
|
|
|
|
|
|
|
ND_VA_LIST_CLOSE( user_args);
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
DRT_Instrument *Instrument_Ptr = Node_Ptr->Value;
|
2022-03-20 23:46:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_INDEX_PRINT";
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
if( DR_Instrument_Dump( Instrument_Ptr, ++(*Count_Ptr)) != DRS_OK)
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
|
|
|
return( NDS_KO);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return( NDS_OK);
|
|
|
|
}
|
|
|
|
}
|
2022-03-23 22:57:26 +01:00
|
|
|
|
|
|
|
case NDD_CMD_STATS_GET:
|
|
|
|
{
|
|
|
|
ND_VA_ARG_GET( Next_Node_Ptr, *Args_Ptr, NDT_Node *);
|
|
|
|
|
|
|
|
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
|
|
|
|
|
|
|
|
ND_VA_ARG_GET( Instruments_Count_Ptr, user_args, long *);
|
|
|
|
ND_VA_ARG_GET( Layers_Count_Ptr, user_args, long *);
|
|
|
|
|
|
|
|
ND_VA_LIST_CLOSE( user_args);
|
|
|
|
|
|
|
|
DRT_Instrument *Instrument_Ptr = Node_Ptr->Value;
|
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_STATS_GET";
|
|
|
|
|
|
|
|
(*Instruments_Count_Ptr)++;
|
|
|
|
(*Layers_Count_Ptr) += Instrument_Ptr->Layer_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Node_Number;
|
|
|
|
|
|
|
|
return( NDS_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_SAMPLE_LOAD:
|
|
|
|
{
|
|
|
|
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_ARG_GET( SampleRate, user_args, double);
|
|
|
|
|
|
|
|
ND_VA_LIST_CLOSE( user_args);
|
|
|
|
|
|
|
|
DRT_Instrument *Instrument_Ptr = Node_Ptr->Value;
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_SAMPLE_LOAD";
|
|
|
|
|
|
|
|
return( ND_DataStruct_Traverse( Instrument_Ptr->Layer_DS_Ptr, NDD_CMD_SAMPLE_LOAD, Kit_Ptr, SampleRate));
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
printf( "Instrument_Manager() called with an undefined command %d\n", Command);
|
|
|
|
return( NDS_ERRAPI);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
printf( "Instrument_Manager() called with command %d (%s)\n", Command, Command_Name);
|
|
|
|
return( NDS_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
/* */
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
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_Command_Name Command_Name;
|
|
|
|
|
|
|
|
|
|
|
|
switch( Command)
|
|
|
|
{
|
|
|
|
case NDD_CMD_MANAGER_VERSION:
|
|
|
|
{
|
|
|
|
ND_VA_ARG_GET( Version_Name_Ptr, *Args_Ptr, NDT_Version_Name *);
|
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_MANAGER_VERSION";
|
|
|
|
|
|
|
|
*Version_Name_Ptr = "$Revision: 1.0 $ $Name: Kit_Manager $ $Date: 2021/12/12 21:27:12 $ $Author: agibert $";
|
|
|
|
|
|
|
|
return( NDS_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_INDEX_GET:
|
|
|
|
{
|
|
|
|
ND_VA_ARG_GET( Reply_Index_Id_Ptr, *Args_Ptr, NDT_Index_Id *);
|
|
|
|
ND_VA_ARG_GET( Reply_Command_Ptr, *Args_Ptr, NDT_Command *);
|
|
|
|
ND_VA_ARG_GET( Cmd, *Args_Ptr, NDT_Command);
|
|
|
|
ND_VA_ARG_GET( Kit_Ptr, *Args_Ptr, DRT_Kit *);
|
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_INDEX_GET";
|
|
|
|
|
|
|
|
switch(Cmd)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
case NDT_CMD_SOME_USER_CMD:
|
|
|
|
{
|
|
|
|
*Reply_Index_Id_Ptr = 0;
|
|
|
|
*Reply_Command_Ptr = NDD_CMD_SOME_OTHER_CMD;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
...
|
|
|
|
*/
|
|
|
|
|
|
|
|
case NDD_CMD_INDEX0_PRINT:
|
|
|
|
{
|
|
|
|
*Reply_Index_Id_Ptr = 0;
|
|
|
|
*Reply_Command_Ptr = Cmd;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_VALUE_PRINT:
|
|
|
|
case NDD_CMD_INDEX1_PRINT:
|
|
|
|
{
|
|
|
|
*Reply_Index_Id_Ptr = 1;
|
|
|
|
*Reply_Command_Ptr = Cmd;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
*Reply_Index_Id_Ptr = Index_Id;
|
|
|
|
*Reply_Command_Ptr = Cmd;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return( NDS_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_VALUE_ALLOC:
|
|
|
|
{
|
|
|
|
ND_VA_ARG_GET( Kit_Ptr_Ptr, *Args_Ptr, DRT_Kit **);
|
|
|
|
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
|
|
|
|
ND_VA_ARG_GET( Kit_Template_Ptr, user_args, DRT_Kit *);
|
|
|
|
ND_VA_LIST_CLOSE( user_args);
|
|
|
|
|
|
|
|
NDT_Status nd_status;
|
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_VALUE_ALLOC";
|
|
|
|
|
|
|
|
if( ( *Kit_Ptr_Ptr = (DRT_Kit *)malloc( sizeof( DRT_Kit))) != NULL)
|
|
|
|
{
|
|
|
|
( *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)->Desc, Kit_Template_Ptr->Desc, DESC_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)
|
|
|
|
{
|
|
|
|
printf( "DR_Kit_Manager: ND_DataStruct_Open() failed (%d) !\n", nd_status);
|
|
|
|
return( NDS_KO);
|
|
|
|
}
|
|
|
|
|
|
|
|
return( NDS_OK);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return( NDS_KO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_VALUE_FREE:
|
|
|
|
{
|
|
|
|
ND_VA_ARG_GET( Kit_Ptr, *Args_Ptr, DRT_Kit *);
|
|
|
|
|
|
|
|
NDT_Status nd_status;
|
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_VALUE_FREE";
|
|
|
|
|
|
|
|
if( ( nd_status = ND_DataStruct_Close( Kit_Ptr->Instrument_DS_Ptr)) != NDS_OK)
|
|
|
|
{
|
|
|
|
printf( "DR_Kit_Manager: Can't close Kit_DS (%d)!\n", nd_status);
|
|
|
|
return( DRS_KO);
|
|
|
|
}
|
|
|
|
|
|
|
|
free( Kit_Ptr);
|
|
|
|
|
|
|
|
return( NDS_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_VALUE_COMP:
|
|
|
|
{
|
|
|
|
ND_VA_ARG_GET( Kit1_Ptr, *Args_Ptr, DRT_Kit *);
|
|
|
|
ND_VA_ARG_GET( Kit2_Ptr, *Args_Ptr, DRT_Kit *);
|
|
|
|
|
|
|
|
long rc;
|
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_VALUE_COMP";
|
|
|
|
|
|
|
|
switch( Index_Id)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
rc = Kit1_Ptr->Id - Kit2_Ptr->Id;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
rc = strcmp( Kit1_Ptr->Name, Kit2_Ptr->Name);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
printf( "Unknown COMP idx (%d) !\n", Index_Id);
|
|
|
|
return( NDS_KO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( rc < 0)
|
|
|
|
{
|
|
|
|
return( NDS_LOWER);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( rc > 0)
|
|
|
|
{
|
|
|
|
return( NDS_GREATER);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return( NDS_EQUAL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_VALUE_ADD:
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
ND_VA_ARG_GET( Value_Ptr, *Args_Ptr, void *);
|
|
|
|
|
|
|
|
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
|
|
|
|
|
|
|
|
ND_VA_ARG_GET( user_data, user_args, user_type);
|
|
|
|
ND_VA_ARG_GET( ..., user_args, ...);
|
|
|
|
|
|
|
|
ND_VA_LIST_CLOSE( user_args);
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_VALUE_ADD";
|
|
|
|
|
|
|
|
return( NDS_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_VALUE_REMOVE:
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
ND_VA_ARG_GET( Value_Ptr, *Args_Ptr, void *);
|
|
|
|
|
|
|
|
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
|
|
|
|
|
|
|
|
ND_VA_ARG_GET( user_data, user_args, user_type);
|
|
|
|
ND_VA_ARG_GET( ..., user_args, ...);
|
|
|
|
|
|
|
|
ND_VA_LIST_CLOSE( user_args);
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_VALUE_REMOVE";
|
|
|
|
|
|
|
|
return( NDS_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_VALUE_PRINT:
|
|
|
|
{
|
|
|
|
ND_VA_ARG_GET( Next_Node_Ptr, *Args_Ptr, NDT_Node *);
|
|
|
|
|
|
|
|
ND_VA_LIST_OPEN( lib_args, *Args_Ptr);
|
|
|
|
|
|
|
|
ND_VA_ARG_GET( Out, lib_args, FILE *);
|
|
|
|
ND_VA_ARG_GET( Recursive_Mode, lib_args, NDT_Recursive_Mode);
|
|
|
|
ND_VA_ARG_GET( Recursive_Depth, lib_args, NDT_Recursive_Depth);
|
|
|
|
ND_VA_ARG_GET( Recursive_Offset, lib_args, NDT_Recursive_Offset);
|
|
|
|
|
|
|
|
ND_VA_LIST_OPEN( user_args, lib_args);
|
|
|
|
|
|
|
|
ND_VA_ARG_GET( Count_Ptr, user_args, long *);
|
|
|
|
|
|
|
|
ND_VA_LIST_CLOSE( user_args);
|
|
|
|
ND_VA_LIST_CLOSE( lib_args);
|
|
|
|
|
|
|
|
DRT_Kit *Kit_Ptr = Node_Ptr->Value;
|
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_VALUE_PRINT";
|
|
|
|
|
|
|
|
if( DR_Kit_Dump( Kit_Ptr, ++(*Count_Ptr)) != DRS_OK)
|
|
|
|
{
|
|
|
|
return( NDS_KO);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return( NDS_OK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_INFO_PRINT:
|
|
|
|
{
|
|
|
|
ND_VA_ARG_GET( Next_Node_Ptr, *Args_Ptr, NDT_Node *);
|
|
|
|
|
|
|
|
ND_VA_LIST_OPEN( lib_args, *Args_Ptr);
|
|
|
|
|
|
|
|
ND_VA_ARG_GET( Out, lib_args, FILE *);
|
|
|
|
ND_VA_ARG_GET( Recursive_Mode, lib_args, NDT_Recursive_Mode);
|
|
|
|
ND_VA_ARG_GET( Recursive_Depth, lib_args, NDT_Recursive_Depth);
|
|
|
|
ND_VA_ARG_GET( Recursive_Offset, lib_args, NDT_Recursive_Offset);
|
|
|
|
|
|
|
|
ND_VA_LIST_CLOSE( lib_args);
|
|
|
|
|
|
|
|
NDT_Status nd_status;
|
|
|
|
DRT_Kit *Kit_Ptr = Node_Ptr->Value;
|
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_INFO_PRINT";
|
|
|
|
|
|
|
|
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);
|
|
|
|
return( DRS_KO);
|
|
|
|
}
|
|
|
|
|
|
|
|
return( NDS_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_INDEX0_PRINT:
|
|
|
|
case NDD_CMD_INDEX1_PRINT:
|
|
|
|
{
|
|
|
|
ND_VA_ARG_GET( Next_Node_Ptr, *Args_Ptr, NDT_Node *);
|
|
|
|
|
|
|
|
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
|
|
|
|
|
|
|
|
ND_VA_ARG_GET( Out, user_args, FILE *);
|
|
|
|
ND_VA_ARG_GET( Count_Ptr, user_args, long *);
|
|
|
|
|
|
|
|
ND_VA_LIST_CLOSE( user_args);
|
|
|
|
|
|
|
|
DRT_Kit *Kit_Ptr = Node_Ptr->Value;
|
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_INDEX_PRINT";
|
|
|
|
|
|
|
|
if( DR_Kit_Dump( Kit_Ptr, ++(*Count_Ptr)) != DRS_OK)
|
|
|
|
{
|
|
|
|
return( NDS_KO);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return( NDS_OK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_STATS_GET:
|
|
|
|
{
|
|
|
|
ND_VA_ARG_GET( Next_Node_Ptr, *Args_Ptr, NDT_Node *);
|
|
|
|
|
|
|
|
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
|
|
|
|
|
|
|
|
ND_VA_ARG_GET( Kits_Count_Ptr, user_args, long *);
|
|
|
|
ND_VA_ARG_GET( Instruments_Count_Ptr, user_args, long *);
|
|
|
|
ND_VA_ARG_GET( Layers_Count_Ptr, user_args, long *);
|
|
|
|
|
|
|
|
ND_VA_LIST_CLOSE( user_args);
|
|
|
|
|
|
|
|
DRT_Kit *Kit_Ptr = Node_Ptr->Value;
|
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_STATS_GET";
|
|
|
|
|
|
|
|
(*Kits_Count_Ptr)++;
|
|
|
|
|
|
|
|
return( ND_DataStruct_Traverse( Kit_Ptr->Instrument_DS_Ptr, NDD_CMD_STATS_GET, Instruments_Count_Ptr, Layers_Count_Ptr));
|
|
|
|
}
|
|
|
|
|
|
|
|
case NDD_CMD_SAMPLE_LOAD:
|
|
|
|
{
|
|
|
|
ND_VA_ARG_GET( Next_Node_Ptr, *Args_Ptr, NDT_Node *);
|
|
|
|
|
|
|
|
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
|
|
|
|
|
|
|
|
ND_VA_ARG_GET( SampleRate, user_args, double);
|
|
|
|
|
|
|
|
ND_VA_LIST_CLOSE( user_args);
|
|
|
|
|
|
|
|
DRT_Kit *Kit_Ptr = Node_Ptr->Value;
|
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_SAMPLE_LOAD";
|
|
|
|
|
|
|
|
return( ND_DataStruct_Traverse( Kit_Ptr->Instrument_DS_Ptr, NDD_CMD_SAMPLE_LOAD, Kit_Ptr, SampleRate));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2022-03-20 23:46:24 +01:00
|
|
|
case NDD_CMD_PHONEBOOK_SAVE:
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
ND_VA_ARG_GET( Next_Node_Ptr, *Args_Ptr, NDT_Node *);
|
|
|
|
|
|
|
|
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
|
|
|
|
|
|
|
|
ND_VA_ARG_GET( user_data, user_args, user_type);
|
|
|
|
ND_VA_ARG_GET( ..., user_args, ...);
|
|
|
|
|
|
|
|
ND_VA_LIST_CLOSE( user_args);
|
|
|
|
*/ /*
|
|
|
|
ND_VA_ARG_GET( Next_Node_Ptr, *Args_Ptr, NDT_Node *);
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
|
|
|
|
|
|
|
|
ND_VA_ARG_GET( Out, user_args, FILE *);
|
|
|
|
ND_VA_ARG_GET( Count_Ptr, user_args, long *);
|
|
|
|
|
|
|
|
ND_VA_LIST_CLOSE( user_args);
|
|
|
|
|
|
|
|
DRT_Kit *Kit_Ptr = Node_Ptr->Value;
|
|
|
|
|
|
|
|
|
|
|
|
Command_Name = "NDD_CMD_PHONEBOOK_SAVE";
|
|
|
|
|
|
|
|
fprintf( Out, "%s:%s:%s:%s\n", Kit_Ptr->Number, Kit_Ptr->Name, Kit_Ptr->Address, Kit_Ptr->Email);
|
|
|
|
(*Count_Ptr)++;
|
|
|
|
|
|
|
|
return( NDS_OK);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
printf( "Kit_Manager() called with an undefined command %d\n", Command);
|
|
|
|
return( NDS_ERRAPI);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
printf( "Kit_Manager() called with command %d (%s)\n", Command, Command_Name);
|
|
|
|
return( NDS_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
/* DR_Layer_Add */
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
DRT_Status DR_Layer_Add( DRT_Layer **Layer_Ptr_Ptr, NDT_Root *DS_Ptr, DRT_Layer *Layer_Template_Ptr)
|
|
|
|
{
|
|
|
|
NDT_Status nd_status;
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
return( DRS_KO);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
return( DRS_KO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return( DRS_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
/* DR_Layer_Sample_Load */
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
DRT_Status DR_Layer_Sample_Load( DRT_Layer *Layer_Ptr, DRT_Kit *Kit_Ptr, double SampleRate)
|
|
|
|
{
|
|
|
|
DRT_Status status;
|
|
|
|
SNDFILE *sndf_ptr;
|
|
|
|
|
|
|
|
// int load_sample(char* path, drmr_layer* layer, double target_rate) {
|
|
|
|
// long size;
|
|
|
|
|
|
|
|
|
|
|
|
fprintf( stderr, "Loading: [%s]\n", Layer_Ptr->FileName);
|
|
|
|
|
|
|
|
if( ( Layer_Ptr->SF_Info_Ptr = malloc( sizeof(SF_INFO))) == NULL)
|
|
|
|
{
|
|
|
|
fprintf( stderr, "Can't allocate SF_Info buffer !\n");
|
|
|
|
return( DRS_KO);
|
|
|
|
}
|
|
|
|
|
|
|
|
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)));
|
|
|
|
status = DRS_KO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( Layer_Ptr->SF_Info_Ptr->channels > 2)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Too many channels: Can only handle mono / stereo samples!\n");
|
|
|
|
status = DRS_KO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Layer_Ptr->Sample_Size = Layer_Ptr->SF_Info_Ptr->frames * Layer_Ptr->SF_Info_Ptr->channels * sizeof( float);
|
|
|
|
|
|
|
|
if( ( Layer_Ptr->Sample_Ptr = malloc( Layer_Ptr->Sample_Size)) == NULL)
|
|
|
|
{
|
|
|
|
fprintf(stderr,"Can't allocate sample memory: (%d) for [%s]!\n", Layer_Ptr->Sample_Size, Layer_Ptr->FileName);
|
|
|
|
status = DRS_KO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sf_read_float( sndf_ptr, Layer_Ptr->Sample_Ptr, ( Layer_Ptr->Sample_Size / sizeof( float)));
|
|
|
|
|
|
|
|
status = DRS_OK;
|
|
|
|
|
|
|
|
// convert rate if needed
|
|
|
|
if( Layer_Ptr->SF_Info_Ptr->samplerate != SampleRate)
|
|
|
|
{
|
|
|
|
int src_status;
|
|
|
|
SRC_DATA src_data;
|
|
|
|
long out_size;
|
|
|
|
float *data_out;
|
|
|
|
|
|
|
|
|
|
|
|
src_data.data_in = Layer_Ptr->Sample_Ptr;
|
|
|
|
src_data.input_frames = Layer_Ptr->SF_Info_Ptr->frames;
|
|
|
|
src_data.src_ratio = SampleRate / Layer_Ptr->SF_Info_Ptr->samplerate;
|
|
|
|
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);
|
|
|
|
|
|
|
|
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);
|
|
|
|
status = DRS_KO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
|
|
|
|
if( ( src_status = src_simple( &src_data, 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));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( src_data.input_frames_used != Layer_Ptr->SF_Info_Ptr->frames)
|
|
|
|
{
|
|
|
|
fprintf(stderr,"Didn't consume all input frames. used: %li had: %li gened: %li\n",
|
|
|
|
src_data.input_frames_used, Layer_Ptr->SF_Info_Ptr->frames, src_data.output_frames_gen);
|
|
|
|
}
|
|
|
|
|
|
|
|
free( Layer_Ptr->Sample_Ptr);
|
|
|
|
|
|
|
|
Layer_Ptr->Sample_Ptr = data_out;
|
|
|
|
Layer_Ptr->Sample_Size = src_data.output_frames_gen * Layer_Ptr->SF_Info_Ptr->channels * sizeof( float);
|
|
|
|
Layer_Ptr->SF_Info_Ptr->samplerate = SampleRate;
|
|
|
|
Layer_Ptr->SF_Info_Ptr->frames = src_data.output_frames_gen;
|
|
|
|
}
|
|
|
|
|
|
|
|
free( data_out);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sf_close( sndf_ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
free( Layer_Ptr->SF_Info_Ptr);
|
|
|
|
|
|
|
|
return( status);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
/* DR_Layer_Sample_UnLoad */
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
DRT_Status DR_Layer_Sample_UnLoad( DRT_Layer *Layer_Ptr)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-03-20 23:46:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
/* DR_Layer_Dump */
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
2022-03-20 23:46:24 +01:00
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
DRT_Status DR_Layer_Dump( DRT_Layer *Layer_Ptr, long count)
|
|
|
|
{
|
|
|
|
NDT_Status nd_status;
|
|
|
|
|
2022-03-20 23:46:24 +01:00
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
fprintf( stderr, " %03d) Layer: ", count);
|
|
|
|
fprintf( stderr, " Id: (% 3d) File Name: [%s] Sample: [%lx] Sample Size: (%d) Min: (%f) Max: (%f) Gain: (%f) Pitch: (%f)\n",
|
|
|
|
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);
|
|
|
|
// fprintf( stderr, "\n");
|
2022-03-20 23:46:24 +01:00
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
return( DRS_OK);
|
2022-03-20 23:46:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
/* DR_Instrument_Add */
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
DRT_Status DR_Instrument_Add( DRT_Instrument **Instrument_Ptr_Ptr, NDT_Root *DS_Ptr, DRT_Instrument *Instrument_Template_Ptr)
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
|
|
|
NDT_Status nd_status;
|
|
|
|
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
if( ( nd_status = ND_Value_Alloc( DS_Ptr, (void **)Instrument_Ptr_Ptr, Instrument_Template_Ptr)) != NDS_OK)
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
|
|
|
printf( "Can't allocate new instrument: ND_Value_Alloc() failed (%d) !\n", nd_status);
|
|
|
|
return( DRS_KO);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( ( nd_status = ND_DataStruct_Value_Add( DS_Ptr, (void *)*Instrument_Ptr_Ptr)) != NDS_OK)
|
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
printf( "Can't add new instrument: ND_Value_Add() failed (%d) !\n", nd_status);
|
2022-03-20 23:46:24 +01:00
|
|
|
return( DRS_KO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return( DRS_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
/* DR_Instrument_Dump */
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
DRT_Status DR_Instrument_Dump( DRT_Instrument *Instrument_Ptr, long Count)
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
NDT_Status nd_status;
|
|
|
|
long count2;
|
2022-03-20 23:46:24 +01:00
|
|
|
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
fprintf( stderr, " %03d) Instrument: ", Count);
|
|
|
|
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);
|
2022-03-20 23:46:24 +01:00
|
|
|
// fprintf( stderr, "\n");
|
2022-03-23 22:57:26 +01:00
|
|
|
fprintf( stderr, " Layer List:\n");
|
|
|
|
|
|
|
|
if( Instrument_Ptr->Layer_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Node_Number == 0)
|
|
|
|
{
|
|
|
|
fprintf( stderr, " Empty list!\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
count2 = 0;
|
|
|
|
|
|
|
|
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);
|
|
|
|
return( DRS_KO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf( stderr, "\n");
|
2022-03-20 23:46:24 +01:00
|
|
|
|
|
|
|
return( DRS_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
/* DR_Kit_Add */
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
DRT_Status DR_Kit_Add( DRT_Kit **Kit_Ptr_Ptr, NDT_Root *DS_Ptr, DRT_Kit *Kit_Template_Ptr)
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
|
|
|
NDT_Status nd_status;
|
|
|
|
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
if( ( nd_status = ND_Value_Alloc( DS_Ptr, (void **)Kit_Ptr_Ptr, Kit_Template_Ptr)) != NDS_OK)
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
|
|
|
printf( "Can't allocate new kit: ND_Value_Alloc() failed (%d) !\n", nd_status);
|
|
|
|
return( DRS_KO);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
return( DRS_KO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return( DRS_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
/* 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-20 23:46:24 +01:00
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
/* DR_Kit_Dump */
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
DRT_Status DR_Kit_Dump( DRT_Kit *Kit_Ptr, long Count)
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
|
|
|
NDT_Status nd_status;
|
|
|
|
long count2;
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
fprintf( stderr, " %03d) 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);
|
2022-03-20 23:46:24 +01:00
|
|
|
fprintf( stderr, " Instruments List:\n");
|
|
|
|
|
|
|
|
if( Kit_Ptr->Instrument_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Node_Number == 0)
|
|
|
|
{
|
|
|
|
fprintf( stderr, " Empty list!\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
count2 = 0;
|
|
|
|
|
|
|
|
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);
|
|
|
|
return( DRS_KO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf( stderr, "\n");
|
|
|
|
|
|
|
|
return( DRS_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
2022-03-23 22:57:26 +01:00
|
|
|
/* DR_XML_Node_Exist */
|
2022-03-20 23:46:24 +01:00
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
DRT_Status DR_XML_Node_Exist( xmlDocPtr Xml_Doc, xmlXPathContextPtr Xml_XpathCtx, char *Xpath_Request)
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
DRT_Status status;
|
|
|
|
xmlXPathObjectPtr xml_xpathobj;
|
|
|
|
xmlNodeSetPtr nodeset;
|
|
|
|
char *tmpval_ptr;
|
|
|
|
long tmpval_len;
|
2022-03-20 23:46:24 +01:00
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
|
|
|
|
if( ( xml_xpathobj = xmlXPathEvalExpression( Xpath_Request, Xml_XpathCtx)) == NULL)
|
|
|
|
{
|
|
|
|
fprintf( stderr, "DR_XML_Node_Exist: xmlXPathEvalExpression failed [%s]!\n", Xpath_Request);
|
|
|
|
status = DRS_KO;
|
|
|
|
}
|
|
|
|
else
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
nodeset = xml_xpathobj->nodesetval;
|
|
|
|
|
|
|
|
if( xmlXPathNodeSetIsEmpty( nodeset))
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
// fprintf( stderr, "[%s] not found!\n", Xpath_Request);
|
|
|
|
status = DRS_KO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// fprintf( stderr, "[%s] found!\n", Xpath_Request);
|
|
|
|
status = DRS_OK;
|
2022-03-20 23:46:24 +01:00
|
|
|
}
|
|
|
|
}
|
2022-03-23 22:57:26 +01:00
|
|
|
|
|
|
|
return( status);
|
2022-03-20 23:46:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
/* DR_XML_Value_Get */
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
DRT_Status DR_XML_Value_Get( char *Value_Ptr, long Max_Len, xmlDocPtr Xml_Doc, xmlXPathContextPtr Xml_XpathCtx, char *Xpath_HeadRequest, char *Xpath_TailRequest)
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
|
|
|
DRT_Status status;
|
|
|
|
xmlXPathObjectPtr xml_xpathobj;
|
|
|
|
xmlNodeSetPtr nodeset;
|
|
|
|
char *tmpval_ptr;
|
|
|
|
long tmpval_len;
|
2022-03-23 22:57:26 +01:00
|
|
|
char xpath_request[1024];
|
|
|
|
|
2022-03-20 23:46:24 +01:00
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
strcpy( xpath_request, Xpath_HeadRequest);
|
|
|
|
strcat( xpath_request, Xpath_TailRequest);
|
2022-03-20 23:46:24 +01:00
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
if( ( xml_xpathobj = xmlXPathEvalExpression( xpath_request, Xml_XpathCtx)) == NULL)
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
fprintf( stderr, "DR_XML_Value_Get: xmlXPathEvalExpression failed! [%s]\n", xpath_request);
|
2022-03-20 23:46:24 +01:00
|
|
|
status = DRS_KO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nodeset = xml_xpathobj->nodesetval;
|
|
|
|
|
|
|
|
if( xmlXPathNodeSetIsEmpty( nodeset))
|
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
fprintf( stderr, "[%s] not found!\n", xpath_request);
|
2022-03-20 23:46:24 +01:00
|
|
|
status = DRS_KO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( ( tmpval_ptr = xmlNodeListGetString( Xml_Doc, nodeset->nodeTab[0]->xmlChildrenNode, 1)) == NULL)
|
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
fprintf( stderr, "[%s] value not found!\n", xpath_request);
|
2022-03-20 23:46:24 +01:00
|
|
|
status = DRS_KO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
// fprintf( stderr, "[%s] = [%s] found!\n", nodeset->nodeTab[0]->name, tmpval_ptr);
|
2022-03-20 23:46:24 +01:00
|
|
|
|
|
|
|
if( ( tmpval_len = strlen( tmpval_ptr)) > Max_Len)
|
|
|
|
{
|
|
|
|
fprintf( stderr, "Value too long (%d)>(%d)!\n", tmpval_len, Max_Len);
|
|
|
|
status = DRS_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strcpy( Value_Ptr, tmpval_ptr);
|
|
|
|
status = DRS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
xmlFree( tmpval_ptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return( status);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
2022-03-23 22:57:26 +01:00
|
|
|
/* DR_XML_Query_Tab_Exec */
|
2022-03-20 23:46:24 +01:00
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
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)
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
DRT_Status status;
|
|
|
|
char reply_str[DESC_SIZE];
|
|
|
|
int i;
|
|
|
|
|
2022-03-20 23:46:24 +01:00
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
i=0;
|
2022-03-20 23:46:24 +01:00
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
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)
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
strcpy( reply_str, "");
|
2022-03-20 23:46:24 +01:00
|
|
|
}
|
2022-03-23 22:57:26 +01:00
|
|
|
|
|
|
|
switch( XML_Query_Tab[i].Value_Type)
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
case XML_QUERY_VALUE_STRING:
|
|
|
|
{
|
|
|
|
strncpy( ( Value_Ptr + XML_Query_Tab[i].Value_Offset), reply_str, XML_Query_Tab[i].Value_Len);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case XML_QUERY_VALUE_INT:
|
|
|
|
{
|
|
|
|
*( (int *)( Value_Ptr + XML_Query_Tab[i].Value_Offset)) = atoi( reply_str);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case XML_QUERY_VALUE_LONG:
|
|
|
|
{
|
|
|
|
*( (long *)( Value_Ptr + XML_Query_Tab[i].Value_Offset)) = strtol( reply_str, NULL, 10);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case XML_QUERY_VALUE_LONGLONG:
|
|
|
|
{
|
|
|
|
*( (long long *)( Value_Ptr + XML_Query_Tab[i].Value_Offset)) = strtoll( reply_str, NULL, 10);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case XML_QUERY_VALUE_FLOAT:
|
|
|
|
{
|
|
|
|
*( (float *)( Value_Ptr + XML_Query_Tab[i].Value_Offset)) = strtof( reply_str, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case XML_QUERY_VALUE_DOUBLE:
|
|
|
|
{
|
|
|
|
*( (double *)( Value_Ptr + XML_Query_Tab[i].Value_Offset)) = strtod( reply_str, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
fprintf( stderr, "Unknown valute type: (%d)\n", XML_Query_Tab[i].Value_Type);
|
|
|
|
break;
|
|
|
|
}
|
2022-03-20 23:46:24 +01:00
|
|
|
}
|
2022-03-23 22:57:26 +01:00
|
|
|
|
|
|
|
i++;
|
2022-03-20 23:46:24 +01:00
|
|
|
}
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
return( DRS_OK);
|
2022-03-20 23:46:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
/* DR_Kit_Load */
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
DRT_Status DR_Kit_Load( DRT_Base *Base_Ptr, char *FileName)
|
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
DRT_Status status;
|
|
|
|
NDT_Status nd_status;
|
|
|
|
|
|
|
|
DRT_Kit kit_template;
|
|
|
|
DRT_Kit *kit_ptr;
|
|
|
|
DRT_Instrument instrument_template;
|
|
|
|
DRT_Instrument *instrument_ptr;
|
|
|
|
DRT_Layer layer_template;
|
|
|
|
DRT_Layer *layer_ptr;
|
|
|
|
|
|
|
|
xmlDocPtr xml_doc;
|
|
|
|
xmlXPathContextPtr xml_xpathCtx;
|
|
|
|
xmlXPathObjectPtr xml_xpathObj;
|
2022-03-20 23:46:24 +01:00
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
char tmp_filename[FILENAME_SIZE];
|
|
|
|
char xpath_head[1024];
|
|
|
|
char reply_str[256];
|
2022-03-20 23:46:24 +01:00
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
int instrument, layer;
|
|
|
|
short i;
|
|
|
|
|
|
|
|
|
|
|
|
layer_template.Sample_Ptr = NULL;
|
|
|
|
layer_template.Sample_Size = 0;
|
|
|
|
|
|
|
|
|
2022-03-20 23:46:24 +01:00
|
|
|
fprintf( stderr, "Loading: [%s]...\n", FileName);
|
|
|
|
|
|
|
|
if( strlen( FileName) > FILENAME_LEN)
|
|
|
|
{
|
|
|
|
fprintf( stderr, "Kit file name too long [%s]!", FileName);
|
|
|
|
status = DRS_KO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
strcpy( tmp_filename, FileName);
|
|
|
|
strcpy( kit_template.DirName, dirname(tmp_filename));
|
2022-03-20 23:46:24 +01:00
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
if( ( xml_doc = xmlParseFile( FileName)) == NULL)
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
|
|
|
fprintf( stderr, "xml_doc failed!\n");
|
|
|
|
status = DRS_KO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( ( xml_xpathCtx = xmlXPathNewContext( xml_doc)) == NULL)
|
|
|
|
{
|
|
|
|
fprintf( stderr, "xmlXPathNewContext failed!\n");
|
|
|
|
status = DRS_KO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( xmlXPathRegisterNs( xml_xpathCtx, "drumkit", "http://www.hydrogen-music.org/drumkit") != 0)
|
|
|
|
{
|
|
|
|
fprintf( stderr,"Error: unable to register default NS!\n");
|
|
|
|
status = DRS_KO;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( ( status = DR_XML_Node_Exist( xml_doc, xml_xpathCtx, XML_XPATH_DRUMKIT_BASE_STR) != DRS_OK))
|
|
|
|
{
|
|
|
|
fprintf( stderr, "Bad drumkit file!\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
DR_XML_Query_Tab_Exec( &kit_template, xml_doc, xml_xpathCtx, 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)
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
|
|
|
fprintf( stderr, "Can't create a new kit!\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
// fprintf( stderr, "New kit!\n");
|
2022-03-20 23:46:24 +01:00
|
|
|
|
|
|
|
status = DRS_OK;
|
2022-03-23 22:57:26 +01:00
|
|
|
instrument = 1;
|
2022-03-20 23:46:24 +01:00
|
|
|
while( ( status == DRS_OK)
|
2022-03-23 22:57:26 +01:00
|
|
|
&& ( sprintf( xpath_head, XML_XPATH_DRUMKIT_INSTRUMENT_FULL, instrument) > 0)
|
|
|
|
&& ( DR_XML_Node_Exist( xml_doc, xml_xpathCtx, xpath_head) == DRS_OK))
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
instrument_template.Id = -1;
|
|
|
|
|
|
|
|
DR_XML_Query_Tab_Exec( &instrument_template, xml_doc, xml_xpathCtx, xpath_head, DRG_XML_Query_Tab_Instrument);
|
|
|
|
|
|
|
|
if( instrument_template.Id == -1)
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
|
|
|
fprintf( stderr, "Instrument id not found!\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
if( ( status = DR_Instrument_Add( &instrument_ptr, kit_ptr->Instrument_DS_Ptr, &instrument_template)) != DRS_OK)
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
fprintf( stderr, "Can't create a new instrument!\n");
|
2022-03-20 23:46:24 +01:00
|
|
|
}
|
2022-03-23 22:57:26 +01:00
|
|
|
else
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
// fprintf( stderr, "New Instrument!\n");
|
2022-03-20 23:46:24 +01:00
|
|
|
}
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
layer = 1;
|
|
|
|
while( ( status == DRS_OK)
|
|
|
|
&& ( sprintf( xpath_head, XML_XPATH_DRUMKIT_LAYER_FULL, instrument, layer) > 0)
|
|
|
|
&& ( DR_XML_Node_Exist( xml_doc, xml_xpathCtx, xpath_head) == DRS_OK))
|
2022-03-20 23:46:24 +01:00
|
|
|
{
|
2022-03-23 22:57:26 +01:00
|
|
|
DR_XML_Query_Tab_Exec( &layer_template, xml_doc, xml_xpathCtx, xpath_head, DRG_XML_Query_Tab_Layer);
|
|
|
|
|
|
|
|
strcpy( tmp_filename, kit_template.DirName);
|
|
|
|
strcat( tmp_filename, "/");
|
|
|
|
strcat( tmp_filename, layer_template.FileName);
|
|
|
|
strcpy( layer_template.FileName, tmp_filename);
|
|
|
|
|
|
|
|
if( ( status = DR_Layer_Add( &layer_ptr, instrument_ptr->Layer_DS_Ptr, &layer_template)) != DRS_OK)
|
|
|
|
{
|
|
|
|
fprintf( stderr, "Can't create a new layer!\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// fprintf( stderr, "New layer!\n");
|
|
|
|
layer++;
|
|
|
|
}
|
2022-03-20 23:46:24 +01:00
|
|
|
}
|
|
|
|
}
|
2022-03-23 22:57:26 +01:00
|
|
|
|
|
|
|
instrument++;
|
2022-03-20 23:46:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
xmlXPathFreeContext( xml_xpathCtx);
|
|
|
|
}
|
|
|
|
|
|
|
|
xmlFreeDoc( xml_doc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
xmlCleanupParser();
|
|
|
|
|
|
|
|
return( status);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
/* DR_Kits_Load */
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
DRT_Status DR_Kits_Load( DRT_Base *Base_Ptr)
|
|
|
|
{
|
|
|
|
DRT_Status status;
|
|
|
|
NDT_Status nd_status;
|
|
|
|
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/Mars Lindrum: 02-Kit 2/drumkit.xml";
|
|
|
|
glob_t glob_struct;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
|
|
LIBXML_TEST_VERSION;
|
|
|
|
|
|
|
|
if( glob( glob_pattern, (GLOB_NOSORT + GLOB_TILDE), NULL, &glob_struct) != 0)
|
|
|
|
{
|
|
|
|
fprintf( stderr, "glob() error!\n");
|
|
|
|
status = DRS_KO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for( i = 0; i < glob_struct.gl_pathc; i++)
|
|
|
|
{
|
|
|
|
// printf( "[%s]\n", glob_struct.gl_pathv[i]);
|
|
|
|
|
|
|
|
if( ( status = DR_Kit_Load( Base_Ptr, glob_struct.gl_pathv[i])) != DRS_OK)
|
|
|
|
{
|
|
|
|
fprintf( stderr, "Can't load kit [%s]!\n", glob_struct.gl_pathv[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
status = DRS_KO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
status = DRS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
globfree( &glob_struct);
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
Base_Ptr->SampleRate=44100;
|
2022-03-20 23:46:24 +01:00
|
|
|
|
|
|
|
/*
|
2022-03-23 22:57:26 +01:00
|
|
|
status = DR_Layer_Sample_Load( (DRT_Layer *)(
|
|
|
|
((DRT_Instrument *)(
|
|
|
|
((DRT_Kit *)(Base_Ptr->Kit_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Head->Value))
|
|
|
|
->Instrument_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);
|
2022-03-20 23:46:24 +01:00
|
|
|
*/
|
2022-03-23 22:57:26 +01:00
|
|
|
status = DR_Kit_Sample_Load( (DRT_Kit *)(Base_Ptr->Kit_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Head->Value),
|
|
|
|
Base_Ptr->SampleRate);
|
2022-03-20 23:46:24 +01:00
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
return( status);
|
|
|
|
}
|
2022-03-20 23:46:24 +01:00
|
|
|
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
|
2022-03-20 23:46:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
/* DR_Kits_Dump */
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
DRT_Status DR_Kits_Dump( DRT_Base *Base_Ptr)
|
|
|
|
{
|
|
|
|
NDT_Status nd_status;
|
|
|
|
short index;
|
|
|
|
long count = 0;
|
2022-03-23 22:57:26 +01:00
|
|
|
long kits_count = 0;
|
|
|
|
long instruments_count = 0;
|
|
|
|
long layers_count = 0;
|
2022-03-20 23:46:24 +01:00
|
|
|
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
fprintf( stderr, "\n");
|
2022-03-20 23:46:24 +01:00
|
|
|
fprintf( stderr, "DrumKit List:\n");
|
2022-03-23 22:57:26 +01:00
|
|
|
/*
|
2022-03-20 23:46:24 +01:00
|
|
|
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);
|
|
|
|
return( DRS_KO);
|
|
|
|
}
|
|
|
|
|
|
|
|
for( index = 0; index < Base_Ptr->Kit_DS_Ptr->Index_Nb; index++)
|
|
|
|
{
|
|
|
|
count = 0;
|
|
|
|
fprintf( stderr, "Dump Index: (%d)\n", index);
|
|
|
|
|
|
|
|
if( Base_Ptr-> Kit_DS_Ptr->Index_Tab[index].Node_Number == 0)
|
|
|
|
{
|
|
|
|
fprintf( stderr, " Empty list!\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
return( DRS_KO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf( stderr, "\n");
|
|
|
|
}
|
|
|
|
*/
|
2022-03-23 22:57:26 +01:00
|
|
|
|
2022-03-20 23:46:24 +01:00
|
|
|
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);
|
|
|
|
return( DRS_KO);
|
|
|
|
}
|
|
|
|
|
2022-03-23 22:57:26 +01:00
|
|
|
if( ( nd_status = ND_DataStruct_Traverse( Base_Ptr->Kit_DS_Ptr, NDD_CMD_STATS_GET, &kits_count, &instruments_count, &layers_count)) != NDS_OK)
|
|
|
|
{
|
|
|
|
printf( "Can't compute stats: ND_DataStruct_Traverse() failed (%d) !\n", nd_status);
|
|
|
|
return( DRS_KO);
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf( stderr, "Number of Kits: (%ld) Number of Instruments: (%ld) Number of Layers: (%ld)\n", kits_count, instruments_count, layers_count);
|
|
|
|
|
2022-03-20 23:46:24 +01:00
|
|
|
return( DRS_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
/* DR_Init */
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
DRT_Status DR_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_DeInit */
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
DRT_Status DR_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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
/* main */
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
int main( int argc, char **argv)
|
|
|
|
{
|
|
|
|
DRT_Base base;
|
|
|
|
DRT_Status status;
|
|
|
|
|
|
|
|
|
|
|
|
if( ( status = DR_Init( &base)) != DRS_OK)
|
|
|
|
{
|
|
|
|
exit( -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if( ( status = DR_Kits_Load( &base)) != DRS_OK)
|
|
|
|
{
|
|
|
|
exit( -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
printf( "hello world!\n");
|
|
|
|
|
|
|
|
if( ( status = DR_Kits_Dump( &base)) != DRS_OK)
|
|
|
|
{
|
|
|
|
exit( -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if( ( status = DR_DeInit( &base)) != DRS_OK)
|
|
|
|
{
|
|
|
|
exit( -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
exit( 0);
|
|
|
|
}
|