Two dry sourcesΒΆ

In this example, two dry sources will be simulated and the binaural output is written to the file out_two_sources.wav. One source is a cello placed at the front left of the listener and the other source is castanets placed at the front right of the listener. If you want to test it run the two_sources.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
sim = simulator.SimulatorConvexRoom();
set(sim, ...
    'HRIRDataset', simulator.DirectionalIR( ...
        'impulse_responses/qu_kemar_anechoic/QU_KEMAR_anechoic_3m.sofa'), ...
    'Sources', {simulator.source.Point(), simulator.source.Point()}, ...
    'Sinks',   simulator.AudioSink(2) ...
    );
set(sim.Sources{1}, ...
    'Name', 'Cello', ...
    'Position', [1; 2; 0], ...
    'AudioBuffer', simulator.buffer.FIFO(1) ...
    );
set(sim.Sources{1}.AudioBuffer, ...
    'File', 'stimuli/anechoic/instruments/anechoic_cello.wav' ...
    );
set(sim.Sources{2}, ...
    'Name', 'Castanets', ...
    'Position', [1; -2; 0], ...
    'AudioBuffer', simulator.buffer.FIFO(1) ...
    );
set(sim.Sources{2}.AudioBuffer, ...
    'File', 'stimuli/anechoic/instruments/anechoic_castanets.wav' ...
    );
set(sim.Sinks, ...
    'Name', 'Head', ...
    'UnitX', [1; 0; 0], ...
    'Position', [0; 0; 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_two_sources.wav',sim.SampleRate);
sim.set('ShutDown',true);