ita_raven_demo.m 2.27 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
Lukas Aspöck's avatar
Lukas Aspöck committed
10
11
% load ita raven project
rpf = itaRavenProject('..\RavenInput\Classroom\Classroom.rpf');
12
13

%% Simulationsparameter einstellen
Lukas Aspöck's avatar
Lukas Aspöck committed
14
% Image sources up to second order
15
16
17
rpf.setISOrder_PS(2);

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

Lukas Aspöck's avatar
Lukas Aspöck committed
20
% set impulse response length in ms (at least length of reverberation time)
21
rpf.setFilterLength(2800);  %[ms]
Lukas Aspöck's avatar
Lukas Aspöck committed
22
23
% rpf.setFilterLengthToReverbTime();    % estimates reverberation time and
% sets rpf.filterLength to this value
24

Lukas Aspöck's avatar
Lukas Aspöck committed
25
% set room temperature
26
27
28
rpf.setTemperature(21); %C


Lukas Aspöck's avatar
Lukas Aspöck committed
29
30
%% Define simulation outputs
% create monaural room impulse response
31
32
rpf.setGenerateRIR(1);

Lukas Aspöck's avatar
Lukas Aspöck committed
33
% create binaural room impulse response
34
35
rpf.setGenerateBRIR(1);

Lukas Aspöck's avatar
Lukas Aspöck committed
36
% create and export energy histograms
37
38
39
40
rpf.setExportHistogram(1);  % histogramme z.B. bentigt fr schnelle Nachhallzeitauswertung (RavenProject.getT30)


%% Quell- und Empfngerdaten
Lukas Aspöck's avatar
Lukas Aspöck committed
41
% set source positions
42
43
44
45
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
46
% set receiver positions
47
48
rpf.setReceiverPositions([4.4500    1.0000   -3.9000]);

Lukas Aspöck's avatar
Lukas Aspöck committed
49
% set sound source names
50
51
rpf.setSourceNames('Speaker Left');

Lukas Aspöck's avatar
Lukas Aspöck committed
52
% set source directivity 
53
54
rpf.setSourceDirectivity('KH_O100_Oli_5x5_3rd_relativiert_auf_azi0_ele0.daff');

Lukas Aspöck's avatar
Lukas Aspöck committed
55
56
%% start simulation 
% run simulation
57
58
59
rpf.run;

%% Ergebnisse abholen
Lukas Aspöck's avatar
Lukas Aspöck committed
60
61
% get room impulse responses
mono_ir = rpf.getMonauralImpulseResponseItaAudio();     % rpf.getMonauralImpulseResponse() without ITA-Toolbox
62
63
64
65
66
binaural = rpf.getBinauralImpulseResponseItaAudio();
reverb_time = rpf.getT30();


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

Lukas Aspöck's avatar
Lukas Aspöck committed
70
%% Example: Include loudspeaer frequency response in RIR (for comparisons with measurements)
71
72
73
74
ls_O100 = ita_read('..\RavenDatabase\FrequencyResponse\KH_O100_reference_holesclosed_final_at1V1m_fft14.ita');
ir_mit_lautsprecher = ita_convolve(mono_ir, ls_O100);

%% Additional features
Lukas Aspöck's avatar
Lukas Aspöck committed
75
76
77
78
79
% show room model including sound sources
 rpf.plotModel;
 
 % show absorption coefficients
 rpf.plotMaterialsAbsorption;