Commit 33219b32 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen

Merge branch 'va_2018_api_change'

parents 398ada13 dc2dd395
function pos = ita_3da_LSSetup_VRLab(varargin)
% Give back the position, in meters, of the 8 loudspeakers in the VR lab.
% See options for more details
% Give back the position, in meters, of the 12 loudspeakers in the VR lab.
% See options for more details
% Author: Michael Kohnen -- Email: mko@akustik.rwth-aachen.de
% Date: 03-May-2017
% Date: 19-Dec-2017
% Options
opts.virtualSpeaker = false; % true || Indicates whether to add virtual speaker achieve a more regular distribution (stabilizes the pseudoinverse in Ambisonics Decoding)
opts.coordSystem = 'itaCoordinates'; % 'openGL' || indicates in which coordinate system the output is
opts.isItaCoordinates = true; % true || indicates whether the output is a itaCoordinate or not (warning: if combined with coordSystem='opneGL', the angles for azimuth and elevation are not correct
opts.heightCorrection = 0.0597; % in meter || ensures that the loudspeakers are around the point (0 0 0), standard value is height of the bigger loudspeaker in the horizontal plane
opts.isItaCoordinates = true; % true || indicates whether the output is a itaCoordinate or not (warning: if combined with coordSystem='opneGL', the angles for azimuth and elevation are not correct
opts.heightCorrection = 0; % in meter || ensures that the loudspeakers are around the point (0 0 0), standard value is height of the bigger loudspeaker in the horizontal plane
opts=ita_parse_arguments(opts, varargin);
% X Y Z (openGL)
pos = itaCoordinates(zeros(12,3));
pos.r= 2.28;
pos.phi_deg=[45 315 225 135 0 270 180 90 0 270 180 90];
pos.theta_deg=[88.5 88.5 88.5 88.5 60 60 60 60 118 118 118 118];
pos.r= [2.283 2.293 2.273 2.278 2.344 2.324 2.333 2.336 2.233 2.228 2.231 2.233];
pos.phi_deg=[45.317 313.757 225.547 134.557 0 270 180 90 0 270 180 90];
pos.theta_deg=[90 90 90 90 58.148 57.783 57.980 58.228 117.411 117.391 117.524 117.700];
if opts.virtualSpeaker
pos.cart = [pos.cart;...
......
This source diff could not be displayed because it is too large. You can view the blob instead.
%% itaVA simple example code for generic path renderer
itaVAq
va.reset();
va.addSearchPath( pwd );
va.add_search_path( pwd );
ita_write_wav( ita_demosound, 'ita_demosound.wav', 'overwrite' );
X = va.createAudiofileSignalSource( 'ita_demosound.wav' );
va.setAudiofileSignalSourcePlaybackAction( X, 'play' );
va.setAudiofileSignalSourceIsLooping( X, true );
S = va.createSoundSource( 'itaVA_Source' );
va.setSoundSourceSignalSource( S, X );
L = va.createListener( 'itaVA_Listener' );
va.setActiveListener( L );
X = va.create_signal_source_buffer_from_file( '$(DemoSound)' );
va.set_signal_source_buffer_playback_action( X, 'play' );
va.set_signal_source_buffer_looping( X, true );
S = va.create_sound_source( 'itaVA_Source' );
va.set_sound_source_signal_source( S, X );
L = va.create_sound_receiver( 'itaVA_Listener' );
va.set_active_sound_receiver( L );
mMods = va.enumerateModules;
mMods = va.get_rendering_modules();
modname = 'none';
for n = size( mMods, 1 )
if strcmp( 'PrototypeGenericPath', mMods(n).name( 1:size( 'PrototypeGenericPath', 2 ) ) )
modname = mMods(n).name;
break; % use first one found
end
if isstruct( mMods )
modname = mMods.id; % only one available
else
modname = mMods( 1 ).id; % use first
end
if strcmp( modname, 'none' )
......@@ -30,31 +28,26 @@ end
% How to get help
mStruct = struct;
mStruct.help = ''; % or true or anything
mRes = va.callModule( modname, mStruct );
mRes = va.get_rendering_module_parameters( modname, mStruct );
disp( mRes.help )
% How to get infos
mStruct = struct;
mStruct.info = ''; % or true or anything
mRes = va.callModule( modname, mStruct )
% How to update using a file with two channels (matching channels required)
a = ita_merge( ita_amplify( ita_generate_impulse, '-21dB' ), ita_amplify( ita_generate_impulse, '-12dB' ) );
ita_write_wav( a, 'unequal_dirac.wav', 'overwrite' );
mStruct = struct;
mStruct.verbose = ''; % Verbose output for testing only, costly ...
mStruct.listener = L;
mStruct.receiver = L;
mStruct.source = S;
mStruct.filepath = fullfile( pwd, 'unequal_dirac.wav' );
mRes = va.callModule( modname, mStruct )
va.set_rendering_module_parameters( modname, mStruct )
% How to update a path sending floating point data (separate channels possible)
b = ita_generate_impulse( 'fftDegree', 18 );
mStruct = struct;
mStruct.verbose = true; % ... remove line if verbosity not required anymore.
mStruct.listener = L;
mStruct.receiver = L;
mStruct.source = S;
mStruct.ch2 = b.timeData / 104; % here, only update channel 2
mRes = va.callModule( modname, mStruct ) % Currently under testing, use short IRs only
va.set_rendering_module_parameters( modname, mStruct ) % Currently under testing, use short IRs only
va.disconnect()
......@@ -10,37 +10,29 @@ va.connect( 'localhost' )
va.reset()
% Control output gain
va.setOutputGain( .25 )
va.set_output_gain( .25 )
% Add the current absolute folder path to VA application
va.addSearchPath( pwd );
va.add_search_path( pwd );
% Create a signal source and start playback
ita_write_wav( ita_demosound, 'ita_demosound.wav', 'overwrite' );
X = va.createAudiofileSignalSource( 'ita_demosound.wav' );
va.setAudiofileSignalSourcePlaybackAction( X, 'play' )
va.setAudiofileSignalSourceIsLooping( X, true );
X = va.create_signal_source_buffer_from_file( '$(DemoSound)' );
va.set_signal_source_buffer_playback_action( X, 'play' )
va.set_signal_source_buffer_looping( X, true );
% Create a virtual sound source and set a position
S = va.createSoundSource( 'itaVA_Source' );
va.setSoundSourcePosition( S, [0 1.7 -2] )
% Connect the signal source to the virtual sound source
va.setSoundSourceSignalSource( S, X )
S = va.create_sound_source( 'itaVA_Source' );
va.set_sound_source_position( S, [ 2 1.7 2 ] )
% Create a listener with a HRTF and position him
H = va.loadHRIRDataset( '$(DefaultHRIR)' );
L = va.createListener( 'itaVA_Listener', 'default', H );
va.setListenerPosition( L, [0 1.7 0] )
va.setListenerOrientationYPR( L, [0 0 0] ) % Default view is to -Z (OpenGL)
L = va.create_sound_receiver( 'itaVA_Listener' );
va.set_sound_receiver_position( L, [ 0 1.7 0 ] )
% Set the listener as the active one
va.setActiveListener( L )
H = va.create_directivity( '$(DefaultHRIR)' );
va.set_sound_receiver_directivity( L, H );
% Now close connection
va.disconnect()
% VA virtual scene is still active now ...
% Connect the signal source to the virtual sound source
va.set_sound_source_signal_source( S, X )
% Explore itaVA class ...
doc itaVA
% More information
disp( 'Type ''doc itaVA'' for more information.' )
......@@ -2,20 +2,17 @@
% This assumes you already have set up a virtual scene without listener
% Create itaVA and connect
va = itaVA( 'localhost' )
va = itaVA( 'localhost' );
% Create a listener
L = va.createListener( 'itaVA_Tracked_Listener' );
% Create a sound receiver
L = va.create_sound_receiver( 'itaVA_Tracked_Listener' );
% OptiTrack tracker conneection and listener updates
va.setTrackedListener( L ) % For virtual scene / rendering
va.setTrackedRealWorldListener( L ) % For CTC reproductions
va.connectTracker
pause( 12 ) % Observe how you can move the virtual listener in VAGUI
va.disconnectTracker
% OptiTrack tracker conneection and sound receiver updates
va.set_tracked_sound_receiver( L ) % For virtual scene / rendering
va.set_tracked_real_world_sound_receiver( L ) % For CTC reproductions
va.connect_tracker
pause( 12 ) % Observe how you can move the virtual sound receiver
va.disconnect_tracker
% Remove listener again
va.deleteListener( L )
% Now close connection
va.disconnect()
va.delete_sound_receiver( L )
......@@ -13,8 +13,8 @@ myhrir.pf
%% Exchange (variables prepared by itaVA_experimental_renderer_prepare)
mStruct = struct;
mStruct.listener = L;
mStruct.receiver = L;
mStruct.source = S;
mStruct.ch1 = double( myhrir.ch( 1 ).timeData )';
mStruct.ch2 = double( myhrir.ch( 2 ).timeData )';
mRes = va.callModule( mod_id, mStruct )
va.set_rendering_module_parameters( mod_id, mStruct )
......@@ -91,16 +91,16 @@ function connect_connect_va_Callback( hObject, ~, handles )
% hObject handle to connect_connect_va (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if handles.va.isConnected
if handles.va.get_connected
handles.va.disconnect;
end
handles.va.connect;
handles.va.reset;
gpg_renderer_list = [];
for n=1:numel( handles.va.getRenderingModules )
if strcmp( handles.va.getRenderingModules( n ).class, 'PrototypeGenericPath' )
gpg_renderer_list = [ gpg_renderer_list handles.va.getRenderingModules( n ) ];
for n=1:numel( handles.va.get_rendering_modules )
if strcmp( handles.va.get_rendering_modules( n ).class, 'PrototypeGenericPath' )
gpg_renderer_list = [ gpg_renderer_list handles.va.get_renderers( n ) ];
end
end
......@@ -118,7 +118,7 @@ disp( [ 'Using channel prototype generic path renderer with identifier: ' gpg_re
% Classic VA module call with input and output arguments
handles.module_id = [ gpg_renderer.class ':' gpg_renderer.id ];
in_args.info = true;
out_args = handles.va.callModule( handles.module_id, in_args );
out_args = handles.va.call_module( handles.module_id, in_args );
handles.module_channels = out_args.numchannels;
handles.module_filter_length_samples = out_args.irfilterlengthsamples;
disp( [ 'Your experimental renderer "' handles.module_id '" has ' num2str( handles.module_channels ) ' channels and an FIR filter length of ' num2str( out_args.irfilterlengthsamples ) ' samples' ] )
......@@ -224,26 +224,26 @@ filepath_list = handles.listbox_sourcesignals.UserData;
filepath_selected = filepath_list{ index_selected };
filename_selected = filename_list{ index_selected };
if handles.va.isConnected
if handles.va.get_connected
last_index = handles.listbox_sourcesignals_last_index;
if last_index == index_selected
% play/pause current
va_signal_id = handles.va.getSoundSourceSignalSource( handles.va_source_id );
va_signal_id = handles.va.get_sound_source_signal_source( handles.va_source_id );
assert( ~isempty( va_signal_id ) )
playstate = handles.va.getAudiofileSignalSourcePlaybackState( va_signal_id );
playstate = handles.va.get_signal_source_buffer_playback_state( va_signal_id );
if strcmpi( playstate, 'playing' )
handles.va.setAudiofileSignalSourcePlaybackAction( va_signal_id, 'pause' );
handles.va.set_signal_source_buffer_playback_action( va_signal_id, 'pause' );
else
handles.va.setAudiofileSignalSourcePlaybackAction( va_signal_id, 'play' );
handles.va.set_signal_source_buffer_playback_action( va_signal_id, 'play' );
end
else
% new selected, remove old?
if last_index ~= -1
va_signal_id = handles.va.getSoundSourceSignalSource( handles.va_source_id );
handles.va.setSoundSourceSignalSource( handles.va_source_id, '' );
handles.va.deleteSignalSource( va_signal_id );
va_signal_id = handles.va.get_sound_source_signal_source( handles.va_source_id );
handles.va.get_sound_source_signal_source( handles.va_source_id, '' );
handles.va.delete_si( va_signal_id );
end
% create new
......@@ -300,7 +300,7 @@ end
if ~isempty( stringlist )
handles.listbox_filters.String = stringlist;
else
if handles.va.isConnected
if handles.va.get_connected
warning( [ 'No itaAudio objects with matching ' handles.module_channels ' channels found in current workspace' ] )
else
%warning( [ 'No itaAudio objects found in current workspace' ] )
......
% Prepare an experimental renderer using PrototypeGEnericPath
itaVAq
va.addSearchPath( pwd );
va.add_search_path( pwd );
va.reset();
% Find first PGP renderer
for n=1:numel( va.getRenderingModules )
if strcmp( va.getRenderingModules( n ).class, 'PrototypeGenericPath' )
gpg_renderer = va.getRenderingModules( n );
break;
end
mMods = va.get_rendering_modules();
if isstruct( mMods )
gpg_renderer = mMods; % only one available
else
gpg_renderer = mMods( 1 ); % use first
end
if strcmp( gpg_renderer.id, 'none' )
disp( 'Could not find a generic path module, not activated in VA core configuration?' )
end
if ~exist( 'gpg_renderer', 'var' )
error( 'No prototype generic path renderer found, please add or enable in VA configuration.' )
else
......@@ -18,19 +24,21 @@ else
end
% Classic VA module call with input and output arguments
mod_id = [ gpg_renderer.class ':' gpg_renderer.id ];
mod_id = gpg_renderer.id;
in_args.info = true;
out_args = va.callModule( mod_id, in_args );
out_args = va.get_rendering_module_parameters( mod_id, in_args );
disp( [ 'Your experimental renderer has ' num2str( out_args.numchannels ) ' channels and an FIR filter length of ' num2str( out_args.irfilterlengthsamples ) ' samples' ] )
% Very simple scene with one path
L = va.createListener( 'itaVA_ExperimentalListener' );
L = va.create_sound_receiver( 'itaVA_ExperimentalListener' );
%va.setActiveListener( L );
S = va.createSoundSource( 'itaVA_ExperimentalListener' );
S = va.create_sound_source( 'itaVA_ExperimentalListener' );
% Create a signal source and start playback
ita_write_wav( ita_demosound, 'ita_demosound.wav', 'overwrite' );
X = va.createAudiofileSignalSource( 'ita_demosound.wav' );
va.setAudiofileSignalSourcePlaybackAction( X, 'play' )
va.setAudiofileSignalSourceIsLooping( X, true );
va.setSoundSourceSignalSource( S, X );
X = va.create_signal_source_buffer_from_file( 'ita_demosound.wav' );
va.set_signal_source_buffer_playback_action( X, 'play' )
va.set_signal_source_buffer_looping( X, true );
va.set_sound_source_signal_source( S, X );
disp( 'VA experimental renderer prepared.' )
......@@ -83,8 +83,9 @@ if ~isempty( current_va_server_dir )
for i = 1:numel( vs )
vss = vs{ 1, i };
if numel( vss ) > 6
if strcmpi( vss( 1:6 ), 'VACore' )
set( handles.edit_vaserver_version, 'String', strcat( vs( i ) ) )
if strcmpi( vss( 3:10 ), 'VAServer' )
server_version = vss( 15:end );
set( handles.edit_vaserver_version, 'String', strcat( server_version ) )
end
end
end
......
itaVAq;
va.reset;
va.setOutputGain( .25 );
va.addSearchPath( pwd );
ita_write_wav( ita_demosound, 'ita_demosound.wav', 'overwrite' );
X = va.createAudiofileSignalSource( 'ita_demosound.wav' );
va.setAudiofileSignalSourcePlaybackAction( X, 'play' )
va.setAudiofileSignalSourceIsLooping( X, true );
S = va.createSoundSource( 'itaVA_Source', 'all' );
va.setSoundSourcePosition( S, [ 0 1.7 -2 ] );
va.setSoundSourceSignalSource( S, X );
H = va.loadHRIRDataset( '$(DefaultHRIR)' );
L = va.createListener( 'itaVA_Listener', 'all', H );
va.setListenerPosition( L, [ 0 1.7 0 ] );
va.setActiveListener( L );
\ No newline at end of file
......@@ -2,4 +2,4 @@
va = itaVA( 'localhost' );
%% Also add current dir to VA search path
va.addSearchPath( pwd );
\ No newline at end of file
va.add_search_path( pwd );
\ No newline at end of file
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