Skip to content
......@@ -52,9 +52,11 @@ while getopts ":-:e:d:" OPTIONS; do
-)
case "${OPTARG}" in
max_cores)
MAX_CORES="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
MAX_CORES="${!OPTIND}"
OPTIND=$(($OPTIND + 1))
;;
esac
;;
esac;;
e)
ENC_PATH=${OPTARG}
;;
......@@ -82,10 +84,6 @@ duration_arg=""
complexity_cmd="--checks COMPLEXITY --wmc_tool_mem_only --basop --create_complexity_tables"
max_num_workers="--max_workers $MAX_CORES"
# prepare combined format test signals
echo "\n======================= 0. preparing combined format test inputs =======================\n\n"
./scripts/prepare_combined_format_inputs.py
# Modes
mono_modes=$(./scripts/IvasBuildAndRunChecks.py -l | grep ^mono)
FOA_modes=$(./scripts/IvasBuildAndRunChecks.py -l | grep ^FOA)
......@@ -112,7 +110,6 @@ ISM_plus2_modes=$(./scripts/IvasBuildAndRunChecks.py -l | grep ^ISM+2)
ISM_plus3_modes=$(./scripts/IvasBuildAndRunChecks.py -l | grep ^ISM+3)
ISM_plus4_modes=$(./scripts/IvasBuildAndRunChecks.py -l | grep ^ISM+4)
echo "\n======================= 1. Mono =======================\n\n"
./scripts/IvasBuildAndRunChecks.py $enc_cmd $dec_cmd $complexity_cmd ltv_complexity_mono_no_fec -m $mono_modes -p $cfg $duration_arg $max_num_workers | tee smoke_test_output_mono.txt
rm -r ./COMPLEXITY/dec/
......
......@@ -38,16 +38,9 @@ the United Nations Convention on Contracts on the International Sales of Goods.
#include "isar_lc3plus_common.h"
#include "isar_lc3plus_dec.h"
#include "ivas_error_utils.h"
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
#include "lc3.h"
#endif
#include "lc3plus.h"
#ifdef SPLIT_REND_WITH_HEAD_ROT
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
#define MAX_SAMPLES_PER_CHANNEL 960 / 4
#else
#define MAX_SAMPLES_PER_CHANNEL 960
#endif
#define DEFAULT_BPS 256000
#ifndef PCM_SAMPLE_TYPEDEF_DEFINED
......@@ -100,7 +93,6 @@ static int encodeAndDecodeOneStereoFrame( LC3PLUS_CONFIG config, uint32_t bps )
uint8_t *bitstream_out = malloc( bitstreamSizePerIvasFrame );
memset( bitstream_out, 0, bitstreamSizePerIvasFrame );
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
int perChannelBitrate = lc3plus_enc_get_real_bitrate(encHandle->handles[0]);
int perLc3plusFrameDataBlockOctets = encHandle->num_ftds * perChannelBitrate / 8 / (1000*1000/config.lc3plus_frame_duration_us);
int targetOctets = bps / 8 / (1000*1000/config.isar_frame_duration_us);
......@@ -118,9 +110,6 @@ static int encodeAndDecodeOneStereoFrame( LC3PLUS_CONFIG config, uint32_t bps )
Word16 Q_in[16];
memset(Q_in, 0, sizeof(Q_in) );
err = ISAR_LC3PLUS_ENC_Encode( encHandle, pcm_in, bitstream_out, bitstreamSizePerIvasFrame, Q_in );
#else
err = ISAR_LC3PLUS_ENC_Encode( encHandle, pcm_in, bitstream_out );
#endif
if ( IVAS_ERR_OK != err )
{
ISAR_LC3PLUS_ENC_Close( &encHandle );
......@@ -200,11 +189,7 @@ static int encodeAndDecodeOneStereoFrame( LC3PLUS_CONFIG config, uint32_t bps )
static int openCloseEncoder( void )
{
ivas_error err;
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20000, .channels = 1, .samplerate = 48000 };
#endif
uint32_t bps = 128000;
ISAR_LC3PLUS_ENC_HANDLE encHandle;
......@@ -221,36 +206,23 @@ static int openCloseEncoder( void )
static int tryOpenEncoderWithInvalidBitrate( void )
{
ivas_error err;
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20000, .channels = 1, .samplerate = 48000 };
#endif
/* lc3plus max bitrate is 320000 per channel */
uint32_t invalid_high_bps = 700000;
uint32_t invalid_low_bps = 8;
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
uint32_t limitedBitrate;
#endif
ISAR_LC3PLUS_ENC_HANDLE encHandle;
err = ISAR_LC3PLUS_ENC_Open( config, invalid_high_bps, &encHandle );
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
/* setting an invalid bitrate should result in a limited bitrate*/
if ( IVAS_ERR_OK != err )
#else
/* setting an invalid bitrate should trigger an error - which is what we expect */
if ( IVAS_ERR_LC3PLUS_INVALID_BITRATE != err )
#endif
{
return 1;
}
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
limitedBitrate = lc3plus_enc_get_real_bitrate(encHandle->handles[0]);
if(limitedBitrate != 320000)
{
return 1;
}
#endif
ISAR_LC3PLUS_ENC_Close(&encHandle);
err = ISAR_LC3PLUS_ENC_Open( config, invalid_low_bps, &encHandle );
/* setting an invalid bitrate should trigger an error - which is what we expect */
......@@ -265,11 +237,7 @@ static int tryOpenEncoderWithInvalidBitrate( void )
static int tryOpenEncoderWithInvalidFrameDuration( void )
{
ivas_error err;
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20000, .channels = 1, .samplerate = 48000 };
#endif
config.lc3plus_frame_duration_us = 1234; /*unsupported frame duration*/
uint32_t bps = 320000;
......@@ -286,11 +254,7 @@ static int tryOpenEncoderWithInvalidFrameDuration( void )
static int tryOpenEncoderWithInvalidSampleRate( void )
{
ivas_error err;
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20000, .channels = 1, .samplerate = 48000 };
#endif
config.samplerate = 1234; /*unsupported sample rate */
uint32_t bps = 320000;
......@@ -330,22 +294,14 @@ static int tryCallEncoderApiWithInvalidParams( void )
return 1;
}
ISAR_LC3PLUS_ENC_Close( &invalidEncHandle );
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
Word16 Q_in[16];
memset(Q_in, 0, sizeof(Q_in) );
if ( IVAS_ERR_UNEXPECTED_NULL_POINTER != ISAR_LC3PLUS_ENC_Encode( invalidEncHandle, invalidPcm_in, invalidBitstream_out, bsSize, Q_in ) )
#else
if ( IVAS_ERR_UNEXPECTED_NULL_POINTER != ISAR_LC3PLUS_ENC_Encode( invalidEncHandle, invalidPcm_in, invalidBitstream_out ) )
#endif
{
return 1;
}
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
memset(Q_in, 0, sizeof(Q_in) );
if ( IVAS_ERR_UNEXPECTED_NULL_POINTER != ISAR_LC3PLUS_ENC_Encode( invalidEncHandle, pcm_in, invalidBitstream_out, bsSize, Q_in) || IVAS_ERR_UNEXPECTED_NULL_POINTER != ISAR_LC3PLUS_ENC_Encode( invalidEncHandle, invalidPcm_in, bitstream_out, bsSize, Q_in ) || IVAS_ERR_UNEXPECTED_NULL_POINTER != ISAR_LC3PLUS_ENC_Encode( invalidEncHandle, pcm_in, bitstream_out, bsSize, Q_in ) )
#else
if ( IVAS_ERR_UNEXPECTED_NULL_POINTER != ISAR_LC3PLUS_ENC_Encode( invalidEncHandle, pcm_in, invalidBitstream_out ) || IVAS_ERR_UNEXPECTED_NULL_POINTER != ISAR_LC3PLUS_ENC_Encode( invalidEncHandle, invalidPcm_in, bitstream_out ) || IVAS_ERR_UNEXPECTED_NULL_POINTER != ISAR_LC3PLUS_ENC_Encode( invalidEncHandle, pcm_in, bitstream_out ) )
#endif
{
return 1;
}
......@@ -391,11 +347,7 @@ static int tryCallDecoderApiWithInvalidParams( void )
static int openCloseDecoderWithCaching( void )
{
ivas_error err;
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20000, .channels = 1, .samplerate = 48000 };
#endif
ISAR_LC3PLUS_DEC_HANDLE decHandle;
err = ISAR_LC3PLUS_DEC_Open( config,
#ifdef LC3PLUS_DEC_ALLOW_DISABLE_CACHING
......@@ -414,11 +366,7 @@ static int openCloseDecoderWithCaching( void )
static int openCloseDecoderWithoutCaching( void )
{
ivas_error err;
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20000, .channels = 1, .samplerate = 48000 };
#endif
ISAR_LC3PLUS_DEC_HANDLE decHandle;
err = ISAR_LC3PLUS_DEC_Open( config,
#ifdef LC3PLUS_DEC_ALLOW_DISABLE_CACHING
......@@ -438,11 +386,7 @@ static int openCloseDecoderWithoutCaching( void )
static int tryOpenDecoderWithInvalidFrameDuration( void )
{
ivas_error err;
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20000, .channels = 1, .samplerate = 48000 };
#endif
config.lc3plus_frame_duration_us = 1234; /*unsupported frame duration*/
ISAR_LC3PLUS_DEC_HANDLE decHandle;
......@@ -462,11 +406,7 @@ static int tryOpenDecoderWithInvalidFrameDuration( void )
static int tryOpenDecoderWithInvalidSampleRate( void )
{
ivas_error err;
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20000, .channels = 1, .samplerate = 48000 };
#endif
config.samplerate = 1234; /*unsupported sample rate*/
ISAR_LC3PLUS_DEC_HANDLE decHandle;
......@@ -486,11 +426,7 @@ static int tryOpenDecoderWithInvalidSampleRate( void )
static int encodeOneFrame( void )
{
ivas_error err;
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20000, .channels = 1, .samplerate = 48000 };
#endif
uint32_t bps = 128000;
ISAR_LC3PLUS_ENC_HANDLE encHandle;
......@@ -511,14 +447,10 @@ static int encodeOneFrame( void )
return err;
uint8_t *bitstream_out = malloc( bitstreamSizePerIvasFrame );
memset( bitstream_out, 0, bitstreamSizePerIvasFrame );
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
Word16 Q_in[16];
memset(Q_in, 0, sizeof(Q_in) );
err = ISAR_LC3PLUS_ENC_Encode( encHandle, pcm, bitstream_out, bitstreamSizePerIvasFrame, Q_in );
#else
err = ISAR_LC3PLUS_ENC_Encode( encHandle, pcm, bitstream_out );
#endif
if ( IVAS_ERR_OK != err )
return err;
......@@ -531,11 +463,7 @@ static int encodeOneFrame( void )
static int encodeAndDecodeOneMonoFrame( void )
{
ivas_error err;
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20000, .channels = 1, .samplerate = 48000 };
#endif
uint32_t bps = 128000;
ISAR_LC3PLUS_ENC_HANDLE encHandle;
......@@ -559,13 +487,9 @@ static int encodeAndDecodeOneMonoFrame( void )
uint8_t *bitstream_out = malloc( bitstreamSizePerIvasFrame );
memset( bitstream_out, 0, bitstreamSizePerIvasFrame );
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
Word16 Q_in[16];
memset(Q_in, 0, sizeof(Q_in) );
err = ISAR_LC3PLUS_ENC_Encode( encHandle, pcm_in, bitstream_out, bitstreamSizePerIvasFrame, Q_in );
#else
err = ISAR_LC3PLUS_ENC_Encode( encHandle, pcm_in, bitstream_out );
#endif
if ( IVAS_ERR_OK != err )
return err;
ISAR_LC3PLUS_ENC_Close( &encHandle );
......@@ -608,11 +532,7 @@ static int encodeAndDecodeOneMonoFrame( void )
static int encodeAndDecodeOneStereoFrameIvas20msLc3plus10ms_48kHz( void )
{
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20 * 1000, .channels = 2, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20 * 1000, .channels = 2, .samplerate = 48000 };
#endif
return encodeAndDecodeOneStereoFrame( config, DEFAULT_BPS );
}
......@@ -630,140 +550,84 @@ static int encodeAndDecodeOneStereoFrameIvas20msLc3plus10ms_16kHz( void )
static int encodeAndDecodeOneStereoFrameIvas5msLc3plus5ms_48kHz( void )
{
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5 * 1000, .channels = 2, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5 * 1000, .channels = 2, .samplerate = 48000 };
#endif
return encodeAndDecodeOneStereoFrame( config, DEFAULT_BPS );
}
static int encodeAndDecodeOneStereoFrameIvas10msLc3plus10ms_48kHz( void )
{
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5 * 1000, .channels = 2, .samplerate = 48000 };
#endif
return encodeAndDecodeOneStereoFrame( config, DEFAULT_BPS );
}
static int encodeAndDecodeOneMonoFrameIvas20msLc3plus10ms_48kHz( void )
{
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20 * 1000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 20 * 1000, .channels = 1, .samplerate = 48000 };
#endif
return encodeAndDecodeOneStereoFrame( config, DEFAULT_BPS );
}
static int encodeAndDecodeOneMonoFrameIvas5msLc3plus5ms_48kHz( void )
{
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5 * 1000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 5 * 1000, .isar_frame_duration_us = 5 * 1000, .channels = 1, .samplerate = 48000 };
#endif
return encodeAndDecodeOneStereoFrame( config, DEFAULT_BPS );
}
static int encodeAndDecodeOneStereoFrameIvas20msLc3plus2_5ms_48kHz( void )
{
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 2.5 * 1000, .isar_frame_duration_us = 20 * 1000, .channels = 2, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 2.5 * 1000, .isar_frame_duration_us = 20 * 1000, .channels = 2, .samplerate = 48000 };
#endif
return encodeAndDecodeOneStereoFrame( config, DEFAULT_BPS );
}
static int encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_80kbpsPerChannel( void )
{
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000 };
#endif
return encodeAndDecodeOneStereoFrame( config, config.channels * 82*1000 );
}
static int encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_96kbpsPerChannel( void )
{
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000 };
#endif
return encodeAndDecodeOneStereoFrame( config, config.channels * 98*1000 );
}
static int encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_124kbpsPerChannel( void )
{
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000 };
#endif
return encodeAndDecodeOneStereoFrame( config, config.channels * 126*1000 );
}
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
static int encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_800kbpsPerChannel( void )
{
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000 };
#endif
return encodeAndDecodeOneStereoFrame( config, config.channels * 800*1000 );
}
#endif
static int encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_204800bpsPerChannel( void )
{
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000 };
#endif
return encodeAndDecodeOneStereoFrame( config, config.channels * 204800 );
}
static int encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_205600bpsPerChannel( void )
{
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000 };
#endif
return encodeAndDecodeOneStereoFrame( config, config.channels * 205600 );
}
static int encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_206400bpsPerChannel( void )
{
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000 };
#endif
return encodeAndDecodeOneStereoFrame( config, config.channels * 206400 );
}
static int encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_207200bpsPerChannel( void )
{
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 1, .samplerate = 48000, .high_res_mode_enabled = 0 };
#else
LC3PLUS_CONFIG config = { .lc3plus_frame_duration_us = 10 * 1000, .isar_frame_duration_us = 10 * 1000, .channels = 2, .samplerate = 48000 };
#endif
return encodeAndDecodeOneStereoFrame( config, config.channels * 207200 );
}
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
#include "ivas_lc3plus_unit_test_payload_format.c"
#endif
int main(
int argc,
......@@ -841,11 +705,9 @@ int main(
ret = encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_124kbpsPerChannel();
if ( ret != 0 )
return 1;
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
ret = encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_800kbpsPerChannel();
if ( ret != 0 )
return 1;
#endif
/* start configs around the FDL threshold */
ret = encodeAndDecodeOneStereoFrameIvas10msLc3_10ms_48kHz_204800bpsPerChannel();
if ( ret != 0 )
......@@ -860,16 +722,8 @@ int main(
if ( ret != 0 )
return 1;
/* end configs around the FDL threshold */
#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS
ret = run_all_payload_tests();
if ( ret != 0 )
return 1;
#endif
return 0;
}
#else
int main( void )
{
return EXIT_SUCCESS;
}
#endif /* SPLIT_REND_WITH_HEAD_ROT */
......@@ -38,7 +38,7 @@ the United Nations Convention on Contracts on the International Sales of Goods.
#include "isar_lc3plus_common.h"
#include "isar_lc3plus_dec.h"
#include "ivas_error_utils.h"
#include "lc3.h"
#include "lc3plus.h"
#define MAX_SAMPLES_PER_CHANNEL 960 / 4
#define DEFAULT_BPS 256000
......
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
% Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
% Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
% Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
% contributors to this repository. All Rights Reserved.
%
% This software is protected by copyright law and by international treaties.
% The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
% Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
% Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
% Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
% contributors to this repository retain full ownership rights in their respective contributions in
% the software. This notice grants no license of any kind, including but not limited to patent
% license, nor is any license granted by implication, estoppel or otherwise.
%
% Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
% contributions.
%
% This software is provided "AS IS", without any express or implied warranties. The software is in the
% development stage. It is intended exclusively for experts who have experience with such software and
% solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
% and fitness for a particular purpose are hereby disclaimed and excluded.
%
% Any dispute, controversy or claim arising under or in relation to providing this software shall be
% submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
% accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
% the United Nations Convention on Contracts on the International Sales of Goods.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function Gen_Hrf_IVAS_Binary(dataSpec, modSpec, info)
%% Config
filePath = modSpec.folderMod; % Path for outputs
modelVersion = 3;
useModel = 0; % Indicates model format, '0' for Bspline model
useITD = 1; % use ITD model
always_48k_ITD = 1; % Use 48 kHz sampling for ITD model also for lower sampling rates, resampling done in real-time in C
resAzim = 1; % Resolution in degrees for sampled basis functions
resElev = 4; % Resolution in degreed for sampled basis functions
%% Load model
modelName = [dataSpec.dataBase, '_', ...
dataSpec.subjId, '_', modSpec.method, '_D_Model.mat'];
fn = fullfile(modSpec.folderMod, modelName);
load(fn,'mod');
mod_hrf_org = mod.mod.interp.hrf;
mod_itd_org = mod.mod.interp.itd;
fs_orig = 48000;
fs_last = 16000;
[mod.dat.hrf.hrf_latency, integer_latency, Q_latency, diff] = toInt32(mod.dat.hrf.hrf_latency);
if dataSpec.genRomFile
h_file_name = fullfile(dataSpec.romOutDir,'ivas_rom_TdBinauralRenderer_fx.h');
c_file_name = fullfile(dataSpec.romOutDir,'ivas_rom_TdBinauralRenderer_fx.c');
copyright_str = string(join({
'/******************************************************************************************************'
''
' (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,'
' Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,'
' Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,'
' Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other'
' contributors to this repository. All Rights Reserved.'
''
' This software is protected by copyright law and by international treaties.'
' The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,'
' Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,'
' Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,'
' Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other'
' contributors to this repository retain full ownership rights in their respective contributions in'
' the software. This notice grants no license of any kind, including but not limited to patent'
' license, nor is any license granted by implication, estoppel or otherwise.'
''
' Contributors are required to enter into the IVAS codec Public Collaboration agreement before making'
' contributions.'
''
' This software is provided "AS IS", without any express or implied warranties. The software is in the'
' development stage. It is intended exclusively for experts who have experience with such software and'
' solely for the purpose of inspection. All implied warranties of non-infringement, merchantability'
' and fitness for a particular purpose are hereby disclaimed and excluded.'
''
' Any dispute, controversy or claim arising under or in relation to providing this software shall be'
' submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in'
' accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and'
' the United Nations Convention on Contracts on the International Sales of Goods.'
''
'*******************************************************************************************************/'
''
}, newline));
%% Write out the header
fileID_h = fopen(h_file_name,'wt');
fprintf(fileID_h,'%s', copyright_str);
h_file_content = string(join({
''
''
'#ifndef _IVAS_ROM_TDBINAURALRENDERER_NEW_'
'#define _IVAS_ROM_TDBINAURALRENDERER_NEW_'
''
'#include <stdint.h>'
'#include "options.h"'
'#ifdef DEBUGGING'
'#include "debug.h"'
'#endif'
'#include "cnst.h"'
'#include "ivas_cnst.h"'
''
'/*-------------------------------------------------------------------------'
' * TD Binaural rendering related ROM tables'
' *------------------------------------------------------------------------*/'
'/* TD renderer default HRIR model */'
'#ifndef FIX_TDREND_HRTF_FILE_FORMAT'
'extern const Word32 defaultHRIR_rom_latency_s_fx; /* Q31 */'
'extern const Word16 defaultHRIR_rom_azimDim2[15]; /* Q0 */'
'extern const Word16 defaultHRIR_rom_azimDim3[15]; /* Q0 */'
'extern const Word16 defaultHRIR_rom_azim_start_idx[15]; /* Q0 */'
'extern const Word16 defaultHRIR_rom_azimSegSamples[1]; /* Q0 */'
'extern const Word16 defaultHRIR_rom_azimShapeIdx[15]; /* Q0 */'
'extern const Word16 defaultHRIR_rom_azimShapeSampFactor[15]; /* Q0 */'
'extern const Word32 defaultHRIR_rom_elevKSeq_fx[13]; /* Q22 */'
''
'extern const UWord32 defaultHRIR_rom_AlphaL48_fx[470 * 128]; /*Q30*/'
'extern const UWord32 defaultHRIR_rom_AlphaR48_fx[470 * 128]; /*Q30*/'
'extern const UWord32 defaultHRIR_rom_AlphaL32_fx[470 * 86]; /*Q30*/'
'extern const UWord32 defaultHRIR_rom_AlphaR32_fx[470 * 86]; /*Q30*/'
'extern const UWord32 defaultHRIR_rom_AlphaL16_fx[470 * 43]; /*Q30*/'
'extern const UWord32 defaultHRIR_rom_AlphaR16_fx[470 * 43]; /*Q30*/'
'extern const UWord32 defaultHRIR_rom_EL48_fx[HRTF_MODEL_N_SECTIONS * 470]; /*Q28*/'
'extern const UWord32 defaultHRIR_rom_ER48_fx[HRTF_MODEL_N_SECTIONS * 470]; /*Q28*/'
'extern const UWord32 defaultHRIR_rom_EL32_fx[HRTF_MODEL_N_SECTIONS * 470]; /*Q28*/'
'extern const UWord32 defaultHRIR_rom_ER32_fx[HRTF_MODEL_N_SECTIONS * 470]; /*Q28*/'
'extern const UWord32 defaultHRIR_rom_EL16_fx[HRTF_MODEL_N_SECTIONS * 470]; /*Q28*/'
'extern const UWord32 defaultHRIR_rom_ER16_fx[HRTF_MODEL_N_SECTIONS * 470]; /*Q28*/'
''
'extern const Word32 defaultHRIR_rom_elevBsShape_fx[36]; /*Q30*/'
'extern const Word32 defaultHRIR_rom_azimBsShape_fx[21]; /*Q30*/'
'extern const UWord32 defaultHRIR_rom_ITD_W_fx[658]; /*Q25*/'
'extern const Word32 defaultHRIR_rom_ITD_elevKSeq_fx[16]; /*Q22*/'
'extern const Word32 defaultHRIR_rom_ITD_elevBsShape_fx[28]; /*Q30*/'
'extern const Word32 defaultHRIR_rom_ITD_azimKSeq_fx[19]; /*Q22*/'
'extern const Word32 defaultHRIR_rom_ITD_azimBsShape_fx[84]; /*Q30*/'
''
'#else'
''
'extern const Word16 defaultHRIR_rom_latency_s_Q_fx;'
'extern const Word32 defaultHRIR_rom_latency_s_fx;'
'extern const Word16 defaultHRIR_rom_model_configuration[6];'
['extern const Word16 defaultHRIR_rom_azimDim3[' int2str(size(mod_hrf_org.elevBf{1}, 3)) '];']
['extern const Word16 defaultHRIR_rom_azim_start_idx[' int2str(size(mod_hrf_org.elevBf{1}, 3)) '];']
'extern const Word16 defaultHRIR_rom_azimSegSamples[1];'
['extern const Word16 defaultHRIR_rom_azimShapeIdx[' int2str(size(mod_hrf_org.elevBf{1}, 3)) '];']
['extern const Word16 defaultHRIR_rom_azimShapeSampFactor[' int2str(size(mod_hrf_org.elevBf{1}, 3)) '];']
'extern const Word16 defaultHRIR_rom_elevKSeq_Q_fx;'
['extern const Word16 defaultHRIR_rom_elevKSeq_fx[' int2str(length(mod_hrf_org.elevKSeq{1})) '];']
'extern const Word16 defaultHRIR_rom_Alpha48_Q_fx;'
['extern const Word16 defaultHRIR_rom_AlphaL48_fx[' int2str(size(mod_hrf_org.WL{1}, 1)) ' * ' int2str(size(mod_hrf_org.WL{1}, 2)) ']; /*Q30*/']
['extern const Word16 defaultHRIR_rom_AlphaR48_fx[' int2str(size(mod_hrf_org.WR{1}, 1)) ' * ' int2str(size(mod_hrf_org.WR{1}, 2)) ']; /*Q30*/']
'extern const Word16 defaultHRIR_rom_Alpha32_Q_fx;'
['extern const Word16 defaultHRIR_rom_AlphaL32_fx[' int2str(size(mod_hrf_org.WL{1}, 1)) ' * ' int2str(ceil(32*size(mod_hrf_org.WL{1}, 2)/48)) ']; /*Q30*/']
['extern const Word16 defaultHRIR_rom_AlphaR32_fx[' int2str(size(mod_hrf_org.WR{1}, 1)) ' * ' int2str(ceil(32*size(mod_hrf_org.WR{1}, 2)/48)) ']; /*Q30*/']
'extern const Word16 defaultHRIR_rom_Alpha16_Q_fx;'
['extern const Word16 defaultHRIR_rom_AlphaL16_fx[' int2str(size(mod_hrf_org.WL{1}, 1)) ' * ' int2str(ceil(16*size(mod_hrf_org.WL{1}, 2)/48)) ']; /*Q30*/']
['extern const Word16 defaultHRIR_rom_AlphaR16_fx[' int2str(size(mod_hrf_org.WR{1}, 1)) ' * ' int2str(ceil(16*size(mod_hrf_org.WR{1}, 2)/48)) ']; /*Q30*/']
'extern const Word16 defaultHRIR_rom_E48_Q_fx;'
['extern const Word32 defaultHRIR_rom_EL48_fx[HRTF_MODEL_N_SECTIONS * ' int2str(size(mod_hrf_org.WL{1}, 1)) ']; /*Q28*/']
['extern const Word32 defaultHRIR_rom_ER48_fx[HRTF_MODEL_N_SECTIONS * ' int2str(size(mod_hrf_org.WR{1}, 1)) ']; /*Q28*/']
'extern const Word16 defaultHRIR_rom_E32_Q_fx;'
['extern const Word32 defaultHRIR_rom_EL32_fx[HRTF_MODEL_N_SECTIONS * ' int2str(size(mod_hrf_org.WL{1}, 1)) ']; /*Q28*/']
['extern const Word32 defaultHRIR_rom_ER32_fx[HRTF_MODEL_N_SECTIONS * ' int2str(size(mod_hrf_org.WR{1}, 1)) ']; /*Q28*/']
'extern const Word16 defaultHRIR_rom_E16_Q_fx;'
['extern const Word32 defaultHRIR_rom_EL16_fx[HRTF_MODEL_N_SECTIONS * ' int2str(size(mod_hrf_org.WL{1}, 1)) ']; /*Q28*/']
['extern const Word32 defaultHRIR_rom_ER16_fx[HRTF_MODEL_N_SECTIONS * ' int2str(size(mod_hrf_org.WR{1}, 1)) ']; /*Q28*/']
'extern const Word16 defaultHRIR_rom_elevBsShape_Q_fx;'
'extern const Word16 defaultHRIR_rom_elevBsShape_fx[36]; /*Q30*/'
}, newline));
fprintf(fileID_h,'%s', h_file_content);
fclose(fileID_h);
%% Write out the header
fileID_c = fopen(c_file_name,'wt');
fprintf(fileID_c,'%s', copyright_str);
if ismac
username = getenv('USER');
else
username = getenv('username');
end
c_file_content = string(join({
''
'/* clang-format off */'
''
'#include <stdint.h>'
'#include "options.h"'
'#ifdef DEBUGGING'
'#include "debug.h"'
'#endif'
'#include "cnst.h"'
'#include "ivas_cnst.h"'
'#include "wmc_auto.h"'
''
'#define WMC_TOOL_SKIP'
''
'/*-------------------------------------------------------------------------'
' * TD Binaural rendering related ROM tables'
' *------------------------------------------------------------------------*/'
'/* TD renderer default HRIR model */'
''
}, newline));
fprintf(fileID_c,'%s', c_file_content);
fprintf(fileID_c, '#ifdef DEBUGGING\n');
fprintf(fileID_c, '/* Generated on %s with Matlab version %s by %s on %s */\n', datetime("today"), version, username, computer);
fprintf(fileID_c, '#endif\n');
fprintf(fileID_c, '\n');
fclose(fileID_c);
fileID_c = fopen(c_file_name,'at');
c_file_content = string(join({
[ ...
'const Word16 defaultHRIR_rom_latency_s_Q_fx = ' num2str(Q_latency) ';' newline ...
'const Word32 defaultHRIR_rom_latency_s_fx = ' num2str(integer_latency) ';' newline ...
'const float defaultHRIR_rom_latency_s = ' num2str(single(mod.dat.hrf.hrf_latency),'%.9f') 'f;']
''
}, newline));
fprintf(fileID_c,'%s', c_file_content);
fclose(fileID_c);
end
%% Generate paramters for model
for fs = [48000 32000 16000]
fs_khz = fs/1000;
% outputBinaryFileName = sprintf('hrfilter_model_v%03d_%dkHz.bin',modelVersion,fs_khz);
if dataSpec.genBinaryFile
outputBinaryFileName = sprintf(['td_' erase(info.fileNameHrf,'.sofa') '_model_v%03d_%dkHz.bin'],modelVersion,fs_khz);
end
% HR filters, sample basis functions
mod_hrf = mod_hrf_org;
mod_itd = mod_itd_org;
% Resample if needed
if fs ~= fs_orig
k_orig = size(mod_hrf.WL{1},2);
mod_hrf.WL{1} = (fs_orig/fs)*resample(mod_hrf.WL{1}',fs,fs_orig)';
mod_hrf.WR{1} = (fs_orig/fs)*resample(mod_hrf.WR{1}',fs,fs_orig)';
k = size(mod_hrf.WL{1},2);
resample_factor = fs/fs_orig;
if useITD && ~always_48k_ITD
% Rescale such that the number of samples corresponds to the correct delay.
mod_itd.W = mod_itd.W * resample_factor;
end
end
% Azimuth
M = length(mod_hrf.azimKSeq);
N = sum(unique([mod_hrf.azimBfNum{:}])~=1);
unique_azimKSeq = cell(N,1);
num_unique_splines = 0;
azimShapeIdx = -1*ones(M,1);
azimShapeSampFactor = -1*ones(M,1);
a_num_points = -1*ones(M,1);
a_range = cell(N,1);
azimBfVec = cell(N,1);
% Find basis function shapes
[azimBfNum_sorted, azimBfNum_sorted_idx] = sort([mod_hrf.azimBfNum{:}]);
last_L = -1; % previous number of basis functions
for m = 1:M
L = azimBfNum_sorted(m);
sm = azimBfNum_sorted_idx(m);
if(L == 1)
azimShapeIdx(sm) = -1;
azimShapeSampFactor(sm) = -1;
last_L = L;
elseif( L == last_L )
azimShapeIdx(sm) = num_unique_splines-1; % -1 for C code indexing
azimShapeSampFactor(sm) = 1;
elseif (last_L > 1 && rem(L,last_L)==0)
azimShapeIdx(sm) = num_unique_splines-1; % -1 for C code indexing
azimShapeSampFactor(sm) = L/last_L;
else
num_unique_splines = num_unique_splines+1;
a_knot_interval = (mod_hrf.azimKSeq{sm}(end)-mod_hrf.azimKSeq{sm}(1))/mod_hrf.azimBfNum{sm}; % deg between knot points
a_num_points(num_unique_splines) = ceil(a_knot_interval / resAzim);
a_step = a_knot_interval/a_num_points(num_unique_splines); % sampling in degrees
a_range{num_unique_splines} = mod_hrf.azimKSeq{sm}(1):a_step:mod_hrf.azimKSeq{sm}(end);
i = 1;
for a = a_range{num_unique_splines}
azimBfVec{num_unique_splines}(i,:) = BSplineSampVec( mod_hrf.azimBf{sm}, mod_hrf.azimKmSeq{sm}, a );
i = i+1;
end
unique_azimKSeq{num_unique_splines} = mod_hrf.azimKSeq{sm};
azimShapeIdx(sm) = num_unique_splines-1; % -1 for C code indexing
azimShapeSampFactor(sm) = 1;
last_L = L;
end
end
% Elevation
e_knot_interval = (mod_hrf.elevKSeq{1}(end)-mod_hrf.elevKSeq{1}(1))/(mod_hrf.elevBfNum{1}-3); % deg between knot points
e_num_points = ceil(e_knot_interval / resElev);
e_step = e_knot_interval/e_num_points; % sampling in degrees
e_range = mod_hrf.elevKSeq{1}(1):e_step:mod_hrf.elevKSeq{1}(end);
j=1;
elevBfVec = -1*ones(length(e_range),size(mod_hrf.elevBf{1},3));
for e = e_range
elevBfVec(j,:) = BSplineSampVec( mod_hrf.elevBf{1}, mod_hrf.elevKmSeq{1}, e );
j = j+1;
end
% HR azimuth shapes
azimSplineShape = cell(num_unique_splines,1);
len_a_shapes = cell(num_unique_splines,1);
for n = 1:num_unique_splines
b = azimBfVec{n}(:,2);
azimSplineShape{n} = b(1:2*a_num_points(n)+1);
len_a_shapes{n} = 2*a_num_points(n)+1;
end
% HR elevation shapes
elevSplineShape = [];
b1 = elevBfVec(:,1);
elevSplineShape{1} = b1(1:(e_num_points+1));
b2 = elevBfVec(:,2);
elevSplineShape{2} = b2(1:(e_num_points*2+1));
b3 = elevBfVec(:,3);
elevSplineShape{3} = b3(1:(e_num_points*3+1));
b4 = elevBfVec(:,4);
elevSplineShape{4} = b4((1:e_num_points*4+1));
elevSplineShape{4} = elevSplineShape{4}(1:(end+1)/2); % symmetric
len_e = [length(elevSplineShape{1}) length(elevSplineShape{2}) length(elevSplineShape{3}) length(elevSplineShape{4})];
start_e = [0, len_e(1), sum(len_e(1:2)), sum(len_e(1:3))];
elevSplineShape_all = [elevSplineShape{1};elevSplineShape{2};elevSplineShape{3};elevSplineShape{4}];
% ITD, generate basis functions
% Azimuth
resAzim = 1; % resolution, degrees
a_knot_interval_ITD = (mod_itd.azimKSeq{2}(end)-mod_itd.azimKSeq{2}(1))/((mod_itd.azimBfNum{2}+1)/2-3); % deg between knot points
a_num_points_ITD = ceil(a_knot_interval_ITD / resAzim);
a_step_ITD = a_knot_interval_ITD/a_num_points_ITD; % sampling in degrees
a_range_ITD = mod_itd.azimKSeq{2}(1):a_step_ITD:mod_itd.azimKSeq{2}(end);
azimBfVecITD = -1*ones(length(a_range_ITD),size(mod_itd.azimBf{2},3));
i = 1;
for a = a_range_ITD
azimBfVecITD(i,:) = BSplineSampVecITD( mod_itd.azimBf{2}, mod_itd.azimKmSeq{2}, a );
i = i+1;
end
% Elevation
e_knot_interval_ITD = (mod_itd.elevKSeq(end)-mod_itd.elevKSeq(1))/(mod_itd.elevBfNum-3); % deg between knot points
e_num_points_ITD = ceil(e_knot_interval_ITD / resElev);
e_step_ITD = e_knot_interval_ITD/e_num_points_ITD; % sampling in degrees
e_range_ITD = mod_itd.elevKSeq(1):e_step_ITD:mod_itd.elevKSeq(end);
elevBfVecITD = -1*ones(length(e_range_ITD),size(mod_itd.elevBf,3));
j=1;
for e = e_range_ITD
elevBfVecITD(j,:) = BSplineSampVecITD( mod_itd.elevBf, mod_itd.elevKmSeq, e );
j = j+1;
end
% ITD azimuth shapes
azimSplineShapeITD = [];
b1 = azimBfVecITD(:,1);
azimSplineShapeITD{1} = b1(1:(a_num_points_ITD+1));
b2 = azimBfVecITD(:,2);
azimSplineShapeITD{2} = b2(1:(a_num_points_ITD*2+1));
b3 = azimBfVecITD(:,3);
azimSplineShapeITD{3} = b3(1:(a_num_points_ITD*3+1));
b4 = azimBfVecITD(:,4);
azimSplineShapeITD{4} = b4((1:a_num_points_ITD*4+1));
azimSplineShapeITD{4} = azimSplineShapeITD{4}(1:(end+1)/2); % symmetric
len_a_ITD = [length(azimSplineShapeITD{1}) length(azimSplineShapeITD{2}) length(azimSplineShapeITD{3}) length(azimSplineShapeITD{4})];
start_a_ITD = [0, len_a_ITD(1), sum(len_a_ITD(1:2)), sum(len_a_ITD(1:3))];
azimSplineShapeITD_all = [azimSplineShapeITD{1};azimSplineShapeITD{2};azimSplineShapeITD{3};azimSplineShapeITD{4}];
% ITD elevation shapes
elevSplineShapeITD = [];
b1 = elevBfVecITD(:,1);
elevSplineShapeITD{1} = b1(1:(e_num_points_ITD+1));
b2 = elevBfVecITD(:,2);
elevSplineShapeITD{2} = b2(1:(e_num_points_ITD*2+1));
b3 = elevBfVecITD(:,3);
elevSplineShapeITD{3} = b3(1:(e_num_points_ITD*3+1));
b4 = elevBfVecITD(:,4);
elevSplineShapeITD{4} = b4((1:e_num_points_ITD*4+1));
elevSplineShapeITD{4} = elevSplineShapeITD{4}(1:(end+1)/2); % symmetric
len_e_ITD = [length(elevSplineShapeITD{1}) length(elevSplineShapeITD{2}) length(elevSplineShapeITD{3}) length(elevSplineShapeITD{4})];
start_e_ITD = [0, len_e_ITD(1), sum(len_e_ITD(1:2)), sum(len_e_ITD(1:3))];
elevSplineShapeITD_all = [elevSplineShapeITD{1};elevSplineShapeITD{2};elevSplineShapeITD{3};elevSplineShapeITD{4}];
% Elevation model structure
elevDim3 = size(mod_hrf.elevBf{1}, 3);
[float_elevKSeq, integer_elevKSeq, Q_elevKSeq, diff] = toInt16(mod_hrf.elevKSeq{1});
[float_WL, integer_WL, Q_WL, diff] = toInt16(mod_hrf.WL{1});
[float_WR, integer_WR, Q_WR, diff] = toInt16(mod_hrf.WR{1});
assert(Q_WL == Q_WR, 'hrir strongly asysmetric, cannot be used');
[float_elevSplineShape_all, integer_elevSplineShape_all, Q_elevSplineShape_all, diff] = toInt16(elevSplineShape_all);
for i = 1:elevDim3
[float_azimKSeq{i}, integer_azimKSeq{i}, Q_azimKSeq{i}, diff] = toInt16(mod_hrf.azimKSeq{i});
end
for i = 1:num_unique_splines
[float_azimSplineShape{i}, integer_azimSplineShape{i}, Q_azimSplineShape{i}, diff] = toInt16(azimSplineShape{i});
end
%% Write to binary file
% Open file
fclose('all');
if(exist(filePath, 'dir')==0)
mkdir(filePath);
end
if dataSpec.genBinaryFile
fileID = fopen(fullfile(filePath,outputBinaryFileName),'w');
end
% Header
% Format for file:
if dataSpec.genBinaryFile
% 0 = BSpline model
fwrite(fileID, useModel, 'short');
fwrite(fileID, Q_latency, "int16");
fwrite(fileID, integer_latency, "int32");
% ITD model active/inactive:
% 1 = ITD model is used
% 0 = ITD model is not used
fwrite(fileID, useITD, 'short');
% The sampling frequency in kHz of the HR filter set:
fwrite(fileID, fs_khz, 'short');
% General - model-specific parts
fwrite(fileID, size(mod_hrf.WR{1}, 2), 'short'); % K, filter length
fwrite(fileID, elevDim3, 'short'); % elevDim3 = P
fwrite(fileID, Q_elevKSeq, "int16");
fwrite(fileID, integer_elevKSeq, 'int16');
% Azimuth model structure
azim_start_idx = 0;
for i = 1:elevDim3
azimDim3 = size(mod_hrf.azimBf{i}, 3);
fwrite(fileID, azimDim3, 'short'); % azimDim3 = Q
fwrite(fileID, azim_start_idx, 'short'); % start azim index per elevation
azim_start_idx = azim_start_idx + azimDim3;
fwrite(fileID, Q_azimKSeq{i}, "int16");
fwrite(fileID, integer_azimKSeq{i}, "int16");
end
end
% Azimuth model structure
azim_start_idx = 0;
c_file_content_dim3 = {
['const int16_t defaultHRIR_rom_azimDim3[' num2str(elevDim3) '] = {']
};
c_file_content_start_idx = {
['const int16_t defaultHRIR_rom_azim_start_idx[' num2str(elevDim3) '] = {']
};
content_dim2 = '';
content_dim3 = '';
content_start_idx = '';
for i = 1:elevDim3
azimDim2 = size(mod_hrf.azimBf{i}, 2);
azimDim3 = size(mod_hrf.azimBf{i}, 3);
content_dim3 = [content_dim3 int2str(azimDim3) ', '];
content_start_idx = [content_start_idx int2str(azim_start_idx) ', '];
azim_start_idx = azim_start_idx + azimDim3;
end
if fs == fs_orig && dataSpec.genRomFile
fileID_c = fopen(c_file_name,'at');
c_file_content_dim3{size(c_file_content_dim3,2)+1} = content_dim3;
c_file_content_dim3{size(c_file_content_dim3,2)+1} = '};';
c_file_content_dim3{size(c_file_content_dim3,2)+1} = '';
c_file_content_start_idx{size(c_file_content_start_idx,2)+1} = content_start_idx;
c_file_content_start_idx{size(c_file_content_start_idx,2)+1} = '};';
c_file_content_start_idx{size(c_file_content_start_idx,2)+1} = '';
c_file_content = ...
['const int16_t defaultHRIR_rom_model_configuration[6] = {' newline ];
fprintf(fileID_c,'%s', c_file_content);
c_file_content = [ num2str(useITD) ', /* UseItdModel */' newline ];
fprintf(fileID_c,'%s', c_file_content);
c_file_content = [ num2str(elevDim3) ', /* elevDim3 */' newline ];
fprintf(fileID_c,'%s', c_file_content);
c_file_content = [ num2str(size(mod_hrf_org.WL{1}, 1)) ', /* AlphaN */' newline ];
fprintf(fileID_c,'%s', c_file_content);
c_file_content = [ num2str(num_unique_splines) ', /* num_unique_azim_splines */' newline ];
fprintf(fileID_c,'%s', c_file_content);
c_file_content = [ num2str(e_num_points) ', /* elevSegSamples */' newline ];
fprintf(fileID_c,'%s', c_file_content);
c_file_content = [ num2str(size(mod_hrf_org.WL{1}, 2)) ', /* K_48k */' newline ];
fprintf(fileID_c,'%s', c_file_content);
c_file_content = ['};' newline ];
fprintf(fileID_c,'%s', c_file_content);
arr_str = join(mat2str((single(len_e))));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, ";",',');
arr_str = replace(arr_str, " ",', ');
c_file_content = ...
['const int16_t defaultHRIR_rom_elevBsLen[' num2str(length(len_e)) '] = {' newline ...
arr_str ...
newline '};' newline ...
];
fprintf(fileID_c,'%s', c_file_content);
arr_str = join(mat2str((single(start_e))));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, ";",',');
arr_str = replace(arr_str, " ",', ');
c_file_content = ...
['const int16_t defaultHRIR_rom_elevBsStart[' num2str(length(start_e)) '] = {' newline ...
arr_str ...
newline '};' newline ...
];
fprintf(fileID_c,'%s', c_file_content);
c_file_content = string(join(c_file_content_dim3,newline));
fprintf(fileID_c,'%s', c_file_content);
c_file_content = string(join(c_file_content_start_idx,newline));
fprintf(fileID_c,'%s', c_file_content);
arr_str = join(mat2str((single(a_num_points(1:num_unique_splines)))));
if(num_unique_splines>1)
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, ";",',');
arr_str = replace(arr_str, " ",', ');
else
arr_str(end+1) = ',';
end
c_file_content = ['const int16_t defaultHRIR_rom_azimSegSamples[' num2str(num_unique_splines) '] = {' newline arr_str newline '};' newline];
fprintf(fileID_c,'%s', c_file_content);
arr_str = mat2str(azimShapeIdx);
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str,';', ', ');
c_file_content = ...
['const int16_t defaultHRIR_rom_azimShapeIdx[' num2str(length(azimShapeIdx)) '] = {' newline ...
arr_str ...
newline '};' newline ...
];
fprintf(fileID_c,'%s', c_file_content);
arr_str = mat2str(azimShapeSampFactor);
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str,';', ', ');
c_file_content = ...
['const int16_t defaultHRIR_rom_azimShapeSampFactor[' num2str(length(azimShapeSampFactor)) '] = {' newline ...
arr_str ...
newline '};' newline ...
];
fprintf(fileID_c,'%s', c_file_content);
if dataSpec.makeFxFltBE
arr_str = mat2str(float_elevKSeq);
else
arr_str = mat2str(mod_hrf_org.elevKSeq{1});
end
arr_str = arr_str(2:end);
arr_str(end) = ' ';
arr_str = replace(arr_str,' ', '.000000f, ');
arr_str_fx = mat2str(integer_elevKSeq);
arr_str_fx = arr_str_fx(2:end);
arr_str_fx(end) = ' ';
arr_str_fx = replace(arr_str_fx,' ', ', ');
c_file_content = ...
['const float defaultHRIR_rom_elevKSeq[' num2str(length(mod_hrf.elevKSeq{1})) '] = {' newline ...
arr_str ...
newline '};' newline ...
'const Word16 defaultHRIR_rom_elevKSeq_Q_fx = ' num2str(Q_elevKSeq) ';' newline ...
'const Word16 defaultHRIR_rom_elevKSeq_fx [' num2str(length(mod_hrf.elevKSeq{1})) '] = {' newline ...
arr_str_fx ...
newline '};' newline ...
];
fprintf(fileID_c,'%s', c_file_content);
fclose(fileID_c);
end
if dataSpec.genBinaryFile
% Weights
fwrite(fileID, size(mod_hrf.WL{1},1), 'short'); % (P*Q)
fwrite(fileID, Q_WL, "int16");
fwrite(fileID, integer_WL, 'int16'); % (P*Q) by K
% fwrite(fileID, Q_WR, "int16");
fwrite(fileID, integer_WR, 'int16'); % (P*Q) by K
% Azimuth basis functions
fwrite(fileID, num_unique_splines, 'short'); % number of unique spline functions
for i = 1:num_unique_splines
fwrite(fileID, len_a_shapes{i}, 'short'); % length of azimuth shape
fwrite(fileID, Q_azimSplineShape{i}, "int16");
fwrite(fileID, integer_azimSplineShape{i}, 'int16'); % azimuth shape
fwrite(fileID, a_num_points(i), 'short'); % samples between knot points
end
fwrite(fileID, azimShapeIdx, 'short'); % indices for spline functions to use
fwrite(fileID, azimShapeSampFactor, 'short'); % decimation factor for spline functions
% Elevation basis functions
fwrite(fileID, len_e, 'short'); % length of elevation shapes
fwrite(fileID, start_e, 'short'); % start idx (C indexing) of elevation shapes
fwrite(fileID, length(elevSplineShape_all), 'short'); % total length elevation shapes
fwrite(fileID, Q_elevSplineShape_all, "int16");
fwrite(fileID, integer_elevSplineShape_all, 'int16'); % azimuth shape
fwrite(fileID, e_num_points, 'short'); % samples between knot points
end
if fs == fs_orig && dataSpec.genRomFile
fileID_c = fopen(c_file_name,'at');
if dataSpec.makeFxFltBE
arr_str = join(mat2str(num2hex(single(float_elevSplineShape_all))));
else
arr_str = join(mat2str(num2hex(single(elevSplineShape_all))));
end
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, "';",',');
arr_str = replace(arr_str, "'",'0x');
arr_str_fx = join(mat2str(integer_elevSplineShape_all));
arr_str_fx = arr_str_fx(2:end);
arr_str_fx(end) = ';';
arr_str_fx = replace(arr_str_fx, ";",', ');
c_file_content = [...
'const uint32_t defaultHRIR_rom_elevBsShape[' num2str(length(elevSplineShape_all)) '] = {' newline ...
arr_str newline '};' newline ...
'const Word16 defaultHRIR_rom_elevBsShape_Q_fx = ' num2str(Q_elevSplineShape_all) ';' newline ...
'const Word16 defaultHRIR_rom_elevBsShape_fx[' num2str(length(elevSplineShape_all)) '] = {' newline ...
arr_str_fx newline '};' newline ...
];
fprintf(fileID_c,'%s', c_file_content);
if dataSpec.makeFxFltBE
arr_str = join(mat2str(num2hex(single(float_azimSplineShape{n}))));
else
arr_str = join(mat2str(num2hex(single(azimSplineShape{n}))));
end
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, "';",',');
arr_str = replace(arr_str, "'",'0x');
arr_str_fx = join(mat2str(integer_azimSplineShape{n}));
arr_str_fx = arr_str_fx(2:end);
arr_str_fx(end) = ';';
arr_str_fx = replace(arr_str_fx, ";",', ');
c_file_content = [...
'const uint32_t defaultHRIR_rom_azimBsShape[' num2str(length(azimSplineShape{n})) '] = {' newline ...
arr_str newline '};' newline ...
'const Word16 defaultHRIR_rom_azimBsShape_Q_fx = ' num2str(Q_azimSplineShape{n}) ';' newline ...
'const Word16 defaultHRIR_rom_azimBsShape_fx[' num2str(length(azimSplineShape{n})) '] = {' newline ...
arr_str_fx newline '};' newline ...
];
fprintf(fileID_c,'%s', c_file_content);
fclose(fileID_c);
end
if dataSpec.genRomFile
fileID_c = fopen(c_file_name,'at');
if dataSpec.makeFxFltBE
arr_str_all = num2hex(single(float_WL));
else
arr_str_all = num2hex(single(mod_hrf.WL{1}));
end
numCol = 25;
numIter = floor(size(mod_hrf.WL{1},1)*size(mod_hrf.WL{1},2)/numCol);
numRemain = size(mod_hrf.WL{1},1)*size(mod_hrf.WL{1},2) - numCol * numIter;
c_file_content = ...
['const uint32_t defaultHRIR_rom_AlphaL' num2str(fs/1000) '[' int2str(size(mod_hrf.WL{1}, 1)) ' * ' int2str(size(mod_hrf.WL{1}, 2)) '] = {' newline ];
fprintf(fileID_c,'%s', c_file_content);
for ind = 1: numIter
arr_str = join(mat2str(arr_str_all((ind-1) * numCol + 1 :ind * numCol, : )));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, "';",',');
arr_str = replace(arr_str, "'",'0x');
c_file_content = [ arr_str newline];
fprintf(fileID_c,'%s', c_file_content);
end
arr_str = join(mat2str(arr_str_all(ind * numCol + 1 :ind * numCol + numRemain, : )));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, "';",',');
arr_str = replace(arr_str, "'",'0x');
c_file_content = [ arr_str newline '};' newline];
fprintf(fileID_c,'%s', c_file_content);
arr_str_all_fx = reshape(integer_WL,[],1);
numCol = 25;
numIter = floor(size(mod_hrf.WL{1},1)*size(mod_hrf.WL{1},2)/numCol);
numRemain = size(mod_hrf.WL{1},1)*size(mod_hrf.WL{1},2) - numCol * numIter;
c_file_content = ...
[ ...
'const Word16 defaultHRIR_rom_Alpha' num2str(fs/1000) '_Q_fx = ' num2str(Q_WL) ';' newline ...
'const Word16 defaultHRIR_rom_AlphaL' num2str(fs/1000) '_fx[' int2str(size(mod_hrf.WL{1}, 1)) ' * ' int2str(size(mod_hrf.WL{1}, 2)) '] = {' newline ];
fprintf(fileID_c,'%s', c_file_content);
for ind = 1: numIter
arr_str = join(mat2str(arr_str_all_fx((ind-1) * numCol + 1 :ind * numCol, : )));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, ";",',');
c_file_content = [ arr_str newline];
fprintf(fileID_c,'%s', c_file_content);
end
arr_str = join(mat2str(arr_str_all_fx(ind * numCol + 1 :ind * numCol + numRemain, : )));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, ";",',');
c_file_content = [ arr_str newline '};' newline];
fprintf(fileID_c,'%s', c_file_content);
if dataSpec.makeFxFltBE
arr_str_all = num2hex(single(float_WR));
else
arr_str_all = num2hex(single(mod_hrf.WR{1}));
end
numCol = 25;
numIter = floor(size(mod_hrf.WR{1},1)*size(mod_hrf.WR{1},2)/numCol);
numRemain = size(mod_hrf.WR{1},1)*size(mod_hrf.WR{1},2) - numCol * numIter;
c_file_content = ...
[ ...
'const uint32_t defaultHRIR_rom_AlphaR' num2str(fs/1000) '[' int2str(size(mod_hrf.WR{1}, 1)) ' * ' int2str(size(mod_hrf.WR{1}, 2)) '] = {' newline ];
fprintf(fileID_c,'%s', c_file_content);
for ind = 1: numIter
arr_str = join(mat2str(arr_str_all((ind-1) * numCol + 1 :ind * numCol, : )));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, "';",',');
arr_str = replace(arr_str, "'",'0x');
c_file_content = [ arr_str newline];
fprintf(fileID_c,'%s', c_file_content);
end
arr_str = join(mat2str(arr_str_all(ind * numCol + 1 :ind * numCol + numRemain, : )));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, "';",',');
arr_str = replace(arr_str, "'",'0x');
c_file_content = [ arr_str newline '};' newline];
fprintf(fileID_c,'%s', c_file_content);
arr_str_all_fx = reshape(integer_WR,[],1);
numCol = 25;
numIter = floor(size(mod_hrf.WR{1},1)*size(mod_hrf.WR{1},2)/numCol);
numRemain = size(mod_hrf.WR{1},1)*size(mod_hrf.WR{1},2) - numCol * numIter;
c_file_content = ...
[ ...
'const Word16 defaultHRIR_rom_AlphaR' num2str(fs/1000) '_fx[' int2str(size(mod_hrf.WR{1}, 1)) ' * ' int2str(size(mod_hrf.WR{1}, 2)) '] = {' newline ];
fprintf(fileID_c,'%s', c_file_content);
for ind = 1: numIter
arr_str = join(mat2str(arr_str_all_fx((ind-1) * numCol + 1 :ind * numCol, : )));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, ";",',');
c_file_content = [ arr_str newline];
fprintf(fileID_c,'%s', c_file_content);
end
arr_str = join(mat2str(arr_str_all_fx(ind * numCol + 1 :ind * numCol + numRemain, : )));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, ";",',');
c_file_content = [ arr_str newline '};' newline];
fprintf(fileID_c,'%s', c_file_content);
fclose(fileID_c);
end
HRTF_MODEL_N_SECTIONS = 3;
AlphaN = size(mod_hrf.WL{1}, 1);
K = size(mod_hrf.WL{1}, 2);
sec_length = int32(floor(K / HRTF_MODEL_N_SECTIONS));
iSecFirst = zeros(HRTF_MODEL_N_SECTIONS,1,'int32');
iSecLast = zeros(HRTF_MODEL_N_SECTIONS,1,'int32');
for i = 1:HRTF_MODEL_N_SECTIONS
iSecFirst(i) = (i -1) * sec_length;
end
for i = 1:HRTF_MODEL_N_SECTIONS - 1
iSecLast(i) = i * sec_length - 1;
end
iSecLast(HRTF_MODEL_N_SECTIONS) = K - 1;
EL = zeros( HRTF_MODEL_N_SECTIONS * AlphaN, 1, 'single');
ER = zeros( HRTF_MODEL_N_SECTIONS * AlphaN, 1, 'single');
ind = 1;
for i = 1:HRTF_MODEL_N_SECTIONS
for j = 1:AlphaN
indAlpha = iSecFirst(i) * AlphaN + j;
indK = 0;
EL(ind) = 0;
ER(ind) = 0;
for k = iSecFirst(i) : iSecLast(i) -1
if dataSpec.makeFxFltBE
tmp = single(float_WL(indAlpha + indK));
else
tmp = single(mod_hrf.WL{1}(indAlpha + indK));
end
EL(ind) = EL(ind) + tmp^2;
if dataSpec.makeFxFltBE
tmp = single(float_WR(indAlpha + indK));
else
tmp = single(mod_hrf.WR{1}(indAlpha + indK));
end
ER(ind) = ER(ind) + tmp^2;
indK = indK +AlphaN;
end
ind = ind + 1;
end
end
[float_EL, integer_EL, Q_EL, diff] = toInt32(EL);
[float_ER, integer_ER, Q_ER, diff] = toInt32(ER);
assert(Q_EL == Q_ER, 'hrir strongly asysmetric, cannot be used');
if dataSpec.genBinaryFile
fwrite(fileID, Q_EL, "int16");
fwrite(fileID, integer_EL, 'int32');
fwrite(fileID, integer_ER, 'int32');
end
if dataSpec.genRomFile
fileID_c = fopen(c_file_name,'at');
if dataSpec.makeFxFltBE
arr_str_all = num2hex(float_EL);
else
arr_str_all = num2hex(single(EL));
end
numCol = 25;
numIter = floor(HRTF_MODEL_N_SECTIONS*size(mod_hrf.WL{1},1)/numCol);
numRemain = HRTF_MODEL_N_SECTIONS*size(mod_hrf.WL{1},1) - numCol * numIter;
c_file_content = [...
'const uint32_t defaultHRIR_rom_EL' num2str(fs/1000) '[HRTF_MODEL_N_SECTIONS * ' int2str(size(mod_hrf.WL{1}, 1)) '] = {' newline ];
fprintf(fileID_c,'%s', c_file_content);
for ind = 1: numIter
arr_str = join(mat2str(arr_str_all((ind-1) * numCol + 1 :ind * numCol, : )));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, "';",',');
arr_str = replace(arr_str, "'",'0x');
c_file_content = [ arr_str newline];
fprintf(fileID_c,'%s', c_file_content);
end
arr_str = join(mat2str(arr_str_all(ind * numCol + 1 :ind * numCol + numRemain, : )));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, "';",',');
arr_str = replace(arr_str, "'",'0x');
c_file_content = [ arr_str newline '};' newline];
fprintf(fileID_c,'%s', c_file_content);
arr_str_all_fx = reshape(integer_EL,[],1);
numCol = 25;
numIter = floor(HRTF_MODEL_N_SECTIONS*size(mod_hrf.WL{1},1)/numCol);
numRemain = HRTF_MODEL_N_SECTIONS*size(mod_hrf.WL{1},1) - numCol * numIter;
c_file_content = ...
[ ...
'const Word16 defaultHRIR_rom_E' num2str(fs/1000) '_Q_fx = ' num2str(Q_EL) ';' newline ...
'const Word32 defaultHRIR_rom_EL' num2str(fs/1000) '_fx[HRTF_MODEL_N_SECTIONS * ' int2str(size(mod_hrf.WL{1}, 1)) '] = {' newline ];
fprintf(fileID_c,'%s', c_file_content);
for ind = 1: numIter
arr_str = join(mat2str(arr_str_all_fx((ind-1) * numCol + 1 :ind * numCol, : )));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, ";",',');
c_file_content = [ arr_str newline];
fprintf(fileID_c,'%s', c_file_content);
end
arr_str = join(mat2str(arr_str_all_fx(ind * numCol + 1 :ind * numCol + numRemain, : )));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, ";",',');
c_file_content = [ arr_str newline '};' newline ...
];
fprintf(fileID_c,'%s', c_file_content);
if dataSpec.makeFxFltBE
arr_str_all = num2hex(float_ER);
else
arr_str_all = num2hex(single(ER));
end
numCol = 25;
numIter = floor(HRTF_MODEL_N_SECTIONS*size(mod_hrf.WR{1},1)/numCol);
numRemain = HRTF_MODEL_N_SECTIONS*size(mod_hrf.WR{1},1) - numCol * numIter;
c_file_content = [...
newline 'const uint32_t defaultHRIR_rom_ER' num2str(fs/1000) '[HRTF_MODEL_N_SECTIONS * ' int2str(size(mod_hrf.WR{1}, 1)) '] = {' newline ];
fprintf(fileID_c,'%s', c_file_content);
for ind = 1: numIter
arr_str = join(mat2str(arr_str_all((ind-1) * numCol + 1 :ind * numCol, : )));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, "';",',');
arr_str = replace(arr_str, "'",'0x');
c_file_content = [ arr_str newline];
fprintf(fileID_c,'%s', c_file_content);
end
arr_str = join(mat2str(arr_str_all(ind * numCol + 1 :ind * numCol + numRemain, : )));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, "';",',');
arr_str = replace(arr_str, "'",'0x');
c_file_content = [ arr_str newline '};' newline];
fprintf(fileID_c,'%s', c_file_content);
arr_str_all_fx = reshape(integer_ER,[],1);
numCol = 25;
numIter = floor(HRTF_MODEL_N_SECTIONS*size(mod_hrf.WR{1},1)/numCol);
numRemain = HRTF_MODEL_N_SECTIONS*size(mod_hrf.WR{1},1) - numCol * numIter;
c_file_content = ...
[ ...
'const Word32 defaultHRIR_rom_ER' num2str(fs/1000) '_fx[HRTF_MODEL_N_SECTIONS * ' int2str(size(mod_hrf.WR{1}, 1)) '] = {' newline ];
fprintf(fileID_c,'%s', c_file_content);
for ind = 1: numIter
arr_str = join(mat2str(arr_str_all_fx((ind-1) * numCol + 1 :ind * numCol, : )));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, ";",',');
c_file_content = [ arr_str newline];
fprintf(fileID_c,'%s', c_file_content);
end
arr_str = join(mat2str(arr_str_all_fx(ind * numCol + 1 :ind * numCol + numRemain, : )));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, ";",',');
c_file_content = [ arr_str newline '};' newline ...
];
fprintf(fileID_c,'%s', c_file_content);
fclose(fileID_c);
end
% If ITD model is used, parameters are stored in 2nd part of the same file
if useITD
% General
%fwrite(fileID, size(mod_itd.W, 2), 'short'); % K = 1 always for ITD, so do not need to write.
[float_elevKSeq_itd, integer_elevKSeq_itd, Q_elevKSeq_itd, diff] = toInt16(mod_itd.elevKSeq);
[float_itd_azimKSeq, integer_itd_azimKSeq, Q_itd_azimKSeq, diff] = toInt16(mod_itd.azimKSeq{2});
[float_itd_W, integer_itd_W, Q_itd_W, diff] = toInt16(mod_itd.W);
[float_azimSplineShapeITD_all, integer_azimSplineShapeITD_all, Q_azimSplineShapeITD_all, diff] = toInt16(azimSplineShapeITD_all);
[float_elevSplineShapeITD_all, integer_elevSplineShapeITD_all, Q_elevSplineShapeITD_all, diff] = toInt16(elevSplineShapeITD_all);
% Elevation model structure
elevDim3 = size(mod_itd.elevBf, 3);
% Azimuth model structure
azimDim3 = size(mod_itd.azimBf{2}, 3);
if dataSpec.genBinaryFile
fwrite(fileID, elevDim3, 'short'); % elevDim3 = P
fwrite(fileID, Q_elevKSeq_itd, "int16");
fwrite(fileID, integer_elevKSeq_itd, 'int16');
fwrite(fileID, azimDim3, 'short'); % azimDim3 = Q
fwrite(fileID, Q_itd_azimKSeq, "int16");
fwrite(fileID, integer_itd_azimKSeq, 'int16');
% Weights
fwrite(fileID, size(mod_itd.W,1), 'short'); % (P*Q)
fwrite(fileID, Q_itd_W, "int16");
fwrite(fileID, integer_itd_W, 'int16');
% Azimuth basis functions
fwrite(fileID, len_a_ITD, 'short'); % length of azimuth shapes
fwrite(fileID, start_a_ITD, 'short'); % start idx (C indexing) of azimuth shapes
fwrite(fileID, length(azimSplineShapeITD_all), 'short'); % total length azimuth shapes
fwrite(fileID, Q_azimSplineShapeITD_all, "int16");
fwrite(fileID, integer_azimSplineShapeITD_all, 'int16'); % azimuth shape
fwrite(fileID, a_num_points_ITD, 'short'); % samples between knot points
% Elevation basis functions
fwrite(fileID, len_e_ITD, 'short'); % length of elevation shapes
fwrite(fileID, start_e_ITD, 'short'); % start idx (C indexing) of elevation shapes
fwrite(fileID, length(elevSplineShapeITD_all), 'short'); % total length elevation shapes
fwrite(fileID, Q_elevSplineShapeITD_all, "int16");
fwrite(fileID, integer_elevSplineShapeITD_all, 'int16'); % elevation shapes
fwrite(fileID, e_num_points_ITD, 'short'); % samples between knot points
end
if fs == fs_last && dataSpec.genRomFile
fileID_c = fopen(c_file_name,'at');
if dataSpec.makeFxFltBE
arr_str_all = num2hex(single(float_itd_W));
else
arr_str_all = num2hex(single(mod_itd.W));
end
numCol = 25;
numIter = floor(length(mod_itd.W)/numCol);
numRemain = length(mod_itd.W) - numCol * numIter;
c_file_content = [...
'const uint32_t defaultHRIR_rom_ITD_W[' num2str(length(mod_itd.W)) '] = {' newline ];
fprintf(fileID_c,'%s', c_file_content);
for ind = 1: numIter
arr_str = join(mat2str(arr_str_all((ind-1) * numCol + 1 :ind * numCol, : )));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, "';",',');
arr_str = replace(arr_str, "'",'0x');
c_file_content = [ arr_str newline];
fprintf(fileID_c,'%s', c_file_content);
end
arr_str = join(mat2str(arr_str_all(ind * numCol + 1 :ind * numCol + numRemain, : )));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, "';",',');
arr_str = replace(arr_str, "'",'0x');
c_file_content = [ arr_str newline '};' newline];
fprintf(fileID_c,'%s', c_file_content);
arr_str_all_fx = reshape(integer_itd_W,[], 1);
numCol = 25;
numIter = floor(length(mod_itd.W)/numCol);
numRemain = length(mod_itd.W) - numCol * numIter;
c_file_content = ...
[...
'const Word16 defaultHRIR_rom_ITD_W_Q_fx = ' num2str(Q_itd_W) ';' newline ...
'const Word16 defaultHRIR_rom_ITD_W_fx[' num2str(length(mod_itd.W)) '] = {' newline ];
fprintf(fileID_c,'%s', c_file_content);
for ind = 1: numIter
arr_str = join(mat2str(arr_str_all_fx((ind-1) * numCol + 1 :ind * numCol, : )));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, ";",',');
c_file_content = [ arr_str newline];
fprintf(fileID_c,'%s', c_file_content);
end
arr_str = join(mat2str(arr_str_all_fx(ind * numCol + 1 :ind * numCol + numRemain, : )));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, ";",',');
c_file_content = [ arr_str newline '};' newline ...
];
fprintf(fileID_c,'%s', c_file_content);
c_file_content = ...
['const int16_t defaultHRIR_rom_ITD_model_configuration[4] = {' newline ];
fprintf(fileID_c,'%s', c_file_content);
c_file_content = [ num2str(elevDim3) ', /* elevDim3 */' newline ];
fprintf(fileID_c,'%s', c_file_content);
c_file_content = [ num2str(azimDim3) ', /* azimDim3 */' newline ];
fprintf(fileID_c,'%s', c_file_content);
c_file_content = [ num2str(e_num_points_ITD) ', /* elevSegSamples */' newline ];
fprintf(fileID_c,'%s', c_file_content);
c_file_content = [ num2str(a_num_points_ITD) ', /* azimSegSamples */' newline ];
fprintf(fileID_c,'%s', c_file_content);
c_file_content = ['};' newline ];
fprintf(fileID_c,'%s', c_file_content);
arr_str = join(mat2str((single(len_e_ITD))));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, ";",',');
arr_str = replace(arr_str, " ",', ');
c_file_content = ...
['const int16_t defaultHRIR_rom_ITD_elevBsLen[' num2str(length(len_e_ITD)) '] = {' newline ...
arr_str ...
newline '};' newline ...
];
fprintf(fileID_c,'%s', c_file_content);
arr_str = join(mat2str((single(start_e_ITD))));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, ";",',');
arr_str = replace(arr_str, " ",', ');
c_file_content = ...
['const int16_t defaultHRIR_rom_ITD_elevBsStart[' num2str(length(start_e_ITD)) '] = {' newline ...
arr_str ...
newline '};' newline ...
];
fprintf(fileID_c,'%s', c_file_content);
arr_str = join(mat2str((single(len_a_ITD))));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, ";",',');
arr_str = replace(arr_str, " ",', ');
c_file_content = ...
['const int16_t defaultHRIR_rom_ITD_azimBsLen[' num2str(length(len_a_ITD)) '] = {' newline ...
arr_str ...
newline '};' newline ...
];
fprintf(fileID_c,'%s', c_file_content);
arr_str = join(mat2str((single(start_a_ITD))));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, ";",',');
arr_str = replace(arr_str, " ",', ');
c_file_content = ...
['const int16_t defaultHRIR_rom_ITD_azimBsStart[' num2str(length(start_a_ITD)) '] = {' newline ...
arr_str ...
newline '};' newline ...
];
fprintf(fileID_c,'%s', c_file_content);
if dataSpec.makeFxFltBE
arr_str_all = num2hex(single(float_azimSplineShapeITD_all));
else
arr_str_all = num2hex(single(azimSplineShapeITD_all));
end
numCol = 25;
numIter = floor(length(azimSplineShapeITD_all)/numCol);
numRemain = length(azimSplineShapeITD_all) - numCol * numIter;
c_file_content = [...
'const uint32_t defaultHRIR_rom_ITD_azimBsShape[' num2str(length(azimSplineShapeITD_all)) '] = {' newline ];
fprintf(fileID_c,'%s', c_file_content);
for ind = 1: numIter
arr_str = join(mat2str(arr_str_all((ind-1) * numCol + 1 :ind * numCol, : )));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, "';",',');
arr_str = replace(arr_str, "'",'0x');
c_file_content = [ arr_str newline];
fprintf(fileID_c,'%s', c_file_content);
end
arr_str = join(mat2str(arr_str_all(ind * numCol + 1 :ind * numCol + numRemain, : )));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, "';",',');
arr_str = replace(arr_str, "'",'0x');
c_file_content = [ arr_str newline '};' newline];
fprintf(fileID_c,'%s', c_file_content);
arr_str_all_fx = reshape(integer_azimSplineShapeITD_all, [], 1);
numCol = 25;
numIter = floor(length(azimSplineShapeITD_all)/numCol);
numRemain = length(azimSplineShapeITD_all) - numCol * numIter;
c_file_content = ...
[...
'const Word16 defaultHRIR_rom_ITD_azimBsShape_Q_fx = ' num2str(Q_azimSplineShapeITD_all) ';' newline ...
'const Word16 defaultHRIR_rom_ITD_azimBsShape_fx[' num2str(length(azimSplineShapeITD_all)) '] = {' newline ];
fprintf(fileID_c,'%s', c_file_content);
for ind = 1: numIter
arr_str = join(mat2str(arr_str_all_fx((ind-1) * numCol + 1 :ind * numCol, : )));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, ";",',');
c_file_content = [ arr_str newline];
fprintf(fileID_c,'%s', c_file_content);
end
arr_str = join(mat2str(arr_str_all_fx(ind * numCol + 1 :ind * numCol + numRemain, : )));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, ";",',');
c_file_content = [ arr_str newline '};' newline ...
];
fprintf(fileID_c,'%s', c_file_content);
if dataSpec.makeFxFltBE
arr_str = mat2str(single(float_itd_azimKSeq));
else
arr_str = mat2str(mod_itd.azimKSeq{2});
end
arr_str = arr_str(2:end);
arr_str(end) = ' ';
arr_str = replace(arr_str,' ', '.000000f, ');
c_file_content = ...
['const float defaultHRIR_rom_ITD_azimKSeq[' num2str(length(mod_itd.azimKSeq{2})) '] = {' newline ...
arr_str ...
newline '};' newline ...
];
fprintf(fileID_c,'%s', c_file_content);
arr_str = mat2str(integer_itd_azimKSeq);
arr_str = arr_str(2:end);
arr_str(end) = ' ';
arr_str = replace(arr_str,' ', ', ');
c_file_content = ...
[ newline ...
'const Word16 defaultHRIR_rom_ITD_azimKSeq_Q_fx = ' num2str(Q_itd_azimKSeq) ';' newline ...
'const Word16 defaultHRIR_rom_ITD_azimKSeq_fx[' num2str(length(mod_itd.azimKSeq{2})) '] = {' newline ...
arr_str ...
newline '};' newline ...
newline ...
];
fprintf(fileID_c,'%s', c_file_content);
if dataSpec.makeFxFltBE
arr_str_all = num2hex(single(float_elevSplineShapeITD_all));
else
arr_str_all = num2hex(single(elevSplineShapeITD_all));
end
numCol = 25;
numIter = floor(length(elevSplineShapeITD_all)/numCol);
numRemain = length(elevSplineShapeITD_all) - numCol * numIter;
c_file_content = ['const uint32_t defaultHRIR_rom_ITD_elevBsShape[' num2str(length(elevSplineShapeITD_all)) '] = {' newline ];
fprintf(fileID_c,'%s', c_file_content);
for ind = 1: numIter
arr_str = join(mat2str(arr_str_all((ind-1) * numCol + 1 :ind * numCol, : )));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, "';",',');
arr_str = replace(arr_str, "'",'0x');
c_file_content = [ arr_str newline];
fprintf(fileID_c,'%s', c_file_content);
end
arr_str = join(mat2str(arr_str_all(ind * numCol + 1 :ind * numCol + numRemain, : )));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, "';",',');
arr_str = replace(arr_str, "'",'0x');
c_file_content = [ arr_str newline '};' newline];
fprintf(fileID_c,'%s', c_file_content);
arr_str_all_fx = reshape(integer_elevSplineShapeITD_all, [], 1);
numCol = 25;
numIter = floor(length(elevSplineShapeITD_all)/numCol);
numRemain = length(elevSplineShapeITD_all) - numCol * numIter;
c_file_content = ...
[...
'const Word16 defaultHRIR_rom_ITD_elevBsShape_Q_fx = ' num2str(Q_elevSplineShapeITD_all) ';' newline ...
'const Word16 defaultHRIR_rom_ITD_elevBsShape_fx[' num2str(length(elevSplineShapeITD_all)) '] = {' newline ];
fprintf(fileID_c,'%s', c_file_content);
for ind = 1: numIter
arr_str = join(mat2str(arr_str_all_fx((ind-1) * numCol + 1 :ind * numCol, : )));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, ";",',');
c_file_content = [ arr_str newline];
fprintf(fileID_c,'%s', c_file_content);
end
arr_str = join(mat2str(arr_str_all_fx(ind * numCol + 1 :ind * numCol + numRemain, : )));
arr_str = arr_str(2:end);
arr_str(end) = ';';
arr_str = replace(arr_str, ";",',');
c_file_content = [ arr_str newline '};' newline ...
];
fprintf(fileID_c,'%s', c_file_content);
if dataSpec.makeFxFltBE
arr_str = mat2str(float_elevKSeq_itd);
else
arr_str = mat2str(mod_itd.elevKSeq);
end
arr_str = arr_str(2:end);
arr_str(end) = ' ';
arr_str = replace(arr_str,' ', '.000000f, ');
c_file_content = ...
['const float defaultHRIR_rom_ITD_elevKSeq[' num2str(length(mod_itd.elevKSeq)) '] = {' newline ...
arr_str ...
newline '};' newline ...
];
fprintf(fileID_c,'%s', c_file_content);
arr_str_fx = mat2str(integer_elevKSeq_itd);
arr_str_fx = arr_str_fx(2:end);
arr_str_fx(end) = ' ';
arr_str_fx = replace(arr_str_fx,' ', ', ');
c_file_content = ...
[...
'const Word16 defaultHRIR_rom_ITD_elevKSeq_Q_fx = ' num2str(Q_elevKSeq_itd) ';' newline ...
'const Word16 defaultHRIR_rom_ITD_elevKSeq_fx[' num2str(length(mod_itd.elevKSeq)) '] = {' newline ...
arr_str_fx ...
newline '};' newline ...
];
fprintf(fileID_c,'%s', c_file_content);
fclose(fileID_c);
end
end
% Close file
if dataSpec.genBinaryFile
fclose(fileID);
end
fprintf("Wrote model parameters to: %s\n",fullfile(filePath,outputBinaryFileName));
end % fs loop
if dataSpec.genRomFile
h_file_content = string(join({''
['extern const Word16 defaultHRIR_rom_elevBsLen[' int2str(length(len_e)) '];']
['extern const Word16 defaultHRIR_rom_elevBsStart[' int2str(length(start_e)) '];']
'extern const Word16 defaultHRIR_rom_elevBsShape_Q_fx;'
['extern const Word16 defaultHRIR_rom_elevBsShape_fx[' int2str(length(elevSplineShape_all)) ']; /*Q30*/']
'extern const Word16 defaultHRIR_rom_azimBsShape_Q_fx;'
['extern const Word16 defaultHRIR_rom_azimBsShape_fx[' int2str(length(azimSplineShape{1})) ']; /*Q30*/']
''
}, newline));
fileID_h = fopen(h_file_name,'at');
fprintf(fileID_h,'%s', h_file_content);
fclose(fileID_h);
if useITD
h_file_content = string(join({''
'extern const Word16 defaultHRIR_rom_ITD_W_Q_fx;'
['extern const Word16 defaultHRIR_rom_ITD_W_fx[' int2str(mod_itd.angleBfNum) '];']
'extern const Word16 defaultHRIR_rom_ITD_azimBsShape_Q_fx;'
['extern const Word16 defaultHRIR_rom_ITD_azimBsShape_fx[' int2str(length(azimSplineShapeITD_all)) '];']
'extern const Word16 defaultHRIR_rom_ITD_azimKSeq_Q_fx;'
['extern const Word16 defaultHRIR_rom_ITD_azimKSeq_fx[' int2str(length(mod_itd.azimKSeq{2})) '];']
'extern const Word16 defaultHRIR_rom_ITD_elevBsShape_Q_fx;'
['extern const Word16 defaultHRIR_rom_ITD_elevBsShape_fx[' int2str(length(elevSplineShapeITD_all)) '];']
'extern const Word16 defaultHRIR_rom_ITD_elevKSeq_Q_fx;'
['extern const Word16 defaultHRIR_rom_ITD_elevKSeq_fx[' int2str(length(mod_itd.elevKSeq)) '];']
'extern const Word16 defaultHRIR_rom_ITD_model_configuration[4];'
['extern const Word16 defaultHRIR_rom_ITD_elevBsLen[' int2str(length(len_e_ITD)) '];']
['extern const Word16 defaultHRIR_rom_ITD_elevBsStart[' int2str(length(start_e_ITD)) '];']
['extern const Word16 defaultHRIR_rom_ITD_azimBsLen[' int2str(length(len_a_ITD)) '];']
['extern const Word16 defaultHRIR_rom_ITD_azimBsStart[' int2str(length(start_a_ITD)) '];']
''
}, newline));
fileID_h = fopen(h_file_name,'at');
fprintf(fileID_h,'%s', h_file_content);
fclose(fileID_h);
end
h_file_content = string(join({''
'#endif'
'#endif'
''
}, newline));
fileID_h = fopen(h_file_name,'at');
fprintf(fileID_h,'%s', h_file_content);
fclose(fileID_h);
c_file_content = string(join({'' ...
'#undef WMC_TOOL_SKIP' ...
'' ...
'/* clang-format on */',...
''
}, newline));
fileID_c = fopen(c_file_name,'at');
fprintf(fileID_c,'%s', c_file_content);
fclose(fileID_c);
end
end % function
......@@ -42,6 +42,7 @@ clc
dataSpec.hrfInDir = fullfile(pwd, '..','..','binauralRenderer_interface','HRIRs_sofa');
dataSpec.hrfOutDir = fullfile(pwd, '..', 'hrtf_data');
dataSpec.genRomFile = true;
dataSpec.genRomFileFx = false;
dataSpec.makeFxFltBE = true;
dataSpec.genBinaryFile = true;
dataSpec.romOutDir = fullfile(pwd, '..','..','..','lib_rend');
......@@ -64,4 +65,7 @@ clc
%% load model and generate parameters for IVAS
Gen_Hrf_IVAS_Binary(dataSpec, modSpec, info);
if dataSpec.genRomFileFx
Gen_Hrf_IVAS_Binary_fx(dataSpec, modSpec, info);
end
end
mixed_mc714_foa_masa2_ism4_16.wav
7
MC
1
7_1_4
SBA
13
1
MASA
17
2
stv2MASA2TC16c.met
ISM
19
stvISM1.csv
ISM
20
stvISM2.csv
ISM
21
stvISM3.csv
ISM
22
stvISM4.csv
mixed_mc714_foa_masa2_ism4_32.wav
7
MC
1
7_1_4
SBA
13
1
MASA
17
2
stv2MASA2TC32c.met
ISM
19
stvISM1.csv
ISM
20
stvISM2.csv
ISM
21
stvISM3.csv
ISM
22
stvISM4.csv
spectral_test_16ch_16kHz.wav
4
ISM
1
ism_0a_0e.csv
ISM
2
1
1,-30,0
SBA
3
1
MC
7
5_1_4
spectral_test_16ch_32kHz.wav
4
ISM
1
ism_0a_0e.csv
ISM
2
1
1,-30,0
SBA
3
1
MC
7
5_1_4
spectral_test_4ch_16kHz.wav
3
ISM
1
ism_0a_0e.csv
ISM
2
1
1,-30,0
MC
3
STEREO
spectral_test_4ch_32kHz.wav
3
ISM
1
ism_0a_0e.csv
ISM
2
1
1,-30,0
MC
3
STEREO