Adding VA experimental scripts (for live audio with real-time filter exchange from Matlab)

parent 31772a35
%% itaVA simple example code for generic path renderer
va = itaVA( 'localhost' )
itaVAq
va.reset();
X = va.createAudiofileSignalSource( 'Audiofiles/Bauer.wav' );
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' );
......@@ -47,12 +49,12 @@ mStruct.filepath = fullfile( pwd, 'unequal_dirac.wav' );
mRes = va.callModule( modname, mStruct )
% How to update a path sending floating point data (separate channels possible)
b = ita_generate_impulse( 'fftDegree', 12 );
b = ita_generate_impulse( 'fftDegree', 18 );
mStruct = struct;
mStruct.verbose = true; % ... remove line if verbosity not required anymore.
mStruct.listener = L;
mStruct.source = S;
mStruct.ch2 = b.timeData / 4; % here, only update channel 2
mStruct.ch2 = b.timeData / 104; % here, only update channel 2
mRes = va.callModule( modname, mStruct ) % Currently under testing, use short IRs only
va.disconnect()
%% Starts and prepares VA for experimental setup and exchanges binaural filters from an itaHRTF class
itaVA_experimental_start_server
itaVA_experimental_renderer_prepare
%% Load
[ hrir_filename, hrir_base_path ] = uigetfile( { '*.daff', 'OpenDAFF IR file' }, 'Select an HRIR or HRTF input file' );
myhrirset = itaHRTF( 'daff', fullfile( hrir_base_path, hrir_filename ) );
myhrir_coords = itaCoordinates( 1 );
myhrir_coords.elevation = 40;
myhrir_coords.azimuth = 13;
myhrir = myhrirset.findnearestHRTF( myhrir_coords );
myhrir.pf
%% Exchange (variables prepared by itaVA_experimental_renderer_prepare)
mStruct = struct;
mStruct.listener = L;
mStruct.source = S;
mStruct.ch1 = myhrir.ch( 1 ).timeData;
mStruct.ch2 = myhrir.ch( 2 ).timeData;
mRes = va.callModule( mod_id, mStruct )
% Prepare an experimental renderer using PrototypeGEnericPath
itaVAq
va.addSearchPath( 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
end
if ~exist( 'gpg_renderer', 'var' )
error( 'No prototype generic path renderer found, please add or enable in VA configuration.' )
else
disp( [ 'Using channel prototype generic path renderer with identifier: ' gpg_renderer.id ] )
end
% Classic VA module call with input and output arguments
mod_id = [ gpg_renderer.class ':' gpg_renderer.id ];
in_args.info = true;
out_args = va.callModule( 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' );
%va.setActiveListener( L );
S = va.createSoundSource( '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 );
if ~exist( 'VAServer.exe', 'file' )
itaVA_setup
end
[ basepath, basename, ext ]= fileparts( which( 'VAServer.exe') );
[ va_basepath, ~, ~ ]= fileparts( basepath );
conf_path1 = fullfile( 'conf', 'VACore.ini' );
conf_path2 = fullfile( pwd, 'MyVACore.ini' ); % also absolute path possible
va_args = [ 'localhost:12340 ' conf_path1 ];
os_call = [ which( 'VAServer.exe') ' ' va_args ' &' ];
return_to_dir = pwd;
cd( va_basepath );
[ status, cmdout ] = system( os_call );
cd( return_to_dir );
% After connect, also add the folder with your data like this
% va.add
\ No newline at end of file
if ~exist( 'VAServer.exe', 'file' )
itaVA_setup
end
[ basepath, basename, ext ]= fileparts( which( 'VAServer.exe') );
[ va_basepath, ~, ~ ]= fileparts( basepath );
conf_path = fullfile( va_basepath, 'conf', 'VACore.experimental.ini' );
va_args = [ 'localhost:12340 ' conf_path ];
os_call = [ which( 'VAServer.exe') ' ' va_args ' &' ];
return_to_dir = pwd;
cd( va_basepath );
[ status, cmdout ] = system( os_call );
cd( return_to_dir );
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