sfstoolbox / sfs-matlab

SFS Toolbox for Matlab/Octave
https://sfs-matlab.readthedocs.io
MIT License
98 stars 39 forks source link

Error when SOFAload('***.sofa'); #38

Closed bayesrule closed 9 years ago

bayesrule commented 9 years ago

Hi,

Thank you first for this great project!

I encountered the following error when I was trying to generate an impulse response according to 'QU_KEMAR_anechoic_3m.sofa'.

Commands:

conf = SFS_config_example;
hrtf = SOFAload('QU_KEMAR_anechoic_3m.sofa');
ir = get_ir(hrtf,[0 0 0],[0 0],[rad(30) 0 3],'spherical',conf);
nsig = randn(44100,1);
sig = auralize_ir(ir,nsig,1,conf);
sound(sig,conf.fs);

Error:

Undefined function 'fieldnames' for input arguments of type 'double'.

Error in SOFAload (line 153)
    for field = fieldnames(ObjTemplate)'

NB, we found that SOFA API was not provided directly with SFS, therefore we then dug it out from http://sourceforge.net/projects/sofacoustics/ . Also 'QU_KEMAR_anechoic_3m.sofa' was missing, we found several from the database, they were all trapped in this error.

We tried to debug but couldn't manage to make it work.

Looking forward to your reply. Cheers!

hagenw commented 9 years ago

Hi.

Thanks for your interest in using SFS together with SOFA. The SOFA support is not fully finished yet and the latest official release of the SFS Toolbox is not using it, but it should be usable in general already in the master branch.

Could you be more specific on what exactly you did (Matlab/Octave, version, ...) as we were not able to reproduce this under Matlab (2015a) or Octave (3.8.2). For Octave you have to install octave-netcdf for SOFA support. Under Octave and Linux I did the following:

$ git clone https://github.com/sfstoolbox/sfs.git sfs
$ git clone https://github.com/sofacoustics/API_MO.git sofa
$ wget https://dev.qu.tu-berlin.de/projects/twoears-database/repository/revisions/master/raw/impulse_responses/qu_kemar_anechoic/QU_KEMAR_anechoic_3m.sofa
$ octave
>> addpath('sfs')
>> addpath('sofa/API_MO')
>> SOFAstart
>> SFS_start
>> conf = SFS_config_example;
>> hrtf = SOFAload('QU_KEMAR_anechoic_3m.sofa');

And everything went fine.

bayesrule commented 9 years ago

Hi,

Thank you so much for this swift reply. I have tried it with Matlab 2012b on Win 7 64bit as well as 2015a on Mac OSX.

What I did was simply downloading (all from their master branches)

  1. the whole SFS repository https://github.com/sfstoolbox/sfs/
  2. its data repository https://github.com/sfstoolbox/data
  3. SOFA API repository https://github.com/sofacoustics/API_MO
  4. the example sofa file 'QU_KEMAR_anechoic_3m.sofa' on http://sofacoustics.org/data/database/tu-berlin/

Then I put 2-4 into folder 1 (i.e. the sfs folder) and added this sfs folder and its subfolders to MATLAB path. Every example before BRIR generation was fine.

I simply ran the example commands

conf = SFS_config_example;
hrtf = SOFAload('QU_KEMAR_anechoic_3m.sofa');
ir = get_ir(hrtf,[0 0 0],[0 0],[rad(30) 0 3],'spherical',conf);
nsig = randn(44100,1);
sig = auralize_ir(ir,nsig,1,conf);
sound(sig,conf.fs);

and got the error

Undefined function 'fieldnames' for input arguments of type 'double'.

Error in SOFAload (line 153)
    for field = fieldnames(ObjTemplate)'

And one of my colleagues is trying this with Octave but encounter the mentioned octave-netcdf error and he is installing the package now, some errors sadly occurred though.

Several other colleagues also tried to help but all ended up with this 'fieldnames' error.

I googled it and found that this error usually occurs when the file structure is wrong...? I doubt if this applies to our case though.

Cheers!

bayesrule commented 9 years ago

Hi,

GOOD NEWS.

After carefully reading your answer, I found that I missed the

>>SOFAstart

this important command.

Now the error has gone. I just got

Warning: SOFA 0.6 upgraded to 1.0 

> In SOFAupgradeConventions (line 145)
  In SOFAload (line 186) 

and followed by a short period of noise, should be the impulse I suppose.

Many thanks for your time!

bayesrule commented 9 years ago

Sorry, another error when I continued the examples.

After the above example, I stepped into

conf = SFS_config_example;
conf.secondary_sources.size = 3;
conf.secondary_sources.number = 56;
conf.secondary_sources.geometry = 'circle';
conf.dimension = '2.5D';
hrtf = SOFAload('QU_KEMAR_anechoic_3m.sofa',conf);
% ir = ir_wfs(X,phi,xs,src,hrtf,conf);
ir = ir_wfs([0 0 0],pi/2,[0 3 0],'ps',hrtf,conf);
nsig = randn(44100,1);
sig = auralize_ir(ir,nsig,1,conf);

and it produced an error

Error using strfind
Inputs must be character arrays.

Error in SOFAload (line 51)
    elseif strfind('MREN',varargin{ii})

I checked the SOFAload function that I have. It seems the current SOFA API is not the one that used by the above SFS example? It is hard to understand the line strfind('MREN',varargin{ii}), since the input argument is 'conf' (hrtf = SOFAload('QU_KEMAR_anechoic_3m.sofa',conf);), which is a struct.

Cheers!

hagenw commented 9 years ago

Hi,

yes there was indeed an error in the README example, it should have been read hrtf = SOFAload('QU_KEMAR_anechoic_3m.sofa'). It is fixed with f7707f8.

hagenw commented 9 years ago

The README is now also updated to point to the sofa file.