sofacoustics / SOFAtoolbox

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

Failed to run usage code #66

Closed benitangela closed 1 year ago

benitangela commented 1 year ago

I got an error message when running the code available in the "Usage Code".

Here is my code:

%% put your information here:
hrtf = SOFAload('Restaurant.sofa');
soundInput = audioread('T010_HH5_00393.wav');

%% demo script
% Start SOFA
SOFAstart;
% Display some information about the impulse response
SOFAinfo(hrtf);
% Plot a figure with the measurement setup
SOFAplotGeometry(hrtf);
% Have a look at the size of the data
disp(['size [MxRxN]: ' num2str(size(hrtf.Data.IR))])
% Calculate the source position from a listener point of view
apparentSourceVector = SOFAcalculateAPV(hrtf);
% Listen to the HRTF with azimuth of -90°
apparentSourceVector(91, 1)
SOFAplotGeometry(hrtf, 91);
soundOutput = [conv(squeeze(hrtf.Data.IR(91, 1, :)), soundInput) ...
               conv(squeeze(hrtf.Data.IR(91, 2, :)), soundInput)];
sound(soundOutput, hrtf.Data.SamplingRate);

The error message I got:

Error using SOFAload (line 133)
Error loading the file: Restaurant.sofa
Undefined function 'NETCDFload' for input arguments of type 'char'.

Error in main (line 2)
hrtf = SOFAload('Restaurant.sofa');
petibub commented 1 year ago

The usage code has a wrong order: we need to start the toolbox before using its functionality, i.e., first SOFAstart;, then SOFAload(...);

Thanks for the pointer, Piotr