Moving sourceΒΆ
This example simulates a dry cello that moves from the left to the right of the
listener and stores the resulting binaural signal as
out_moving_source.wav
. If you want to test it run the
moving_source.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 | sim = simulator.SimulatorConvexRoom();
set(sim, ...
'HRIRDataset', simulator.DirectionalIR( ...
'impulse_responses/qu_kemar_anechoic/QU_KEMAR_anechoic_3m.sofa'), ...
'Sources', {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' ...
);
sim.set('Init',true);
sim.Sources{1}.setDynamic( ...
'Position', 'Velocity', 0.25); % move source with 0.25 m/s
set(sim.Sources{1}, ...
'Position', [1; -2; 0] ... %final position
);
while ~sim.isFinished()
sim.set('Refresh',true); % refresh all objects
sim.set('Process',true);
end
data = sim.Sinks.getData();
sim.Sinks.saveFile('out_moving_source.wav',sim.SampleRate);
sim.set('ShutDown',true);
|