Adapting new api

parent 4e334ad3
......@@ -139,9 +139,9 @@ classdef itaVA < handle
this.disconnect
end
function [connected] = is_connected(this)
function [connected] = get_connected(this)
% Returns if a connection to a server is established
connected = VAMatlab('is_connected', this.handle);
connected = VAMatlab('get_connected', this.handle);
end
function connect(this, addressstring)
......
%% 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()
......@@ -24,9 +24,6 @@ va.set_signal_source_buffer_looping( X, true );
S = va.create_sound_source( 'itaVA_Source' );
va.set_sound_source_position( S, [ 2 1.7 2 ] )
% Connect the signal source to the virtual sound source
va.set_sound_source_signal_source( S, X )
% Create a listener with a HRTF and position him
L = va.create_sound_receiver( 'itaVA_Listener' );
va.set_sound_receiver_position( L, [ 0 1.7 0 ] )
......@@ -34,5 +31,8 @@ va.set_sound_receiver_position( L, [ 0 1.7 0 ] )
H = va.create_directivity( '$(DefaultHRIR)' );
va.set_sound_receiver_directivity( L, H );
% Connect the signal source to the virtual sound source
va.set_sound_source_signal_source( S, X )
% More information
disp( 'Type ''doc itaVA'' for more information.' )
......@@ -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.' )
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