Fixing a problem concerning the Doppler shift in outdoor noise DSP parameter struct

parent a0a07c6c
......@@ -5,20 +5,25 @@
% to hard drive.
cont = struct();
conf.free_field_only = false; % No occlusion, no reflections
conf.direct_field_component = true;
conf.diffracted_field_component = true;
conf.reflected_field_component = false; % Causes heavy phasing due to comb filter effects
conf.free_field_only = false; % No occlusion, no reflections, will override field component setup
conf.direct_field_component = true; % If true, direct sound field component is included
conf.diffracted_field_component = true; % If true, direct sound field component is included
conf.reflected_field_component = true; % Causes heavy phasing due to comb filter effects
conf.update_gain_individually = true;
conf.with_delay_update = true;
conf.update_gain_individually = true; % If true, updates gain in DSP components, otherwise gain is applied to filter coefficients
conf.with_delay_update = true; % If true, updates the delay in VDL DSP component, otherwise propagation delay is ignored
receiver_pos = [ 3 0 3 ]; % OpenGL coordinates
buffer_length = 128;
sampling_rate = 44100;
f = ita_ANSI_center_frequencies;
receiver_pos = [ 3 0 3 ]; % OpenGL coordinates in meter
source_pos_range = [ [ -20 0 -3 ]; [ 20 0 -3 ] ]; % OpenGL coordinates in meter
source_velocity = 30 / 3.6; % m/s
% House corner
w = itaInfiniteWedge( [ 1 0 0 ], [ 0 0 -1 ], [ 0 0 0 ] ); % OpenGL coordinates
%% Connect and set up simple scene
va = VA;
......@@ -34,6 +39,7 @@ try
va.add_search_path( 'D:/Users/stienen/dev/VA/VACore/data' );
va.add_search_path( 'C:/ITASoftware/Raven/RavenDatabase/SoundDatabase' );
va.add_search_path( 'C:\Users\jonas\sciebo\ITA\Lehre\Masterarbeiten\2019 Henry Andrew\car_pass-by_corner' );
va.add_search_path( 'D:\Users\stienen\Sciebo\Thesis stuff\auralization\resources' );
c = va.get_homogeneous_medium_sound_speed();
......@@ -48,6 +54,9 @@ try
%X = va.create_signal_source_buffer_from_file( 'WelcomeToVA.wav' );
X = va.create_signal_source_buffer_from_file( 'LKW Leerlauf 2.wav' );
%X = va.create_signal_source_buffer_from_file( 'complex_tonal.wav' );
%X = va.create_signal_source_buffer_from_file( 'complex_tonal_and_noise.wav' );
%X = va.create_signal_source_buffer_from_file( 'pinknoise.wav' );
%X = va.create_signal_source_buffer_from_file( 'Full song - Vulfpeck - Dean Town.wav' );
va.set_signal_source_buffer_playback_action( X, 'play' )
va.set_signal_source_buffer_looping( X, true );
......@@ -65,21 +74,29 @@ end
k = 2 * pi * f ./ c;
%% Example for a synchronized scene update & audio processing simulation/auralization
timestep = 128 / 44100; % here: depends on block size and sample rate
%% Synchronized scene update & audio processing simulation/auralization
timestep = buffer_length / sampling_rate; % here: depends on block size and sample rate
disp( [ 'Resulting time step resolution: ' num2str( timestep ) 's' ] )
traj_distance = norm( source_pos_range( 1, : ) - source_pos_range( 2, : ) );
traj_duration = traj_distance / source_velocity;
numsteps = ceil( traj_duration / timestep );
fprintf( 'Simulation trajectory distance: %.1fs\n', traj_distance )
fprintf( 'Simulation result duration: %.1fs\n', traj_duration )
fprintf( 'Simulation frames total: %i\n', numsteps )
manual_clock = 0;
if ~dry_run
va.set_core_clock( 0 );
end
spatialstep = 0.1 / 2;
disp( [ 'Resulting sound source speed: ' num2str( spatialstep / timestep ) ' m/s' ] )
numsteps = 3400 * 2;
disp( [ 'Simulation result duration: ' num2str( numsteps * timestep ) ' s' ] )
x = linspace( -1, 1, numsteps ) * 20; % motion from x = -50m to x = 50m
source_pos_traj = zeros( numsteps, 3 );
source_pos_traj( :, 1 ) = linspace( source_pos_range( 1, 1 ), source_pos_range( 2, 1 ), numsteps );
source_pos_traj( :, 2 ) = linspace( source_pos_range( 1, 2 ), source_pos_range( 2, 2 ), numsteps );
source_pos_traj( :, 3 ) = linspace( source_pos_range( 1, 3 ), source_pos_range( 2, 3 ), numsteps );
H_direct_log = []; % Direct field component
H_diffracted_log = []; % Diffracted field component
......@@ -89,9 +106,9 @@ IL_log = []; % Insertion loss (total field relative to direct field under free-f
h = waitbar( 0, 'Hold on, running auralization' );
direct_deleted = false; %set to true when the direct path has been deleted
for n = 1:length( x )
for n = 1:numsteps
source_pos = [ x( n ) 0 -3 ]; % OpenGL coordinates
source_pos = source_pos_traj( n, : ); % OpenGL coordinates
if ~dry_run
va.set_sound_source_position( S, source_pos );
end
......@@ -130,7 +147,8 @@ for n = 1:length( x )
prop_path_direct.frequency_magnitudes = abs( H_direct );
end
if ~conf.with_delay_update || n == 1
% Set delay (once if disabled)
if conf.with_delay_update || n == 1
prop_path_direct.delay = distance / c; %delay from sound emitting from source to being received at listener
end
......@@ -150,11 +168,7 @@ for n = 1:length( x )
prop_path_diffracted.position = apex;
prop_path_diffracted.frequencies = f;
prop_path_diffracted.audible = true;
if ~conf.with_delay_update || n == 1
prop_path_diffracted.delay = distance / c;
end
if conf.update_gain_individually
prop_path_diffracted.gain = ( -1 ) * A / rho; % Invert phase
prop_path_diffracted.frequency_magnitudes = abs( D );
......@@ -163,6 +177,14 @@ for n = 1:length( x )
prop_path_diffracted.frequency_magnitudes = abs( H_diffracted );
end
if ~conf.with_delay_update
if n == 1
prop_path_diffracted.delay = distance / c; % Set all-same distance once if disabled
end
else
prop_path_diffracted.delay = detour / c;
end
%% Reflected sound path
......@@ -198,14 +220,16 @@ for n = 1:length( x )
prop_path_reflected.gain = 1;
prop_path_reflected.frequency_magnitudes = abs( H_reflected );
end
if ~conf.with_delay_update
if n == 1
prop_path_reflected.delay = distance / c; % For all-same delay
prop_path_reflected.delay = distance / c; % For all-same delay, set once only if disabled
end
else
prop_path_reflected.delay = distance_image / c;
end
%% Update wave fronts in renderer
paths_update = struct();
if conf.free_field_only || conf.direct_field_component
......@@ -260,13 +284,11 @@ for n = 1:length( x )
end
close( h )
save( 'example_outdoor_acoustics_output_data.mat', 'run_data', 'all_path_names' ); %save variables to file
if ~dry_run
va.disconnect
disp( 'Stop VA to export simulation results from rendering module(s)' )
else
figure
plot( db( H_total_field_log ) )
plot( db( H_total_field_log ) ) % @todo make nicer plot
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment