Commit 1bed0f4c authored by emerit's avatar emerit
Browse files

merge with clean up version

parent 68660ca9
Loading
Loading
Loading
Loading
+102 −0
Original line number Diff line number Diff line
#!/usr/bin/env python3

import os
import subprocess

# Set/unset the flags below to activate/deactivate build/encode/decode phases
build = False
encode = True
decode = True

# Variables
fs = 48
ivasPath = './'
ivasEnc = 'IVAS_cod'
ivasDec = 'IVAS_dec'
ivasRend = 'IVAS_rend'
inPath = './in/'
bitPath = './bit/'
outPath = './out/'
hrtfPath = f'{ivasPath}scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/'
# hrtfName = f'HRIR_128_Meth5_IRC_53_Q10_symL_Itrp1_{fs}000'
# brirKern = 'BRIR_Auditorium_S1_R1'
# brirName = f'{brirKern}_Combined_BRIR_{fs}kHz'
# brirFile = f'{hrtfPath}{hrtfName}+{brirName}.bin'
# brirFile = f'{hrtfPath}fastconv_{hrtfName}_{brirKern}.bin'
# brirFile = f'{hrtfPath}ivas_binaural_custom_48kHz.bin'
brirFiles = [f'ivas_binaural_custom_{fs}kHz', f'ivas_binaural_custom_no_optim_{fs}kHz', f'ivas_binaural_custom_fabian_hrir_{fs}kHz']
brirPaths = [f'{hrtfPath}{brirFiles[0]}.bin', f'{hrtfPath}{brirFiles[1]}.bin']
bitrates = [32, 80, 256]
# inFormats = ['mc 5_1', 'mc 7_1_4', 'sba 1', 'sba 2', 'sba 3']
# files = {'mc 5_1' : f'5ch_ident_{fs}', 'mc 7_1_4' : f'dirac_714_{fs}k', 'sba 1' : f'dirac_HOA1S_{fs}k' , 'sba 2' : f'dirac_HOA2S_{fs}k' , 'sba 3' : f'dirac_HOA3S_{fs}k' }
# outFormats = {'mc 5_1' : '5_1', 'mc 7_1_4' : '7_1_4', 'sba 1' : 'FOA' , 'sba 2' : 'HOA2' , 'sba 3' : 'HOA3' }
inFormats = ['mc 5_1', 'mc 7_1_4', 'sba 3']
files = {'mc 5_1' : f'5ch_ident_{fs}', 'mc 7_1_4' : f'dirac_714_{fs}k' , 'sba 3' : f'dirac_HOA3S_{fs}k' }
outFormats = {'mc 5_1' : '5_1', 'mc 7_1_4' : '7_1_4', 'sba 1' : 'FOA' , 'sba 3' : 'HOA3' }

testDir = os.getcwd()

# Build phase
if build:
    os.chdir(ivasPath)
    subprocess.run('cmake -D CMAKE_BUILD_TYPE=Release -D TARGET_PLATFORM=x86_64 -D COPY_EXECUTABLES_FROM_BUILD_DIR=true -B build -G "Visual Studio 15 2017 Win64"')
    subprocess.run('cmake --build build --config release --clean-first')
    #subprocess.run('cmake --build build --config release')
    os.chdir(testDir)

#Encode
if encode:
    for b in bitrates:
        for f in inFormats:
            cmd = f'{ivasPath}{ivasEnc} -{f} {b * 1000} {fs} {inPath}{files[f]}.wav {bitPath}{files[f]}-{b}kbps.ivas'
            subprocess.run(cmd,shell=True)

#Decode & Render
for b in bitrates:
    for f in inFormats:
        for brir in brirFiles:
            ivasFile = f'{bitPath}{files[f]}-{b}kbps.ivas'
            outFileBase = f'{outPath}{files[f]}-{b}kbps'
            # Decode and render binaural
            cmd = f'{ivasPath}{ivasDec} -hrtf {hrtfPath}{brir}.bin BINAURAL {fs} {ivasFile} {outFileBase}-dec-bin-{brir}.wav'
            subprocess.run(cmd,shell=True)

            # Decode and render binaural IR
            cmd = f'{ivasPath}{ivasDec} -hrtf {hrtfPath}{brir}.bin BINAURAL_ROOM_IR {fs} {ivasFile} {outFileBase}-dec-brir-{brir}.wav'
            subprocess.run(cmd,shell=True)

            # Decode and render binaural reverb
            cmd = f'{ivasPath}{ivasDec} -hrtf {hrtfPath}{brir}.bin BINAURAL_ROOM_REVERB {fs} {ivasFile} {outFileBase}-dec-rev-{brir}.wav'
            subprocess.run(cmd,shell=True)

            # Decode pass-through
            cmd = f'{ivasPath}{ivasDec} {outFormats[f]} {fs} {ivasFile} {outFileBase}-dec-ext.wav'
            subprocess.run(cmd,shell=True)

            # Render binaural
            cmd = f'{ivasPath}{ivasRend} -i {outFileBase}-dec-ext.wav -if {outFormats[f]} -o {outFileBase}-ext-bin-{brir}.wav -of BINAURAL -fs {fs} -hrtf {hrtfPath}{brir}.bin'
            subprocess.run(cmd,shell=True)

            # Render binaural IR
            cmd = f'{ivasPath}{ivasRend} -i {outFileBase}-dec-ext.wav -if {outFormats[f]} -o {outFileBase}-ext-brir-{brir}.wav -of BINAURAL_ROOM_IR -fs {fs} -hrtf {hrtfPath}{brir}.bin'
            subprocess.run(cmd,shell=True)

            # Render binaural reverb
            cmd = f'{ivasPath}{ivasRend} -i {outFileBase}-dec-ext.wav -if {outFormats[f]} -o {outFileBase}-ext-rev-{brir}.wav -of BINAURAL_ROOM_REVERB -fs {fs}'
            subprocess.run(cmd,shell=True)
            
for f in inFormats:
    outFileBase = f'{outPath}{files[f]}'
    for brir in brirFiles:

        # Render binaural
        cmd = f'{ivasPath}{ivasRend} -i {inPath}{files[f]}.wav  -if {outFormats[f]} -o {outFileBase}-rend-bin-{brir}.wav -of BINAURAL -fs {fs} -hrtf {hrtfPath}{brir}.bin'
        subprocess.run(cmd,shell=True)

        # Render binaural IR
        cmd = f'{ivasPath}{ivasRend} -i {inPath}{files[f]}.wav -if {outFormats[f]} -o {outFileBase}-rend-brir-{brir}.wav -of BINAURAL_ROOM_IR -fs {fs} -hrtf {hrtfPath}{brir}.bin -g 8'
        subprocess.run(cmd,shell=True)
        
        # Render binaural reverb
        cmd = f'{ivasPath}{ivasRend} -i  {inPath}{files[f]}.wav -if {outFormats[f]} -o {outFileBase}-rend-rev-{brir}.wav -of BINAURAL_ROOM_REVERB -fs {fs} -hrtf {hrtfPath}{brir}.bin'
        subprocess.run(cmd,shell=True)            
+4 −6
Original line number Diff line number Diff line
@@ -159,19 +159,17 @@

/*#define FIX_I4_OL_PITCH*/                             /* fix open-loop pitch used for EVS core switching */

#define FIX_CREND_FIX_POINT_HRTF_FILE_FORMAT          /* Orange issue 1031 : new fix point hrtf binary file format */
#define FIX_CREND_SIMPLIFY_CODE                         /* Ora : simplify line code in crend */
#define FLOAT_FIX_POINT_HRTF_FILE_FORMAT                /* allows reading floation or fix point hrtf binary file format */
#define FIX_1138_SBA_EXT_ERROR_PRINTOUT                 /* VA: issue 1138: Fix SBA EXT output call of audioCfg2channels() */
#define FIX_1117_ISAR_MALLOC                            /* VA: issue 1117: call ISAR malloc() only at the initialization. */

#define FIX_POINT_HRTF_FILE_FORMAT                     /* All: fix point hrtf binary file format */
#ifdef FIX_POINT_HRTF_FILE_FORMAT
#define FIX_1123_CREND_16BIT_ROM
#define FIX_1123_TDREN_16BIT_ROM
#define FIX_1123_FASTCONV_16BIT_ROM                     /* FhG: issue 1123: update FastConv ROM tables and scripts to generate 16 bit tables instead of float */
#define FIX_1123_PARAMBIN_16BIT_ROM                     /* FhG,Nok: issue 1123: update ParamBin ROM tables and scripts to generate 16 bit tables instead of float */
#define FIX_1123_OPTIMIZE_BINARY_LOAD                   /* Nok: Optimize loading of binary files in fixed point format by precomputing scaling factors */
#define FIX_TDREND_HRTF_FILE_FORMAT                     /* Eri: fix point hrtf binary file format for TDREND */
#define FIX_1123_TDREN_16BIT_ROM
#define FIX_1123_TDREN_32BIT_ROM_EL_ER
#endif

/* #################### End BE switches ################################## */

+1 −1
Original line number Diff line number Diff line
@@ -830,7 +830,7 @@ static ivas_error ivas_rend_initCrend(
                                hHrtf->pOut_to_bin_im[i][j][k] = (float) CRendBin_HOA2_HRIR_coeff_im_16kHz_fx[i][j][k] * factorQ;
                            }
#else
                            Hrtf->pOut_to_bin_re[i][j] = CRendBin_HOA2_HRIR_coeff_re_16kHz[i][j];
                            hHrtf->pOut_to_bin_re[i][j] = CRendBin_HOA2_HRIR_coeff_re_16kHz[i][j];
                            hHrtf->pOut_to_bin_im[i][j] = CRendBin_HOA2_HRIR_coeff_im_16kHz[i][j];
#endif
                        }
+3 −15
Original line number Diff line number Diff line
@@ -438,13 +438,8 @@ static ivas_error DefaultBSplineModel(
    float q_scale_e = 0;
    const int16_t *alphaL_ptr = NULL;
    const int16_t *alphaR_ptr = NULL;
#ifdef FIX_1123_TDREN_32BIT_ROM_EL_ER
    const int32_t *elL_ptr = NULL;
    const int32_t *elR_ptr = NULL;
#else
    const int16_t *elL_ptr = NULL;
    const int16_t *elR_ptr = NULL;
#endif
#endif

    HrFiltSet_p->FilterMethod = TDREND_HRFILT_Method_BSplineModel;
@@ -617,7 +612,9 @@ static ivas_error DefaultBSplineModel(

    /* Precalculated energies for each section and each row of the alpha matrices */
    HRTF_model_precalc( model );
    //  HRTF_energy_sections_precalc( model );
#ifndef FIX_1123_TDREN_16BIT_ROM
    HRTF_energy_sections_precalc( model );
#endif
    model->EL_dyn = (float *) malloc( HRTF_MODEL_N_SECTIONS * model->AlphaN * sizeof( float ) );
    model->ER_dyn = (float *) malloc( HRTF_MODEL_N_SECTIONS * model->AlphaN * sizeof( float ) );
    for ( j = 0; j < HRTF_MODEL_N_SECTIONS * model->AlphaN; j++ )
@@ -645,12 +642,8 @@ static ivas_error DefaultBSplineModel(
        modelITD->elevKSeq_dyn[j] = (float) defaultHRIR_rom_ITD_elevKSeq[j] * q_scale;
    }
    modelITD->elevKSeq = (const float *) modelITD->elevKSeq_dyn;
#else
#ifdef FIX_TDREND_HRTF_FILE_FORMAT
    modelITD->elevKSeq = (const float *) defaultHRIR_rom_ITD_elevKSeq;
#else
    modelITD->elevKSeq = defaultHRIR_rom_ITD_elevKSeq;
#endif
#endif

    modelITD->azimBsLen = defaultHRIR_rom_ITD_azimBsLen;
@@ -665,13 +658,8 @@ static ivas_error DefaultBSplineModel(
    }
    modelITD->azimKSeq = (const float *) modelITD->azimKSeq_dyn;
#else

#ifdef FIX_TDREND_HRTF_FILE_FORMAT
    modelITD->azimKSeq = (const float *) defaultHRIR_rom_ITD_azimKSeq;
#else
    modelITD->azimKSeq = defaultHRIR_rom_ITD_azimKSeq;
#endif
#endif
#ifdef FIX_1123_TDREN_16BIT_ROM
    size_rom_table = sizeof( defaultHRIR_rom_ITD_W ) / sizeof( int16_t );
    modelITD->W_dyn = (float *) malloc( size_rom_table * sizeof( float ) );
+0 −6
Original line number Diff line number Diff line
@@ -697,12 +697,6 @@ void HRTF_model_precalc(
    ModelParams_t *model                                        /* i/o: HRTF Model parameters                   */
);

#ifdef FIX_1123_TDREN_16BIT_ROM
void HRTF_energy_sections_precalc(
    ModelParams_t *model                                        /* i/o: HRTF model parameters        */
);
#endif

ivas_error TDREND_REND_RenderSourceHRFilt(
    TDREND_SRC_t *Src_p,                                        /* i/o: The source to be rendered               */
    const float *hrf_left_delta,                                /* i  : Left filter interpolation delta         */
Loading