Commit cedfb2ba authored by henryjandrew's avatar henryjandrew
Browse files

updated the gain used for diffraced path, and corrected the distance calculated for the direct path

parent 8937ff21
......@@ -26,7 +26,9 @@ H = va.create_directivity_from_file( 'ITA_Artificial_Head_5x5_44kHz_128.v17.ir.d
va.set_sound_receiver_directivity( L, H );
S = va.create_sound_source( 'VA_Source' );
X = va.create_signal_source_buffer_from_file( 'WelcomeToVA.wav' );
%X = va.create_signal_source_buffer_from_file( 'WelcomeToVA.wav' );
X = va.create_signal_source_buffer_from_file( fullfile('C:\ITASoftware\Raven\RavenDatabase\SoundDatabase','Full song - Vulfpeck - Dean Town.wav') );
va.set_signal_source_buffer_playback_action( X, 'play' )
va.set_signal_source_buffer_looping( X, true );
......@@ -34,7 +36,7 @@ va.set_sound_source_signal_source( S, X )
% House corner
w = itaFiniteWedge( [ 1 0 0 ], [ 0 0 -1 ], [ 0 -2 0 ], 4 ); % OpenGL coordinates
%% Example for a synchronized scene update & audio processing simulation/auralization
timestep = 128 / 44100; % here: depends on block size and sample rate
......@@ -47,7 +49,7 @@ disp( [ 'Resulting sound source speed: ' num2str( spatialstep / timestep ) ' m/s
numsteps = 3400;
disp( [ 'Simulation result duration: ' num2str( numsteps * timestep ) ' s' ] )
x = linspace( -1, 1, numsteps ) * 50; % motion from x = -5m to x = 5m
x = linspace( -1, 1, numsteps ) * 50; % motion from x = -50m to x = 50m
n0_of_paths = 2;
......@@ -57,7 +59,8 @@ for n = 1:length( x )
% Modify scene as you please (position has no real effect for prototype generic path renderer)
source_pos = [ x( n ) 1.1 -3 ]; % OpenGL coordinates
distance = sum( abs( source_pos - receiver_pos ) );
%distance = sum( abs( source_pos - receiver_pos ) );
distance = norm(source_pos - receiver_pos);
va.set_sound_source_position( S, source_pos );
......@@ -69,8 +72,8 @@ for n = 1:length( x )
prop_path_direct = struct();
prop_path_direct.ID = 0;
prop_path_direct.path = strcat( 'direct_', num2str(S2), '_to_', num2str(L) ); %sound path ID
prop_path_direct.distance = distance;
prop_path_direct.path = strcat( 'direct_', num2str(S), '_to_', num2str(L) ); %sound path ID
prop_path_direct.gain = 1/distance;
prop_path_direct.delay = distance / c; %delay from sound emitting from source to being received at listener
prop_path_direct.frequencies = f; %Frequencies corresponding to the mags
values = ones(1,31);
......@@ -84,19 +87,24 @@ for n = 1:length( x )
else
prop_path_direct.audible = ~shadow_zone;
end
% Diffracted sound path (id 1)
%prop_path_direct.audible = false;
apex = w.get_aperture_point( source_pos, receiver_pos );
detour = norm( source_pos - apex ) + norm(apex - receiver_pos );
prop_path_diffracted = struct();
prop_path_diffracted.distance = detour;
%prop_path_diffracted.distance = detour;
prop_path_diffracted.delay = detour / c;
prop_path_diffracted.frequencies = f;
[ ~, D ] = ita_diffraction_utd( w, source_pos, receiver_pos, f, c );
[H, D, A] = ita_diffraction_utd( w, source_pos, receiver_pos, f, c );
rho = norm(apex - source_pos);
prop_path_diffracted.gain = A / rho;
prop_path_diffracted.frequency_magnitudes = abs( D );
%prop_path_diffracted.frequency_magnitudes = values;
prop_path_diffracted.source = S;
prop_path_diffracted.receiver = L;
prop_path_diffracted.ID = 1;
......@@ -126,7 +134,7 @@ for n = 1:length( x )
va.call_module( 'virtualaudiodevice', struct( 'trigger', true ) );
waitbar( n / numsteps )
end
close( h )
......
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