From ce49998b9e86a4470b82665afa0bd887a70a5379 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hauke=20Kr=C3=BCger?= Date: Wed, 14 Feb 2024 12:58:15 +0100 Subject: [PATCH] Minor modifications in lib --- .../jvx-m-host-1/m-files/matlab/jvxHost_off.m | 22 +++++++++- .../m-files/matlab/jvxHost_off_rc.m | 44 +++++++++++++++++++ .../+jvx_dsp_base/+tools/jvx_compare_wavs.m | 5 ++- 3 files changed, 69 insertions(+), 2 deletions(-) diff --git a/sources/jvxApplications/jvx-m-host-1/m-files/matlab/jvxHost_off.m b/sources/jvxApplications/jvx-m-host-1/m-files/matlab/jvxHost_off.m index 189e974d..5c0ef639 100644 --- a/sources/jvxApplications/jvx-m-host-1/m-files/matlab/jvxHost_off.m +++ b/sources/jvxApplications/jvx-m-host-1/m-files/matlab/jvxHost_off.m @@ -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; @@ -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 diff --git a/sources/jvxApplications/jvx-m-host-1/m-files/matlab/jvxHost_off_rc.m b/sources/jvxApplications/jvx-m-host-1/m-files/matlab/jvxHost_off_rc.m index 9ba7a3e8..fb9c60d5 100644 --- a/sources/jvxApplications/jvx-m-host-1/m-files/matlab/jvxHost_off_rc.m +++ b/sources/jvxApplications/jvx-m-host-1/m-files/matlab/jvxHost_off_rc.m @@ -137,6 +137,50 @@ res = false; errMsg = ['No entry point .']; 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 .']; + 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 .']; + end else res = false; errMsg = ['Remote call <' whattodo ' is not a valid entry point.']; diff --git a/sources/jvxLibraries/jvx-dsp-base-matlab/+jvx_dsp_base/+tools/jvx_compare_wavs.m b/sources/jvxLibraries/jvx-dsp-base-matlab/+jvx_dsp_base/+tools/jvx_compare_wavs.m index 96580189..3e8f5cca 100644 --- a/sources/jvxLibraries/jvx-dsp-base-matlab/+jvx_dsp_base/+tools/jvx_compare_wavs.m +++ b/sources/jvxLibraries/jvx-dsp-base-matlab/+jvx_dsp_base/+tools/jvx_compare_wavs.m @@ -1,5 +1,6 @@ function [passed] = jvx_compare_wavs(file1, file2, maxDeviation, plotit, ignoreDifferentSizes) - + +passed = false; if(nargin < 4) plotit = true; end @@ -50,6 +51,8 @@ if(plotit) figure; end + +passed = true; for(ind = 1:size(sig1, 1)) diff = sig1(ind,:) - sig2(ind,:);