Commit 3a68b313 authored by Lukas Aspöck's avatar Lukas Aspöck
Browse files

extended method adjustAbsorptionToMatchReverbTime: user can select whether t20...

extended method adjustAbsorptionToMatchReverbTime: user can select whether t20 or t30 is used for optimization
parent 434ddaa3
......@@ -1917,7 +1917,7 @@ classdef itaRavenProject < handle
end
%------------------------------------------------------------------
function setFilterLength(obj, filter_length)
function setFilterLength(obj, filter_length)
% set filter length in ms
if filter_length < 3
filter_length = filter_length * 1000;
......@@ -4086,8 +4086,8 @@ classdef itaRavenProject < handle
end
%------------------------------------------------------------------
function newReverbTime = adjustAbsorptionToMatchReverbTime(obj, targetReverbTime, roomID, validationsimulation, materialPrefix, materialAppendix, materialIndexVector)
%adjustAbsorptionToMatchReverbTime(targetReverbTime, roomID, validationsimulation, materialPrefix, materialAppendix, materialIndexVector)
function newReverbTime = adjustAbsorptionToMatchReverbTime(obj, targetReverbTime, roomID, useT20, validationsimulation, materialPrefix, materialAppendix, materialIndexVector)
%adjustAbsorptionToMatchReverbTime(targetReverbTime, roomID, useT20, validationsimulation, materialPrefix, materialAppendix, materialIndexVector)
if isempty(obj.modelFileList)
return
end
......@@ -4097,6 +4097,9 @@ classdef itaRavenProject < handle
roomID = 0;
end
if nargin < 4
useT20 = false;% flag to check wheter to use t20 or t30
end
% check if simulation was already run
if isempty(obj.histogram)
if ~obj.exportHistogram
......@@ -4113,9 +4116,18 @@ classdef itaRavenProject < handle
% check back the reverberation times
numSources=size(obj.getSourcePosition,1);
thisReverbTime = obj.getT30(true,false,false,0);
if useT20
thisReverbTime = obj.getT20(true,false,false,0);
else
thisReverbTime = obj.getT30(true,false,false,0);
end
for iSources=2:numSources
thisReverbTime = thisReverbTime + obj.getT30(true,false,false,iSources-1);
if useT20
thisReverbTime = thisReverbTime + obj.getT20(true,false,false,iSources-1);
else
thisReverbTime = thisReverbTime + obj.getT30(true,false,false,iSources-1);
end
end
thisReverbTime = thisReverbTime / numSources;
......@@ -4139,9 +4151,9 @@ classdef itaRavenProject < handle
end
end
materialNames = roommodel.getMaterialNames(); % read materials out of the ac3d model
if nargin > 4
if nargin > 5
newMaterialNames = strcat(materialPrefix, materialNames);
if nargin > 5
if nargin > 6
newMaterialNames = strcat(newMaterialNames, materialAppendix);
end
roommodel.setMaterialNames(newMaterialNames);
......@@ -4178,7 +4190,7 @@ classdef itaRavenProject < handle
% apply new absorption values
matProcessed={};
if nargin < 7
if nargin < 8
materialIndexVector = 1 : numel(materialNames);
else
materialIndexVector = materialIndexVector + 1; % C++ starts counting at zero, but MATLAB starts at 1
......@@ -4203,14 +4215,19 @@ classdef itaRavenProject < handle
end
end
if (nargin < 4) || validationsimulation
if (nargin < 5) || validationsimulation
disp('repeat simulation for validation');
obj.run();
% check back the reverberation times
newReverbTime = obj.getT30(true,false,false,0);
for iSources=2:numSources
newReverbTime = newReverbTime + obj.getT30(true,false,false,iSources-1);
if useT20
newReverbTime = newReverbTime + obj.getT20(true,false,false,iSources-1);
else
newReverbTime = newReverbTime + obj.getT30(true,false,false,iSources-1);
end
end
newReverbTime = newReverbTime / numSources;
......@@ -4219,7 +4236,12 @@ classdef itaRavenProject < handle
plot(1:nRT, targetReverbTime, 1:nRT, thisReverbTime, 1:nRT, newReverbTime);
legend('Target RT', 'RT before', 'RT after');
ylabel('T30 [s]');
if useT20
ylabel('T20 [s]');
else
ylabel('T30 [s]');
end
xlabel('Frequency band [Hz]');
ylim([0 1.2*max(targetReverbTime)]);
......@@ -5548,7 +5570,7 @@ classdef itaRavenProject < handle
obj.setOutputPath(oldPath);
end
%------------------------------------------------------------------
%------------------------------------------------------------------
function monoIR = getMonauralImpulseResponse(obj)
if isempty(obj.monoIR)
error('No mono room impulse response present.');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment