Commit be5663a4 authored by emerit's avatar emerit
Browse files

fix python path issue and merge with 588

parent 463442be
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -1515,9 +1515,16 @@ typedef enum

#define BINAURAL_MAXBANDS                       60                          /* Max number of bands */
#define BINAURAL_CONVBANDS                      50                          /* Bands upto which convolution is performed */
#ifdef FIX_588_UPDATE_FASTCONV_SD
#define BINAURAL_NTAPS                           3
#else
#define BINAURAL_NTAPS                           5

#endif
#ifdef FIX_588_UPDATE_FASTCONV_SD
#define BINAURAL_NTAPS_SBA                       BINAURAL_NTAPS
#else
#define BINAURAL_NTAPS_SBA                       3
#endif

#define BINAURAL_NTAPS_MAX                      96

+1 −0
Original line number Diff line number Diff line
@@ -167,6 +167,7 @@

#define FIX_718_JBM_MD_UDPATE                           /* Fhg: fix issue #718, wrong setting of the update flag in the TD obj renderer in the JBM path */
#define FIX_719_CRASH_IN_CLEANUP                        /* VA: issue 719: fix Decoder crash after call to goto to cleanup */
#define FIX_588_UPDATE_FASTCONV_SD                      /* FhG: issue 588: update FastConv SD HRTFs in CLDFB domain with new conversion method */
#define FIX_312_FASTCONV_HRTF_LOAD                      /* FhG: update loading of FastConv HRTFs from binary data - to be enabled after Matlab binary blob generation is harmonised */

/* ################## End BE DEVELOPMENT switches ######################### */
+17 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ set(EXTERNALS_PATH ${PROJECT_SOURCE_DIR}/Externals)
endif()
set(IVAS_TRUNK_PATH "${PROJECT_SOURCE_DIR}/../..")
set(IVAS_TRUNK_UTIL_PATH ${IVAS_TRUNK_PATH}/lib_util)
string(REPLACE "/binauralRenderer_interface" "" IVAS_TRUNK_SCRIPTS_PATH ${PROJECT_SOURCE_DIR})
set(IVAS_TRUNK_DEC_PATH ${IVAS_TRUNK_PATH}/lib_dec)
set(IVAS_TRUNK_REND_PATH ${IVAS_TRUNK_PATH}/lib_rend)
set(IVAS_TRUNK_ENC_PATH ${IVAS_TRUNK_PATH}/lib_enc)
@@ -80,11 +81,27 @@ message(STATUS "libmysofa configured")
else()
find_package(Python REQUIRED COMPONENTS Development Interpreter NumPy )

message("Python_EXECUTABLE = ${Python_EXECUTABLE}")
message("Python_SITELIB = ${Python_SITELIB}")
message("Python_SITEARCH = ${Python_SITEARCH}")
message("Python_LIBRARIES = ${Python_LIBRARIES}")
message("Python_LIBRARY_DIRS = ${Python_LIBRARY_DIRS}")
message("Python_INCLUDE_DIRS = ${Python_INCLUDE_DIRS}")
message("Python_NumPy_INCLUDE_DIRS = ${Python_NumPy_INCLUDE_DIRS}")

string(REPLACE "/numpy/core/include" "" Python_SitePackages ${Python_NumPy_INCLUDE_DIRS})
string(REPLACE "/site-packages/numpy/core/include" "" Python_User_Folder ${Python_NumPy_INCLUDE_DIRS})
set (Python_User_Script "${Python_User_Folder}/Scripts")
message("Python_User_Script = ${Python_User_Script}")
message("Python_SitePackages = ${Python_SitePackages}")

if (DEFINED ENV{PYTHONPATH})
message("PYTHONPATH = $ENV{PYTHONPATH}")
else()
set(ENV{PYTHONPATH} "${Python_SitePackages};${IVAS_TRUNK_SCRIPTS_PATH}")
message("set PYTHONPATH to $ENV{PYTHONPATH}")
endif()

add_definitions(-DNPY_NO_DEPRECATED_API)
add_definitions(-DFIX_REMOVE_MYSOFA)
endif()
+34 −13
Original line number Diff line number Diff line
@@ -4,9 +4,20 @@ from netCDF4 import Dataset
from typing import Tuple



def load(filename)-> Tuple[str, str, np.ndarray, np.ndarray, np.ndarray,np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray]:

def load(
    filename,
) -> Tuple[
    str,
    str,
    np.ndarray,
    np.ndarray,
    np.ndarray,
    np.ndarray,
    np.ndarray,
    np.ndarray,
    np.ndarray,
    np.ndarray,
]:
    hrtf = Dataset(filename, "r", format="NETCDF4")
    Database_Name = hrtf.DatabaseName
    Listener_Short_Name = hrtf.ListenerShortName
@@ -62,7 +73,19 @@ def load(filename)-> Tuple[str, str, np.ndarray, np.ndarray, np.ndarray,np.ndarr
            )
            ind_ear = ind_ear + 1
        ind_dir = ind_dir + 1
    return Database_Name, Listener_Short_Name, Sampling_Rate, latencys, Data_Delay, Data_IR_48khz, Data_IR_32khz, Data_IR_16khz, Source_Position, Source_Position_Cartesian
    return (
        Database_Name,
        Listener_Short_Name,
        Sampling_Rate,
        latencys,
        Data_Delay,
        Data_IR_48khz,
        Data_IR_32khz,
        Data_IR_16khz,
        Source_Position,
        Source_Position_Cartesian,
    )


def find_pos_cart(Source_Position_Cartesian, dir_cart):
    valmax = 0
@@ -76,6 +99,7 @@ def find_pos_cart( Source_Position_Cartesian, dir_cart):
        ind_dir = ind_dir + 1
    return indmax


def find_pos_spheric(Source_Position_Cartesian, dir_spheric):
    valmax = 0
    indmax = -1
@@ -100,6 +124,3 @@ def find_pos_spheric( Source_Position_Cartesian, dir_spheric):
            indmax = ind_dir
        ind_dir = ind_dir + 1
    return indmax


+61 −9
Original line number Diff line number Diff line
@@ -31,6 +31,12 @@
*******************************************************************************************************/
#include <string.h>
#include <stdio.h>
#ifdef _WIN32
#include <direct.h>
#define getcwd _getcwd
#elif
#include <unistd.h>
#endif
#include <math.h>
#include "options.h"
#include "ivas_cnst.h"
@@ -246,6 +252,9 @@ PyObject *import_name( const char *modname, const char *symbol )
    module = PyImport_Import( u_name );
    Py_DECREF( u_name );

    if ( module == NULL )
        return NULL;

    return PyObject_GetAttrString( module, symbol );
}

@@ -715,8 +724,36 @@ int main( int argc, char *argv[] )
        }
    }


#ifdef FIX_REMOVE_MYSOFA

    char current_path[_MAX_PATH];
    char ivas_path[_MAX_PATH];

    getcwd( current_path, _MAX_PATH );
    strcpy( ivas_path, current_path );
    strcpy( ivas_path, current_path );
    char *tmpstr = strstr( ivas_path, "\\binauralRenderer_interface" );
    tmpstr[0] = '\0';

    wchar_t *pyPath = Py_GetPath();

    wprintf( L"pyPath = %ls\n", pyPath );

    size_t len = wcslen( pyPath ) + strlen( ivas_path ) + strlen( current_path ) + 3;

    wchar_t *myPyPath = malloc( len * sizeof( wchar_t ) );

    swprintf( myPyPath, len, L"%ls;%hs;%hs", pyPath, current_path, ivas_path );
    // swprintf( myPyPath, len, L"%ls", pyPath );

    wprintf( L"myPyPath = %ls\n", myPyPath );

    Py_SetPath( myPyPath );

    pyPath = Py_GetPath();

    wprintf( L"pyPath = %ls\n", pyPath );

    Py_Initialize();

    if ( numpy_import_array( -1 ) == -1 )
@@ -728,23 +765,38 @@ int main( int argc, char *argv[] )
        return -1;
    }

    FILE *fp_py = _Py_fopen( "SofaReader.py", "r" );

    sofa_load_func = import_name( "SofaReader", "load" );

    if ( sofa_load_func == NULL )
    {
        Py_Finalize();
        fprintf( stderr, "SofaReader.py!\n\n" );
        usage_gen_crend_tables();

        return -1;
    }

    int ret = PyCallable_Check( sofa_load_func );
    if ( ret == 0 )
    {
        Py_DECREF( sofa_find_dir_func );
        fclose( fp_py );
        Py_DECREF( sofa_load_func );
        Py_Finalize();
        fprintf( stderr, "SofaReader.py!\n\n" );
        fprintf( stderr, "error reading SofaReader.py!\n\n" );
        usage_gen_crend_tables();

        return -1;
    }

    sofa_find_dir_func = import_name( "SofaReader", "find_pos_spheric" );
    if ( sofa_find_dir_func == NULL )
    {
        Py_DECREF( sofa_load_func );
        Py_Finalize();
        fprintf( stderr, "error reading SofaReader.py!\n\n" );
        usage_gen_crend_tables();

        return -1;
    }

    ret = PyCallable_Check( sofa_find_dir_func );
    if ( ret == 0 )
@@ -752,7 +804,6 @@ int main( int argc, char *argv[] )
        Py_DECREF( sofa_find_dir_func );
        Py_DECREF( sofa_load_func );

        fclose( fp_py );
        Py_Finalize();
        fprintf( stderr, "SofaReader.py!\n\n" );
        usage_gen_crend_tables();
@@ -869,7 +920,8 @@ int main( int argc, char *argv[] )
    Py_DECREF( sofa_find_dir_func );
    Py_DECREF( sofa_load_func );

    fclose( fp_py );
    free( myPyPath );

    Py_Finalize();
#endif

Loading