ita_raven_demo.m 2.68 KB
Newer Older
Lukas Aspöck's avatar
Lukas Aspöck committed
1
% 1. set/check matlab paths
2 3 4 5 6 7 8 9


% <ITA-Toolbox>
% This file is part of the application Raven for the ITA-Toolbox. All rights reserved.
% You can find the license for this m-file in the application folder.
% </ITA-Toolbox>

%% Projektdatei einlesen
10 11 12 13 14 15 16
% project laden
ravenProjectPath = '..\RavenInput\Classroom\Classroom.rpf';

if (~exist(ravenProjectPath,'file'))
    [filename, pathname] = uigetfile('Classroom.rpf', 'Please select raven project file!');
    ravenProjectPath = [pathname filename];
end
17 18
ravenBasePath = ravenProjectPath(1:end-34);

19
rpf = itaRavenProject(ravenProjectPath);
20
%% Simulationsparameter einstellen
Lukas Aspöck's avatar
Lukas Aspöck committed
21
% Image sources up to second order
22 23 24
rpf.setISOrder_PS(2);

% 20000 ray tracing partikel
Lukas Aspöck's avatar
Lukas Aspöck committed
25
rpf.setNumParticles(200);
26

Lukas Aspöck's avatar
Lukas Aspöck committed
27
% set impulse response length in ms (at least length of reverberation time)
28
rpf.setFilterLength(2800);  %[ms]
Lukas Aspöck's avatar
Lukas Aspöck committed
29 30
% rpf.setFilterLengthToReverbTime();    % estimates reverberation time and
% sets rpf.filterLength to this value
31

Lukas Aspöck's avatar
Lukas Aspöck committed
32
% set room temperature
33 34 35
rpf.setTemperature(21); %C


Lukas Aspöck's avatar
Lukas Aspöck committed
36 37
%% Define simulation outputs
% create monaural room impulse response
38 39
rpf.setGenerateRIR(1);

Lukas Aspöck's avatar
Lukas Aspöck committed
40
% create binaural room impulse response
41 42
rpf.setGenerateBRIR(1);

Lukas Aspöck's avatar
Lukas Aspöck committed
43
% create and export energy histograms
44 45 46 47
rpf.setExportHistogram(1);  % histogramme z.B. bentigt fr schnelle Nachhallzeitauswertung (RavenProject.getT30)


%% Quell- und Empfngerdaten
Lukas Aspöck's avatar
Lukas Aspöck committed
48
% set source positions
49 50 51 52
rpf.setSourcePositions([9 1.7 -2.5]);
rpf.setSourceViewVectors([-1 0 0]);
rpf.setSourceUpVectors([0 1 0]);

Lukas Aspöck's avatar
Lukas Aspöck committed
53
% set receiver positions
54 55
rpf.setReceiverPositions([4.4500    1.0000   -3.9000]);

Lukas Aspöck's avatar
Lukas Aspöck committed
56
% set sound source names
57 58
rpf.setSourceNames('Speaker Left');

Lukas Aspöck's avatar
Lukas Aspöck committed
59
% set source directivity 
60 61
rpf.setSourceDirectivity('KH_O100_Oli_5x5_3rd_relativiert_auf_azi0_ele0.daff');

Lukas Aspöck's avatar
Lukas Aspöck committed
62 63
%% start simulation 
% run simulation
64 65 66
rpf.run;

%% Ergebnisse abholen
Lukas Aspöck's avatar
Lukas Aspöck committed
67 68
% get room impulse responses
mono_ir = rpf.getMonauralImpulseResponseItaAudio();     % rpf.getMonauralImpulseResponse() without ITA-Toolbox
69 70 71 72 73
binaural = rpf.getBinauralImpulseResponseItaAudio();
reverb_time = rpf.getT30();


%% ITA-Toolbox......
Lukas Aspöck's avatar
Lukas Aspöck committed
74 75
mono_ir.plot_time;      % plot monaural RIR in time domain
binaural.plot_freq;     % plot binaural RIR in time domain
76

Lukas Aspöck's avatar
Lukas Aspöck committed
77
%% Example: Include loudspeaer frequency response in RIR (for comparisons with measurements)
78 79 80 81 82 83
pathFrequencyResponse = '..\RavenDatabase\FrequencyResponse\KH_O100_reference_holesclosed_final_at1V1m_fft14.ita';
if (~exist(pathFrequencyResponse,'file'))
    pathFrequencyResponse = [ ravenBasePath pathFrequencyResponse(4:end) ];
end

ls_O100 = ita_read(pathFrequencyResponse);
84 85 86
ir_mit_lautsprecher = ita_convolve(mono_ir, ls_O100);

%% Additional features
Lukas Aspöck's avatar
Lukas Aspöck committed
87 88 89 90 91
% show room model including sound sources
 rpf.plotModel;
 
 % show absorption coefficients
 rpf.plotMaterialsAbsorption;
92 93