Commit 1295761a authored by lefort's avatar lefort
Browse files

Corrected for MacOS.

parent bd994d57
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ def load(
    hrtf = Dataset(filename, "r", format="NETCDF4")
    Database_Name = hrtf.DatabaseName
    Listener_Short_Name = hrtf.ListenerShortName
    latencys = None
    latencys = 0
    if "latencys" in hrtf.variables.keys():
        latencys = np.array(hrtf.variables["latencys"])
    Sampling_Rate = np.array(hrtf.variables["Data.SamplingRate"])
+52 −9
Original line number Diff line number Diff line
@@ -34,8 +34,10 @@
#ifdef _WIN32
#include <direct.h>
#define getcwd _getcwd
#elif
#define MAX_PATH _MAX_PATH
#else
#include <unistd.h>
#define MAX_PATH PATH_MAX
#endif
#include <math.h>
#include "options.h"
@@ -726,15 +728,16 @@ int main( int argc, char *argv[] )

#ifdef FIX_REMOVE_MYSOFA

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

    getcwd( current_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" );
    char *tmpstr = strstr( ivas_path, "/binauralRenderer_interface" );
    tmpstr[0] = '\0';

#ifdef _WIN32
    wchar_t *pyPath = Py_GetPath();

    wprintf( L"pyPath = %ls\n", pyPath );
@@ -753,11 +756,24 @@ int main( int argc, char *argv[] )
    pyPath = Py_GetPath();

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

    Py_Initialize();

#ifndef _WIN32
    PyObject* sysPath = PySys_GetObject((char*)"path");
    PyList_Append(sysPath, (PyUnicode_FromString(current_path)));
    PyList_Append(sysPath, (PyUnicode_FromString(ivas_path)));
#endif

    if ( numpy_import_array( -1 ) == -1 )
    {
#ifdef _WIN32
        free( myPyPath );
#else
        Py_DECREF( sysPath );
#endif

        Py_Finalize();
        fprintf( stderr, "Cannot load numpy!\n\n" );
        usage_gen_crend_tables();
@@ -769,6 +785,12 @@ int main( int argc, char *argv[] )

    if ( sofa_load_func == NULL )
    {
#ifdef _WIN32
        free( myPyPath );
#else
        Py_DECREF( sysPath );
#endif

        Py_Finalize();
        fprintf( stderr, "SofaReader.py!\n\n" );
        usage_gen_crend_tables();
@@ -780,6 +802,12 @@ int main( int argc, char *argv[] )
    if ( ret == 0 )
    {
        Py_DECREF( sofa_load_func );
#ifdef _WIN32
        free( myPyPath );
#else
        Py_DECREF( sysPath );
#endif

        Py_Finalize();
        fprintf( stderr, "error reading SofaReader.py!\n\n" );
        usage_gen_crend_tables();
@@ -791,6 +819,12 @@ int main( int argc, char *argv[] )
    if ( sofa_find_dir_func == NULL )
    {
        Py_DECREF( sofa_load_func );
#ifdef _WIN32
        free( myPyPath );
#else
        Py_DECREF( sysPath );
#endif

        Py_Finalize();
        fprintf( stderr, "error reading SofaReader.py!\n\n" );
        usage_gen_crend_tables();
@@ -803,6 +837,11 @@ int main( int argc, char *argv[] )
    {
        Py_DECREF( sofa_find_dir_func );
        Py_DECREF( sofa_load_func );
#ifdef _WIN32
        free( myPyPath );
#else
        Py_DECREF( sysPath );
#endif

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

#ifdef _WIN32
    free( myPyPath );
#else
    Py_DECREF( sysPath );
#endif

    Py_Finalize();
#endif
@@ -990,17 +1033,17 @@ int generate_crend_ivas_tables_from_sofa( const char *file_path, bool no_optim )
        args = Py_BuildValue( "(s)", sofa_file_path );
        kwargs = NULL;
        py_results = PyObject_Call( sofa_load_func, args, kwargs );
        Py_DECREF( args );

        if ( py_results == NULL )
        {
            Py_DECREF( py_results );

            fprintf( stderr, "Wrong file with wrong sample rate %s!\n\n", sofa_file_path );
            usage_gen_crend_tables();
            free( sofa_file_path );

            return -1;
        }
        Py_DECREF( args );

        ret = PyTuple_Check( py_results );
        if ( ret )
        {
@@ -1297,7 +1340,7 @@ int generate_crend_ivas_tables_from_sofa( const char *file_path, bool no_optim )
            if ( a[0] < -180 )
                a[0] += 360;
            fprintf( stderr, "Nearest Position: %f, %f, %f\n", a[0], a[1], a[2] );
            fprintf( stderr, "Nearest position found at: %d\n", nearest );
            fprintf( stderr, "Nearest position found at: %ld\n", nearest );
            index_pos[i] = nearest;
        }
        else