Rooms using the Image Source Model

This example simulates a dry cello in a shoe box room and stores the resulting binaural signal in out_room.wav. The shoe box room is simulated with an image source model. If you want to test it run the room.m script.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
set(sim, ...
    'MaximumDelay', 0.5, ...
    'PreDelay', 0.0, ...
    'HRIRDataset', simulator.DirectionalIR( ...
        'impulse_responses/qu_kemar_anechoic/QU_KEMAR_anechoic_3m.sofa'), ...
    'Sources', {simulator.source.ISMGroup}, ...
    'Sinks', simulator.AudioSink(2), ...
    'Room', simulator.room.Shoebox ...
    );
set(sim.Sources{1}, ...
    'Name', 'Cello', ...
    'Position', [2.5; 2.5; 0], ...
    'AudioBuffer', simulator.buffer.FIFO(1), ...
    'Room', sim.Room ...
    );
set(sim.Sources{1}.AudioBuffer, ...
    'File', 'stimuli/anechoic/instruments/anechoic_cello.wav' ...
    );
% define the room
set(sim.Room, ...
    'Name', 'Room', ...
    'Position', [-3; -3; -1.75], ...
    'UnitX', [1; 0; 0], ...
    'UnitZ', [0; 0; 1], ...
    'LengthX', 6.0, ...
    'LengthY', 6.0, ...
    'LengthZ', 2.7, ...
    'ReverberationMaxOrder', 8, ...
    'RT60', 1.0 ...
    );
sim.set('Init',true);
while ~sim.isFinished()
    sim.set('Refresh',true);  % refresh all objects
    sim.set('Process',true);
end
data = sim.Sinks.getData();
sim.Sinks.saveFile('out_room.wav',sim.SampleRate);  % save file
sim.set('ShutDown',true);