VAMatlabExecutable_debug.m 3.52 KB
Newer Older
1
% This debug script is for debugging the VA-to-Matlab connection
2 3 4 5 6 7
% without the use of the facade class "itaVA"
% To use MSVS for debugging the MEX library, in VS select "Debugging >
% Append to process" ... then select the MATLAB.exe process and start to
% execute commands in Matlab that are calling functions of the MEX file


8 9 10
%% Pathes to required libs & dlls (cumbersome, but necessary)
vam_path = 'D:\Users\stienen\dev\VA\VAMatlab';
build_dir = 'build_win32-x64.vc12';
11

12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
vanet_dir = 'D:\Users\stienen\dev\VA';
vista_dir = 'D:\Users\stienen\dev\ViSTA';
natnet_libs = 'X:\VR\dev\ExternalLibs\NatNetSDK\NatNetSDK-2.7\lib\x64';

addpath( fullfile( vam_path, build_dir, 'lib' ) ) % VAMatlabD
addpath( fullfile( vanet_dir, build_dir, 'lib' ) ) % VABaseD, VANetD
addpath( fullfile( vista_dir, build_dir, 'lib' ) ) % VistaBaseD, VistaAspectsD, VistaInterProcCommD
addpath( fullfile( natnet_libs ) ) % NatNetSDK (OptiTrack)

copy_dlls = true;
if( copy_dlls ) % Be careful with this option
    dest = fullfile( vam_path, build_dir, 'lib' );
    copyfile( which( 'VABaseD.dll' ), dest )
    copyfile( which( 'VANetD.dll' ), dest )
    copyfile( which( 'VistaBaseD.dll' ), dest )
    copyfile( which( 'VistaAspectsD.dll' ), dest )
    copyfile( which( 'VistaInterProcCommD.dll' ), dest )
    copyfile( which( 'NatNetLib.dll' ), dest )
    warning( 'DLLs have been copied, make sure to use the corresponding versions during debugging.' )
end


%% Connection
35
conn = VAMatlabD( 'connect', 'localhost:12340' );
36
renderers = VAMatlabD( 'get_rendering_modules', conn, false );
37
disp( renderers )
38
reproductions = VAMatlabD( 'get_reproduction_modules', conn, false );
39 40 41
disp( reproductions )

%% Tests
42

43
L = VAMatlabD( 'create_sound_receiver', conn, 'itaVA_Tracked_Listener', 'default', -1 );
44

45 46 47 48
VAMatlabD( 'set_tracked_sound_receiver', conn,L )
%VAMatlabD( 'set_tracked_sound_source', conn,L )
VAMatlabD( 'set_tracked_sound_receiver_head_rigid_body_index', conn, 1 )
VAMatlabD( 'set_tracked_sound_receiver_head_rigid_body_translation', conn, [ 0 0 3 ] )
49 50 51 52 53
q = ita_quaternion( [ pi/sqrt(2) 0 1/sqrt(2) 0 ] ) 
q = q.normalize

VAMatlabD( 'SetRigidBodyRotation', conn, q.e(:)' )

54 55 56
VAMatlabD( 'connect_trracker', conn )
b = VAMatlabD( 'get_tracker_connected', conn )
VAMatlabD( 'disconnect_tracker', conn )
57 58


59
%VAMatlabD( 'connect_tracker', conn, '137.226.61.85', '137.226.61.85' )
60 61 62



63
modinfos = VAMatlabD( 'get_modules', conn );
64 65 66 67


istruct = struct;
istruct.info = '';
68
ostruct = VAMatlabD( 'call_mdule', conn, 'PrototypeGenericPath:MyGenericRenderer', istruct )
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91

istruct = struct();
istruct.command = 'UPDATE';
istruct.ListenerID = 1;
istruct.SourceID = 1;

if false 
    istruct.type = 'FilePath';
    istruct.FilePath = '$(VADataDir)/HPEQ/HD600_all_eq_128_stereo.wav';
end

if true
    istruct.type = 'DATA';
    istruct.IRDataCh1 = [ 0.9 zeros( 1, 2048 ) ];
    istruct.IRDataCh2 = [ 0.1 zeros( 1, 2048 ) ];
end

if false
    sweep = ita_time_crop( ita_generate_sweep, [1 1350], 'samples' ) * 0.03;
    istruct.type = class( sweep );
    istruct.itaAudio = ita_merge( sweep, sweep );
end

92
ostruct = VAMatlabD( 'call_module', conn, 'PrototypeGenericPath:MyGenericRenderer', istruct );
93

94 95 96 97
%VAMatlabD( 'call_module', conn, 'hprep', { 'print', 'help' } ) % will print on std::cout @ real VACore, i.e. VAGUI or Console
%lhs_arg = VAMatlabD( 'call_module', conn, 'hprep', { 'get', 'gain' } )
%VAMatlabD( 'call_module', conn, 'hprep', { 'set', 'gain', 'value', lhs_arg / 3 } )
%lhs_arg_new = VAMatlabD( 'call_module', conn, 'hprep', { 'get', 'gain' } )
98 99 100

VAMatlabD( 'disconnect', conn )
clear VAMatlabD % release to allow write access for msvc