drummer/utils.c

122 lines
4.1 KiB
C
Raw Normal View History

/*----------------------------------------------------------------------------*/
/* util.c */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* This file is part of Drummer. */
/* */
/* Drummer is free software: you can redistribute it and/or modify it */
/* under the terms of the GNU General Public License as published by */
/* the Free Software Foundation, either version 3 of the License, or */
/* (at your option) any later version. */
/* */
/* Drummer is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with Drummer. If not, see <https://www.gnu.org/licenses/>. */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* Includes */
/*----------------------------------------------------------------------------*/
#define _UTILS_C_
#include <drummer.h>
/*----------------------------------------------------------------------------*/
/* DR_LV2_Log_Write */
/*----------------------------------------------------------------------------*/
/*
DRT_Status DR_LV2_Log_Write( DRT_Log_Type_Id Log_Type_Id, char *Out_Fmt, va_list Args)
{
LV2_URID type;
switch( Log_Type_Id)
{
case DRD_LOG_TYPE_ID_TRACE:
{
type = DRG_LV2_Base.Logger.Trace;
break;
}
case DRD_LOG_TYPE_ID_INFO:
{
type = DRG_LV2_Base.Logger.Note;
break;
}
case DRD_LOG_TYPE_ID_WARNING:
{
type = DRG_LV2_Base.Logger.Warning;
break;
}
case DRD_LOG_TYPE_ID_ERROR:
case DRD_LOG_TYPE_ID_UNKNOWN:
default:
{
type = DRG_LV2_Base.Logger.Error;
break;
}
}
if( lv2_log_vprintf( &(DRG_LV2_Base.Logger), type, Out_Fmt, Args) == 0)
{
fprintf( stderr, "LV2 logger error...\n");
}
return( DRS_OK);
}
*/
/*----------------------------------------------------------------------------*/
/* DR_Kit_Id_Convert */
/*----------------------------------------------------------------------------*/
DRT_Status DR_Kit_Id_Convert( uint8_t *Bank_Id_LSB_Ptr, uint8_t *Bank_Id_MSB_Ptr, uint8_t *Program_Id_Ptr, DRT_Kit_Id Kit_Id)
{
*Program_Id_Ptr = Kit_Id % 128;
*Bank_Id_MSB_Ptr = ( Kit_Id / 128) % 128;
*Bank_Id_LSB_Ptr = ( Kit_Id / 128) / 128;
// LG_LOG_INFO_4( "DR_Kit_Id_Convert: kit: id: (%d) -> Bank/Program: (%d/%d/%d)", Kit_Id, *Bank_Id_LSB_Ptr, *Bank_Id_MSB_Ptr, *Program_Id_Ptr);
return( DRS_OK);
}
/*----------------------------------------------------------------------------*/
/* DR_Bank_Program_Id_Convert */
/*----------------------------------------------------------------------------*/
DRT_Status DR_Bank_Program_Id_Convert( DRT_Kit_Id *Kit_Id_Ptr, uint8_t Bank_Id_LSB, uint8_t Bank_Id_MSB, uint8_t Program_Id)
{
*Kit_Id_Ptr = ( Bank_Id_LSB * 128 + Bank_Id_MSB) * 128 + Program_Id;
// LG_LOG_INFO_4( "DR_Bank_Program_Id_Convert: kit: id: (%d) <- Bank/Program: (%d/%d/%d)", *Kit_Id_Ptr, Bank_Id_LSB, Bank_Id_MSB, Program_Id);
return( DRS_OK);
}