sofacoustics / SOFAtoolbox

SOFA Toolbox (API for Matlab, Octave)
http://sofaconventions.org
European Union Public License 1.2
115 stars 32 forks source link

hrtf = SOFAload('hrtf_M_hrtf B.sofa'); warning: Invalid UTF-8 byte sequences have been replaced. #76

Open PacoH opened 1 year ago

PacoH commented 1 year ago

What needs to be done to get this to work?

SOFAstart;
hrtf = SOFAload('hrtf_M_hrtf B.sofa');
warning: Invalid UTF-8 byte sequences have been replaced.
warning: implicit conversion from numeric to char
warning: called from
    SOFAload at line 133 column 9

'NETCDFload' undefined near line 128, column 128a
error: called from
    SOFAload at line 133 column 9

hrtf_M_hrtf B.sofa is in SOFAtoolbox upper level directory.

petibub commented 1 year ago

could you provide the sofa file (to reproduce your issue)?

PacoH commented 1 year ago

Sure. Thanks for your reply. I'm not sure if it is just a path problem. I am new to Octave. The upper SOFAtoolbox directory has been added to the path and hrtf_M_hrtf B.sofa is in that directory:

Screenshot 2023-07-03 at 11 25 03 AM w=600 px

hrtf_M_hrtf B.zip

isfmiho commented 1 year ago

I could not reproduce the issue with Matlab.

Octave returns some warnings though, regarding invalid UTF-8 byte sequences similar to yours. No error though.

I'm wondering if SOFAstart runs properly, it does not return a version number. Which version of SOFA Toolbox do you use?

isfmiho commented 1 year ago

Why do you use these very old SOFA files, SOFA version 0.6? They are deprecated for almost 10 years.

Can you please try to get the latest version from: https://www.sofaconventions.org/mediawiki/index.php/Files (ARI database -> hrtf_nh2.sofa)

PacoH commented 1 year ago

I'm wondering if SOFAstart runs properly, it does not return a version number. Which version of SOFA Toolbox do you use?

Is it supposed to return a version number? If so that is not mentioned or demonstrated in the documentation. Maybe it only does that in Matlab?

Installed from SOFA Toolbox for Matlab and Octave 2.1.4.zip. Is there a way to get the version number from within Octave. Is there a list of commands available for this toolbox? BTW, the Octave documentation does not mention toolboxes, only packages, which seems peculiar.

PacoH commented 1 year ago

Why do you use these very old SOFA files, SOFA version 0.6? They are deprecated for almost 10 years.

Can you please try to get the latest version from: https://www.sofaconventions.org/mediawiki/index.php/Files (ARI database -> hrtf_nh2.sofa)

The reason I am using these SOFA files is because they are all I was able to find in the sparse documentation of the sofalizer ffmpeg filter.

sofalizer - FFmpeg

[FFmpeg-cvslog] doc/filters: add sofalizer examples

SOFAlize This! Downmixing multi-channel audio to stereo – Code Wanderer

I have no way of knowing what SOFA version they are since there are thousands of SOFA files available but I have yet to find a single one that is documented. Hence my interest in this toolbox. I need to identify SOFA files that would work for me. The toolbox page states, "SOFA Toolbox 2.x implements SOFA versions 2.x," but I couldn't find any that were identified as such.

>> hrtf=SOFAload('hrtf_nh2.sofa');
warning: implicit conversion from numeric to char
warning: called from
    SOFAload at line 133 column 9

'NETCDFload' undefined near line 128, column 128
error: called from
    SOFAload at line 133 column 9

Same error.

petibub commented 1 year ago

When I do that in Octave 8.2.0 on Windows, I get:

SOFAstart
SOFA Toolbox for Matlab/Octave 2.1.4. Copyright: Acoustics Research Institute.
This API implements SOFA version 2.1.
Available SOFA Conventions: FreeFieldDirectivityTF, FreeFieldHRIR, FreeFieldHRTF, General, GeneralFIR, GeneralFIR
-E, GeneralSOS, GeneralString, GeneralTF, GeneralTF-E, SimpleFreeFieldHRIR, SimpleFreeFieldHRSOS, SimpleFreeField
HRTF, SimpleFreeFieldSOS, SimpleHeadphoneIR, SingleRoomMIMOSRIR, SingleRoomSRIR
SOFAdbPath (local HRTF database): C:\ISF\AMT\alle branches\thirdparty\sofa\data\SOFA
SOFAdbURL (internet repository): http://www.sofacoustics.org/data
>> hrtf = SOFAload('hrtf_M_hrtf B.sofa');
warning: Invalid UTF-8 byte sequences have been replaced.
warning: Invalid UTF-8 byte sequences have been replaced.
warning: called from
    SOFAload at line 128 column 17

warning: Invalid UTF-8 byte sequences have been replaced.
warning: called from
    SOFAgetConventions at line 118 column 61
    SOFAload at line 152 column 21

When ignoring the warnings, the load seems to succeed. Interesting is that I do see the version of the Toolbox - as Michael mentioned, it would be good to see why you don't see the version.

PacoH commented 1 year ago

Well there may be a difference in the Windows version and the Matlab version of Octave compared to the Macos version. But in any case there is no error.

When ignoring the warnings, the load seems to succeed.

Succeed how? Did you try SOFAinfo(hrtf);?

This is what I get:

>> SOFAstart;
>> hrtf = SOFAload('hrtf_M_hrtf B.sofa');
warning: implicit conversion from numeric to char
warning: called from
    SOFAload at line 133 column 9

'NETCDFload' undefined near line 128, column 128a
error: called from
    SOFAload at line 133 column 9
>> SOFAinfo(hrtf);
error: 'hrtf' undefined near line 1, column 1

What do you get with the SOFA file that isfmiho recommended?:

hrtf_nh2.zip

isfmiho commented 1 year ago

Unfortunately I have no experience with Octave in MacOS. SOFAgetVersion will also show the version number.

Can you please try to:

PacoH commented 1 year ago
>> SOFAstart;
>> SOFAgetVersion
ans = 2.1.4

So that works.

petibub commented 1 year ago

When thinking about the cause of your problem (which we cannot reproduce), one thought: Why can you do SOFAstart; and the load an HRTF which is NOT in the same directory as SOFAstart without changing the directory. Do you have some paths added to the search path of Octave - which might explain the irreproducible behavior?

If yes, remove all SOFA related paths, restart Octave, check again if there are no SOFA-related paths, go to the directory with SOFAstart, call SOFAstart, then you MUST change the directory to that one with your HRTFs, and there you call hrtf=SOFAload(..);.

I wonder if you'll get the error then...

isfmiho commented 11 months ago

When thinking about the cause of your problem (which we cannot reproduce), one thought: Why can you do SOFAstart; and the load an HRTF which is NOT in the same directory as SOFAstart without changing the directory. Do you have some paths added to the search path of Octave - which might explain the irreproducible behavior?

If yes, remove all SOFA related paths, restart Octave, check again if there are no SOFA-related paths, go to the directory with SOFAstart, call SOFAstart, then you MUST change the directory to that one with your HRTFs, and there you call hrtf=SOFAload(..);.

I wonder if you'll get the error then...

@PacoH: Did petibub's suggestions help? Is the issue solved?

PacoH commented 11 months ago

Thanks isfmiho. I will try this.