VAMatlabExecutable_debug.m 3.41 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 37 38 39 40 41
renderers = VAMatlabD( 'getRenderingModules', conn, false );
disp( renderers )
reproductions = VAMatlabD( 'getReproductionModules', conn, false );
disp( reproductions )

%% Tests
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

L = VAMatlabD( 'createListener', conn, 'itaVA_Tracked_Listener', 'default', -1 );

VAMatlabD( 'SetTrackedListener', conn,L )
%VAMatlabD( 'SetTrackedSource', conn,L )
VAMatlabD( 'SetRigidBodyIndex', conn, 1 )
VAMatlabD( 'SetRigidBodyTranslation', conn, [ 0 0 3 ] )
q = ita_quaternion( [ pi/sqrt(2) 0 1/sqrt(2) 0 ] ) 
q = q.normalize

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

VAMatlabD( 'connectTracker', conn )
b = VAMatlabD( 'IsTrackerConnected', conn )
VAMatlabD( 'disconnectTracker', conn )


%VAMatlabD( 'connectTracker', conn, '137.226.61.85', '137.226.61.85' )



modinfos = VAMatlabD( 'enumerateModules', conn );


istruct = struct;
istruct.info = '';
ostruct = VAMatlabD( 'callModule', conn, 'GenericPath:MyGenericRenderer', istruct )

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

ostruct = VAMatlabD( 'callModule', conn, 'GenericPath:MyGenericRenderer', istruct );

%VAMatlabD( 'callModule', conn, 'hprep', { 'print', 'help' } ) % will print on std::cout @ real VACore, i.e. VAGUI or Console
%lhs_arg = VAMatlabD( 'callModule', conn, 'hprep', { 'get', 'gain' } )
%VAMatlabD( 'callModule', conn, 'hprep', { 'set', 'gain', 'value', lhs_arg / 3 } )
%lhs_arg_new = VAMatlabD( 'callModule', conn, 'hprep', { 'get', 'gain' } )

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