itaVA_example_simple.m 1.06 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
%% itaVA simple example code

% Create itaVA
va = itaVA;

% Connect to VA application (start the application first)
va.connect( 'localhost' )

% Reset VA to clear the scene
va.reset()

% Control output gain
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
13
va.set_output_gain( .25 )
14 15

% Add the current absolute folder path to VA application
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
16
va.add_search_path( pwd );
17 18

% Create a signal source and start playback
Dipl.-Ing. Jonas Stienen's avatar
Fixes  
Dipl.-Ing. Jonas Stienen committed
19
X = va.create_signal_source_buffer_from_file( '$(DemoSound)' );
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
20 21
va.set_signal_source_buffer_playback_action( X, 'play' )
va.set_signal_source_buffer_looping( X, true );
22 23

% Create a virtual sound source and set a position
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
24
S = va.create_sound_source( 'itaVA_Source' );
Dipl.-Ing. Jonas Stienen's avatar
Fixes  
Dipl.-Ing. Jonas Stienen committed
25
va.set_sound_source_position( S, [ 2 1.7 2 ] )
26 27

% Create a listener with a HRTF and position him
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
28
L = va.create_sound_receiver( 'itaVA_Listener' );
Dipl.-Ing. Jonas Stienen's avatar
Fixes  
Dipl.-Ing. Jonas Stienen committed
29
va.set_sound_receiver_position( L, [ 0 1.7 0 ] )
30

Dipl.-Ing. Jonas Stienen's avatar
Fixes  
Dipl.-Ing. Jonas Stienen committed
31 32
H = va.create_directivity( '$(DefaultHRIR)' );
va.set_sound_receiver_directivity( L, H );
33

34 35 36
% Connect the signal source to the virtual sound source
va.set_sound_source_signal_source( S, X )

Dipl.-Ing. Jonas Stienen's avatar
Fixes  
Dipl.-Ing. Jonas Stienen committed
37 38
% More information
disp( 'Type ''doc itaVA'' for more information.' )