Skip to content
......@@ -104,6 +104,27 @@ static ivas_error read_txt_float(
return IVAS_ERR_OK;
}
#ifdef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER
/*-----------------------------------------------------------------------------------------*
* Function read_txt_uint32()
* Reads a float value from a line
*-----------------------------------------------------------------------------------------*/
static ivas_error read_txt_int32(
const char *pLine, /* i : String to read from */
int32_t *pTarget /* o : Output pointer */
)
{
int32_t val = 0;
if ( sscanf( pLine, "%d", &val ) != 1 )
{
return IVAS_ERR_INVALID_RENDER_CONFIG;
}
*pTarget = val;
return IVAS_ERR_OK;
}
#endif
/*-----------------------------------------------------------------------------------------*
* Function read_txt_vector()
......@@ -273,6 +294,10 @@ ivas_error ConfigReader_read(
hRenderConfig->diffuseEnergyThreshold = DEFAULT_DIFFUSE_ENERGY_THRESHOLD;
hRenderConfig->diffuseCutOffFreqThreshold = DEFAULT_DIFFUSE_CUT_OFF_FREQ_THRESHOLD;
hRenderConfig->directCutOffFreqThreshold = DEFAULT_DIRECT_CUT_OFF_FREQ_THRESHOLD;
#ifdef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER
hRenderConfig->maxNumDirectBlocks = DEFAULT_MAX_NUM_DIRECT_BLOCKS;
hRenderConfig->maxNumDiffuseBlocks = DEFAULT_MAX_NUM_DIFFUSE_BLOCKS;
#endif
/* read file line by line */
while ( fgets( pConfig_str, file_size, pConfigFile ) != NULL )
{
......@@ -391,6 +416,24 @@ ivas_error ConfigReader_read(
return IVAS_ERR_INVALID_RENDER_CONFIG;
}
}
#ifdef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER
else if ( strcmp( item, "MAXNUMDIRECTBLOCKS" ) == 0 )
{
if ( read_txt_int32( pValue, &hRenderConfig->maxNumDirectBlocks ) != IVAS_ERR_OK )
{
errorHandler( item, ERROR_VALUE_INVALID );
return IVAS_ERR_INVALID_RENDER_CONFIG;
}
}
else if ( strcmp( item, "MAXNUMDIFFUSEBLOCKS" ) == 0 )
{
if ( read_txt_int32( pValue, &hRenderConfig->maxNumDiffuseBlocks ) != IVAS_ERR_OK )
{
errorHandler( item, ERROR_VALUE_INVALID );
return IVAS_ERR_INVALID_RENDER_CONFIG;
}
}
#endif
}
free( pValue );
}
......
......@@ -44,6 +44,10 @@
#define DEFAULT_DIFFUSE_ENERGY_THRESHOLD ( -25.f )
#define DEFAULT_DIFFUSE_CUT_OFF_FREQ_THRESHOLD ( -20.f )
#define DEFAULT_DIRECT_CUT_OFF_FREQ_THRESHOLD ( -20.f )
#ifdef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER
#define DEFAULT_MAX_NUM_DIRECT_BLOCKS ( 40 )
#define DEFAULT_MAX_NUM_DIFFUSE_BLOCKS ( 40 )
#endif
typedef struct ConfigReader
......@@ -57,6 +61,10 @@ typedef struct ConfigReader
float diffuseEnergyThreshold; /* use to find the time end limit of the diffuse part (te). diffuse part. It is a ratio in dB between diffuse part after te and complete diffuse HRIR/BRIR energies. The more the value is near zero the smallest is te, complexity decrease. */
float diffuseCutOffFreqThreshold; /* threshold in dB to determine the cut off (fcdiff) frequency for each slice of the diffuse IR. ratio in dB between the energy after fcdiff and the total energy. The more the value is near zero the smallest is fcdiff, complexity decrease */
float directCutOffFreqThreshold; /* threshold in dB to determine the cut off (fcdirect) frequency for each slice of the direct IR. Do not applied to first slice. ratio in dB between the energy after fcdirect and the total energy. The more the value is near zero the smallest is fcdirect, complexity decrease */
#ifdef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER
int32_t maxNumDirectBlocks; /* max number of direct blocks */
int32_t maxNumDiffuseBlocks; /* max number of diffuse blocks */
#endif
} ConfigReader, *ConfigReaderHandle;
typedef enum
......
......@@ -47,10 +47,11 @@ header.chunksize = 0;
%% parse IVAS enum
% read the file
ivas_cnst_path = fullfile(ivas_path, 'lib_com/ivas_cnst.h'); % must be replaced if this file is moved
hrtf_file_reader_path = fullfile(ivas_path, 'lib_util/hrtf_file_reader.h'); % must be replaced if this file is moved
c = fileread(hrtf_file_reader_path);
% regex for RENDERER_TYPE
rt_expr = '^\s+(RENDERER\w+)';
rt_expr = '^\s+(HRTF_READER_RENDERER\w+)';
rt_tok = regexp(c, rt_expr, 'tokens', 'dotexceptnewline', 'lineanchors');
renderer_types = convertCharsToStrings(cat(1,rt_tok{:}));
......
......@@ -46,7 +46,7 @@ addpath(genpath('../td_object_renderer/modeling_tool/'));
%% Set arguments
writeRomFileOutput = true; %% generation of rom files if true
writeBinaryOutput = false; %% generation of binary files if true. Always true for TD renderer
writeBinaryOutput = true; %% generation of binary files if true. Always true for TD renderer
writeEachRendererBinaryOutput = true; %% generation of binary split files each containing binary data for individual renderer
%% Set ivas root path
......@@ -101,6 +101,8 @@ if writeBinaryOutput == true
end
command = [command ...
' -compute_reverb_rom ' ...
erase(hrir_file,'.sofa') '.mat ' ...
' 5 ' ...
erase(hrir_file,'.sofa') '.mat ' ...
erase(hrir_file,'.sofa') '_FOA.mat ' ...
......@@ -173,6 +175,8 @@ if writeBinaryOutput == true
' -input_mixerconv_hrir_file_name ' binary_name ...
' -input_mixerconv_brir_file_path ' binary_path ...
' -input_mixerconv_brir_file_name ' binary_name ...
' -input_reverb_file_path ' binary_path ...
' -input_reverb_file_name ' binary_name ...
' -input_td_file_path ' fullfile(binary_path, 'IVAS_default') ...
' -input_td_file_name ' td_binary_file ...
' -input_param_file_path ' binary_path ...
......@@ -198,6 +202,8 @@ if writeBinaryOutput == true && writeEachRendererBinaryOutput == true
" -input_mixerconv_hrir_file_name " binary_name , ...
" -input_mixerconv_brir_file_path " binary_path ...
" -input_mixerconv_brir_file_name " binary_name ,...
" -input_reverb_file_path " binary_path ...
" -input_reverb_file_name " binary_name ,...
" -input_td_file_path " fullfile(binary_path, 'IVAS_default') ...
" -input_td_file_name " td_binary_file ,...
" -input_param_file_path " binary_path ...
......
......@@ -146,7 +146,12 @@ static void printfAudioBufferOutFilterParams(
printf( "\nmax Diffuse Fc : %u", pParam->index_frequency_max_diffuse );
printf( "\n" );
printf( "\nInverse Diffuse Weights :" );
#ifdef FIX_INV_DIFFUSE_WEIGHT
printBuf_float32( pParam->inv_diffuse_weight[0], pParam->max_num_ir );
printBuf_float32( pParam->inv_diffuse_weight[1], pParam->max_num_ir );
#else
printBuf_float32( pParam->inv_diffuse_weight, pParam->max_num_ir );
#endif
printf( "\n" );
/*if (pParam->numDiffuseBlock > 0)
......@@ -558,11 +563,20 @@ ivas_error ivas_crend_binaural_filter_design_compute_filters_params(
{
pParam->num_iterations[i_chan][0]++;
}
#ifdef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER
/* max MAX_LENGTH_DIRECT_FILTER */
if ( pParam->num_iterations[i_chan][0] > cfgReader->maxNumDirectBlocks )
{
pParam->num_iterations[i_chan][0] = cfgReader->maxNumDirectBlocks;
}
pParam->num_iterations[i_chan][1] = pParam->num_iterations[i_chan][0];
#else
pParam->num_iterations[i_chan][1] = pParam->num_iterations[i_chan][0];
if ( pParam->num_iterations[i_chan][0] > IVAS_MAX_NUM_DIRECT_BLOCKS )
{
pParam->num_iterations[i_chan][0] = IVAS_MAX_NUM_DIRECT_BLOCKS;
}
#endif
}
pParam->max_num_iterations = 0;
......@@ -652,10 +666,17 @@ ivas_error ivas_crend_binaural_filter_design_compute_filters_params(
}
/* max MAX_NUM_DIFFUSE_BLOCKS */
#ifdef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER
if ( numDiffuseBlock > cfgReader->maxNumDiffuseBlocks )
{
numDiffuseBlock = cfgReader->maxNumDiffuseBlocks;
}
#else
if ( numDiffuseBlock > IVAS_MAX_NUM_DIFFUSE_BLOCKS )
{
numDiffuseBlock = IVAS_MAX_NUM_DIFFUSE_BLOCKS;
}
#endif
for ( i_ear = 0; i_ear < 2; ++i_ear )
{
......@@ -685,6 +706,9 @@ ivas_error ivas_crend_binaural_filter_design_compute_filters_params(
ivas_error ivas_crend_binaural_filter_design_set_hrtf_fr(
ivas_hrtf_t *pFirData,
const int16_t frame_len,
#ifdef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER
float mdft_scale_fact,
#endif
HRTFS_DATA *pParam,
int32_t index_start,
int32_t index_end,
......@@ -712,7 +736,9 @@ ivas_error ivas_crend_binaural_filter_design_set_hrtf_fr(
float ppEnergyDiffuseFilter[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS] = { { 0 } }; /* diffuse filter energies ( ppEnergyDiffuseFilter[ear][channel] ) */
float ppDiffuseWeight[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS] = { { 0 } }; /* diffuse weights ( ppDiffuseWeight[ear][channel] ) */
float delayf;
#ifndef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER
float mdft_scale_fact = ( (float) L_FRAME48k * 0.25f ) / frame_len;
#endif
if ( cfgReader != NULL )
{
......@@ -1071,11 +1097,37 @@ ivas_error ivas_crend_binaural_filter_design_set_hrtf_fr(
{
if ( ppDiffuseWeight[i_chan][0] != -1 && ppDiffuseWeight[i_chan][1] != -1 )
{
#ifdef FIX_INV_DIFFUSE_WEIGHT
if ( cfgReader != NULL )
{
if ( cfgReader->harmonizeLateReverbBinauralGain )
{
pParam->inv_diffuse_weight[0][i_chan] = cfgReader->lateReverbCompensationGain[i_chan] * 2.f / ( ppDiffuseWeight[i_chan][0] + ppDiffuseWeight[i_chan][1] );
pParam->inv_diffuse_weight[1][i_chan] = pParam->inv_diffuse_weight[0][i_chan];
}
else
{
pParam->inv_diffuse_weight[0][i_chan] = cfgReader->lateReverbCompensationGain[i_chan] * 1.f / ppDiffuseWeight[i_chan][0];
pParam->inv_diffuse_weight[1][i_chan] = cfgReader->lateReverbCompensationGain[i_chan] * 1.f / ppDiffuseWeight[i_chan][1];
}
}
else
{
pParam->inv_diffuse_weight[0][i_chan] = 2.f / ( ppDiffuseWeight[i_chan][0] + ppDiffuseWeight[i_chan][1] );
pParam->inv_diffuse_weight[1][i_chan] = pParam->inv_diffuse_weight[0][i_chan];
}
#else
pParam->inv_diffuse_weight[i_chan] = 2.f / ( ppDiffuseWeight[i_chan][0] + ppDiffuseWeight[i_chan][1] );
#endif
}
else
{
#ifdef FIX_INV_DIFFUSE_WEIGHT
pParam->inv_diffuse_weight[0][i_chan] = 0; /* pathological case ppEnergyDiffuseFilter[i_ear][i_chan]=0 */
pParam->inv_diffuse_weight[1][i_chan] = 0; /* pathological case ppEnergyDiffuseFilter[i_ear][i_chan]=0 */
#else
pParam->inv_diffuse_weight[i_chan] = 0; /* pathological case ppEnergyDiffuseFilter[i_ear][i_chan]=0 */
#endif
}
}
......@@ -1285,13 +1337,19 @@ ivas_error ivas_set_hrtf_fr(
HRTFS_DATA *crend_hrtf,
ivas_hrtf_t *hrtf,
const int16_t output_frame
#ifdef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER
,
float mdft_scale_fact
#endif
)
{
int32_t i, j, m, n;
float data_ir_flt[L_FRAME48k] = { 0.0f };
int32_t tmp_ir_len, in_len, k;
#ifndef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER
float mdft_scale_fact = ( (float) L_FRAME48k * 0.25f ) / output_frame;
#endif
crend_hrtf->max_num_ir = (int16_t) hrtf->m;
......
......@@ -40,8 +40,10 @@
#define IVAS_SOFA_MAX_VAL_R ( 2 )
#define IVAS_SOFA_MAX_VAL_N ( 48000 )
#define IVAS_SOFA_MAX_VAL_I ( 1 )
#ifndef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER
#define IVAS_MAX_NUM_DIRECT_BLOCKS ( 40 ) /* max number of direct blocks */
#define IVAS_MAX_NUM_DIFFUSE_BLOCKS ( 40 ) /* max number of diffuse blocks */
#endif
#define IVAS_MAX_HRTF_LATENCY_MS ( 0.1 ) /* max hrtf latency */
typedef struct ivas_hrtf_t
......@@ -61,10 +63,17 @@ typedef struct ivas_hrtf_t
ivas_error ivas_get_hrtf_lens( ivas_hrtf_t *hrtf, HRTFS_DATA *crend_hrtf, const int16_t frame_len );
ivas_error ivas_set_hrtf_fr( HRTFS_DATA *crend_hrtf, ivas_hrtf_t *hrtf, const int16_t frame_len
#ifdef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER
,
float mdft_scale_fact
#endif
);
ivas_error ivas_crend_binaural_filter_design_compute_filters_params( ivas_hrtf_t *pFirData, const int16_t framelen, HRTFS_DATA *pParam, int32_t *index_start, int32_t *index_end, int32_t *max_ir_len, ConfigReader *cfgReader );
ivas_error ivas_crend_binaural_filter_design_set_hrtf_fr( ivas_hrtf_t *pFirData, const int16_t frame_len,
#ifdef FIX_20_MS_FRAME_LEN_TABLES_CONVERTER
float mdft_scale_fact,
#endif
HRTFS_DATA *pParam,
int32_t index_start,
int32_t index_end,
......
......@@ -97,7 +97,8 @@ if isfile(Lib_Name)
if sampleRates(ind) == Sofa.Data.SamplingRate
Sofa.DataResampled(ind).IR = Sofa.Data.IR;
else
Sofa.DataResampled(ind).IR = resample(Sofa.Data.IR, sampleRates(ind),Sofa.Data.SamplingRate, 'Dimension',1);
Sofa.DataResampled(ind).IR(:,1,:) = resample(squeeze(Sofa.Data.IR(:,1,:)), sampleRates(ind),Sofa.Data.SamplingRate);
Sofa.DataResampled(ind).IR(:,2,:) = resample(squeeze(Sofa.Data.IR(:,2,:)), sampleRates(ind),Sofa.Data.SamplingRate);
end
Sofa.DataResampled(ind).SamplingRate = sampleRates(ind);
end
......
......@@ -69,7 +69,7 @@ Excess_Phase = squeeze(unwrap(diff(angle(FRs_hi_res), 1, 2) - ...
bin1200 = ceil( 1200/24000*N );
ITD_hi_res = Excess_Phase(bin1200,:)' / ((bin1200-0.5)/N*24000*2*pi);
MaxDel = max(ITD_hi_res, [], 'all');
MaxDel = max(ITD_hi_res);
% Create 2 ears
Ear_dels_hi_res = (repmat(ITD_hi_res, 1, 2) .* [0.5 -0.5]) + 0.5*MaxDel .* ...
......@@ -79,7 +79,7 @@ MRs_hi_res = abs(FRs_hi_res_minP);
% Generate permutation
[~, perm] = ismembertol(...
Vs_hi_res', Vs_hi_res'.*[1,-1,1], ...
1e-4, "ByRows",true);
1e-4, 'ByRows',true);
MRs_hi_res(:,2,:) = MRs_hi_res(:,2,perm);
New_FreqResp_L = mag2min_phase(squeeze(mean(MRs_hi_res, 2))) .* ...
......@@ -113,7 +113,6 @@ IR_HOA = permute(IR_HOA, [3, 1, 2]);
IR_HOA = IR_HOA(:,1:ir_len,:) .* sin(interp1([0,150/192*ir_len,ir_len+1],[1,1,0]*pi/2, 1:ir_len));
IR = permute(IR_HOA, [2, 1, 3]);
HOAformat_str = ['HOA',num2str(order),'S'];
IR_data = IR;
......
This diff is collapsed.
......@@ -401,7 +401,7 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1
// 3 ISM with metadata at 48 kbps, 48 kHz in, 48 kHz out, EXT out
../IVAS_cod -ism 3 testv/ltvISM1.csv testv/ltvISM2.csv testv/ltvISM3.csv 48000 48 testv/ltv48_3ISM.wav bit
../IVAS_dec MONO 48 bit testv/ltv48_3ISM.48000_48-48_MONO.tst
../IVAS_dec EXT 48 bit testv/ltv48_3ISM.48000_48-48_MONO.tst
// 3 ISM with metadata at 64 kbps, 48 kHz in, 48 kHz out, EXT out
../IVAS_cod -ism 3 testv/ltvISM1.csv testv/ltvISM2.csv testv/ltvISM3.csv 64000 48 testv/ltv48_3ISM.wav bit
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.