itaVA_example_generic_path_renderer.m 1.97 KB
Newer Older
1
%% itaVA simple example code for generic path renderer
2
itaVAq
3
va.reset();
4 5 6 7
va.addSearchPath( pwd );

ita_write_wav( ita_demosound, 'ita_demosound.wav', 'overwrite' );
X = va.createAudiofileSignalSource( 'ita_demosound.wav' );
8 9 10 11 12 13 14 15 16 17 18
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 );

mMods = va.enumerateModules;

modname = 'none';
for n = size( mMods, 1 )
19
    if strcmp( 'PrototypeGenericPath', mMods(n).name( 1:size( 'PrototypeGenericPath', 2 ) ) )
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
        modname = mMods(n).name;
        break; % use first one found
    end
end

if strcmp( modname, 'none' )
    disp( 'Could not find a generic path module, not activated in VA core configuration?' )
end


% How to get help
mStruct = struct;
mStruct.help = ''; % or true or anything
mRes = va.callModule( 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.source = S;
mStruct.filepath = fullfile( pwd, 'unequal_dirac.wav' );
mRes = va.callModule( modname, mStruct )

% How to update a path sending floating point data (separate channels possible)
52
b = ita_generate_impulse( 'fftDegree', 18 );
53 54 55 56
mStruct = struct;
mStruct.verbose = true; % ... remove line if verbosity not required anymore.
mStruct.listener = L;
mStruct.source = S;
57
mStruct.ch2 = b.timeData / 104; % here, only update channel 2
58 59 60
mRes = va.callModule( modname, mStruct ) % Currently under testing, use short IRs only

va.disconnect()