Skip to content

Commit

Permalink
Minor modifications in lib
Browse files Browse the repository at this point in the history
  • Loading branch information
hkhauke committed Feb 14, 2024
1 parent 24677fe commit ce49998
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ function jvxHost_off_OpeningFcn(hObject, eventdata, handles, varargin)
jvxHost_off_remote.jvx_set_buffersize = @jvxHost_off_remote_set_buffersize;
jvxHost_off_remote.jvx_set_engage_matlab = @jvxHost_off_remote_set_engage_matlab;
jvxHost_off_remote.jvx_mesgq_immediate = @jvxHost_off_remote_trigger_mesgq_immediately;
jvxHost_off_remote.jvx_export_signal = @jvxHost_off_remote_export_signal_wav;

% Set callback for all host system calls
global jvx_host_call_global;
Expand Down Expand Up @@ -1917,5 +1918,24 @@ function pushbutton14_Callback(hObject, eventdata, handles)
[handles] = jvxHost_off_remote_offline_set_engage_matlab_core(jvxHost_off_remote.hObject, handles, doEngageI16);
guidata(jvxHost_off_remote.hObject, handles);


function [res] = jvxHost_off_remote_export_signal_wav(exportOutput, exportId, fname)
res = true;
global jvxHost_off_remote;
handles = guidata(jvxHost_off_remote.hObject);

if(exportOutput)
sigs = handles.jvx_struct.data.output.data;
rate = handles.jvx_struct.data.output.rate;
else
sigs = handles.jvx_struct.data.input.data;
rate = handles.jvx_struct.data.input.rate;
end

if(exportId <= size(sigs,1))
oneBuf = sigs(exportId,:);
audiowrite(fname, oneBuf, rate);
disp(['Wrote file <' fname '>.']);
else
disp('Export Id is outside range of channels in data.');
end

Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,50 @@
res = false;
errMsg = ['No entry point <jvx_input_var>.'];
end

elseif(strcmp(whattodo, 'jvx_export_output_signal'))

if(isfield(jvxHost_off_remote, 'jvx_export_signal'))
try
exportId = 1;
fname = 'data_exported.wav';
if(size(varargin,2) > 1)
exportId = varargin{2};
end
if(size(varargin,2) > 2)
fname = varargin{3};
end
res = jvxHost_off_remote.jvx_export_signal(true, exportId, fname);
catch ME
res = false;
errMsg = ME.message;
end
else
res = false;
errMsg = ['No entry point <jvx_export_signal>.'];
end

elseif(strcmp(whattodo, 'jvx_export_input_signal'))

if(isfield(jvxHost_off_remote, 'jvx_export_signal'))
try
exportId = 1;
fname = 'data_exported.wav';
if(size(varargin,2) > 1)
exportId = varargin{2};
end
if(size(varargin,2) > 2)
fname = varargin{3};
end
res = jvxHost_off_remote.jvx_export_signal(false, exportId, fname);
catch ME
res = false;
errMsg = ME.message;
end
else
res = false;
errMsg = ['No entry point <jvx_export_signal>.'];
end
else
res = false;
errMsg = ['Remote call <' whattodo ' is not a valid entry point.'];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
function [passed] = jvx_compare_wavs(file1, file2, maxDeviation, plotit, ignoreDifferentSizes)


passed = false;
if(nargin < 4)
plotit = true;
end
Expand Down Expand Up @@ -50,6 +51,8 @@
if(plotit)
figure;
end

passed = true;
for(ind = 1:size(sig1, 1))

diff = sig1(ind,:) - sig2(ind,:);
Expand Down

0 comments on commit ce49998

Please sign in to comment.