Skip to content

NETCDFload bug when loading strings with dimension dimension MSI #87

Description

@isfmiho

NETCDFload crashes when loading a SOFA file, with strings having dimension MSI. Just copy and run the following code to reproduce issue. No data required, just the SOFA Toolbox.

E = 1 -> not working:

 %%  IS NOT WORKING: FreeFieldDirectivityFIR with 1 Emitter
SOFAstart;
N = 48000;  % number of dummy samples
clear str;

E = 1; % define number of emitters
Obj=SOFAgetConventions('FreeFieldDirectivityFIR');
Obj.Data.IR = zeros(Obj.API.M,Obj.API.R,N); % defines mrn
Obj.Data.Delay = zeros(Obj.API.M,Obj.API.R); % mandatory; must be IR, MR
Obj.EmitterPosition = repmat([0 0 0], E, 1); % defines e; must be eCI, eCM
Obj = SOFAupdateDimensions(Obj);

for ii=1:Obj.API.E
  str{ii,1}=['String' num2str(round(rand(1,1)*10000))];
end
Obj = SOFAaddVariable(Obj,'EmitterDescriptions','MSI',str); % can be MSI, ESI, MES
% Obj = SOFAaddVariable(Obj,'EmitterDescriptions','ESI',str); % can be MSI, ESI, MES - but will be converted to MSI
% Obj = SOFAaddVariable(Obj,'EmitterDescriptions','MES',str); % can be MSI, ESI, MES - but will be converted to MSI

%% SAVE AND LOAD
Obj = SOFAupdateDimensions(Obj);
disp(Obj.EmitterDescriptions);
SOFAsave('test.sofa',Obj);
Obj2=SOFAload('test.sofa'); % crashes in NETCDFload 

E = 2 -> working:

 %%  IS WORKING: FreeFieldDirectivityFIR with 2 Emitters
SOFAstart;
N = 48000;  % number of dummy samples
clear str;

E = 2; % define number of emitters
Obj=SOFAgetConventions('FreeFieldDirectivityFIR');
Obj.Data.IR = zeros(Obj.API.M,Obj.API.R,N); % defines mrn
Obj.Data.Delay = zeros(Obj.API.M,Obj.API.R); % mandatory; must be IR, MR
Obj.EmitterPosition = repmat([0 0 0], E, 1); % defines e; must be eCI, eCM
Obj = SOFAupdateDimensions(Obj);
for ii=1:Obj.API.E
  str{ii,1}=['String' num2str(round(rand(1,1)*10000))];
end
Obj = SOFAaddVariable(Obj,'EmitterDescriptions','ESI',str); % can be MSI, ESI, MES

%% SAVE AND LOAD
Obj = SOFAupdateDimensions(Obj);
disp(Obj.EmitterDescriptions);
SOFAsave('test.sofa',Obj);
Obj2=SOFAload('test.sofa');

This is where the crash happens in NETCDFload.m in E = 1 case;

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions