From 1bfb650a12cada297d9a0ad39505473c73800d04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hauke=20Kr=C3=BCger?= Date: Mon, 12 Feb 2024 20:07:12 +0100 Subject: [PATCH] 1) Added enums for the numerical limit of options in C functions 2) Checked for type when converting config struct in Matlab integration 3) Catch exception in CjvxMexCalls calls that are interrupted by debugger quit in Matlab 4) Added Mex module for fft framework --- sources/jvxApplications/mex/jvxFFTFwk/.jvxprj | 0 .../mex/jvxFFTFwk/cmake/CMakeLists.txt | 46 +++ .../mex/jvxFFTFwk/src/CjvxFFTFwk.cpp | 226 +++++++++++++ .../mex/jvxFFTFwk/src/CjvxFFTFwk.h | 33 ++ .../mex/jvxFFTFwk/target/entryMex.cpp | 305 ++++++++++++++++++ .../include/CjvxMatlabToCConverter.h | 17 +- .../include/jvx_fft_tools/jvx_fft_tools.h | 3 +- .../include/jvx_windows/jvx_windows.h | 3 +- .../include/CjvxMexCallsProfileTpl.h | 31 +- 9 files changed, 646 insertions(+), 18 deletions(-) create mode 100644 sources/jvxApplications/mex/jvxFFTFwk/.jvxprj create mode 100644 sources/jvxApplications/mex/jvxFFTFwk/cmake/CMakeLists.txt create mode 100644 sources/jvxApplications/mex/jvxFFTFwk/src/CjvxFFTFwk.cpp create mode 100644 sources/jvxApplications/mex/jvxFFTFwk/src/CjvxFFTFwk.h create mode 100644 sources/jvxApplications/mex/jvxFFTFwk/target/entryMex.cpp diff --git a/sources/jvxApplications/mex/jvxFFTFwk/.jvxprj b/sources/jvxApplications/mex/jvxFFTFwk/.jvxprj new file mode 100644 index 00000000..e69de29b diff --git a/sources/jvxApplications/mex/jvxFFTFwk/cmake/CMakeLists.txt b/sources/jvxApplications/mex/jvxFFTFwk/cmake/CMakeLists.txt new file mode 100644 index 00000000..dba7bb94 --- /dev/null +++ b/sources/jvxApplications/mex/jvxFFTFwk/cmake/CMakeLists.txt @@ -0,0 +1,46 @@ +set(PROJECT_NAME jvxFFTFwk) +include(${JVX_CMAKE_DIR}/common_local_mex_head.cmake) + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR}/../src + ${JVX_BASE_ROOT}/sources/jvxLibraries/ayf-mex-connect/include + ${JVX_SUBPRODUCT_LIBS_INCLUDE_PATH}/jvx-dsp/include + ) + +set(LOCAL_SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/../target/entryMex.cpp + + ${CMAKE_CURRENT_SOURCE_DIR}/../src/CjvxFFTFwk.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/../src/CjvxFFTFwk.h + ) + + set(LOCAL_LIBS "jvx-dsp_static") + +set(INSTALL_COMMON_MEX_TARGET_NAME "${PROJECT_NAME}") + +if(JVX_USE_PART_MATLAB) + set(JVX_TARGET_NAME "${PROJECT_NAME}_m") + set(LOCAL_MAT_LIBS ayf-mex-connect_m_static) + set(INSTALL_TARGET_NAME_MATLAB ${JVX_TARGET_NAME}) + set(BUILD_MEX_MATLAB TRUE) + set(BUILD_MEX_OCTAVE FALSE) + set(JVX_RENAME_RELEASE "${PROJECT_NAME}") + include(${JVX_CMAKE_DIR}/common_local_mex_foot.cmake) +endif() + +if(JVX_USE_PART_OCTAVE) + + set(JVX_TARGET_NAME "${PROJECT_NAME}_o") + set(LOCAL_OCT_LIBS ayf-mex-connect_o_static) + set(INSTALL_TARGET_NAME_OCTAVE ${JVX_TARGET_NAME}) + set(BUILD_MEX_OCTAVE TRUE) + set(BUILD_MEX_MATLAB FALSE) + set(JVX_RENAME_RELEASE "${PROJECT_NAME}") + include(${JVX_CMAKE_DIR}/common_local_mex_foot.cmake) + if(JVX_USE_PART_MATLAB) + add_dependencies(${PROJECT_NAME}_o ${PROJECT_NAME}_m) + endif() +endif() + + + diff --git a/sources/jvxApplications/mex/jvxFFTFwk/src/CjvxFFTFwk.cpp b/sources/jvxApplications/mex/jvxFFTFwk/src/CjvxFFTFwk.cpp new file mode 100644 index 00000000..4cfea5a9 --- /dev/null +++ b/sources/jvxApplications/mex/jvxFFTFwk/src/CjvxFFTFwk.cpp @@ -0,0 +1,226 @@ +#include "CjvxFFTFwk.h" + +#include "CjvxMatlabToCConverter.h" + +CjvxFFTFwk::CjvxFFTFwk() +{ +} + +jvxErrorType +CjvxFFTFwk::init_fft_fwk(const mxArray* arrCfg) +{ + if (core_inst != nullptr) + { + return JVX_ERROR_WRONG_STATE; + } + + JVX_SAFE_ALLOCATE_OBJECT_CPP_Z(core_inst, jvx_fft_signal_processing); + jvx_fft_signal_processing_initCfg(core_inst); + + if (mxIsStruct(arrCfg)) + { + mexPrintf("fft signal processing is configured by sub-struct .\n"); + const mxArray* arrFft = CjvxMatlabToCConverter::jvx_mex_lookup_strfield(arrCfg, "fft_processor"); + const mxArray* val = nullptr; + + jvxErrorType res = JVX_NO_ERROR; + + jvxSize fftSize = 0; + + if (arrFft) + { + std::string token; + mexPrintf("--> Found struct field , reading single values for fwk configuration.\n"); + + /* + * -- Struct cfg -- + * jvxFftTools_fwkType fftFrameworkType; -> selectFftFramework + * jvxSize ifcf_length_max; -> ifcf_length_max + * jvxSize ir_length_max; -> ir_length_max + + * jvxFFTSize fftType; + * jvxSize hopsize; -> hopsize + * jvxSize buffersize; -> buffersize + * + * jvxCBool allocateProcessingFft; + * jvxCBool allocateAnalysisFft; + * jvxCBool allocateWeightCorrection; + * + * jvx_windowType desiredWindowTypeWeightCorrection; + * + * -- Struct async -- + * jvxCBool auto_aliasing; -> auto_anti_aliasing + * jvxCBool employ_antialias_weight_processing; -> antialias + * jvxSize ifcf_length; -> ifcf_length + * + * -- Struct sync -- + * jvxInt32 percentAnalysisWinFftSize; -> percentAnalysisWinFftSize + * jvx_windowType wintype; -> wintype + * + * + * -> FFTSize + * -> hopsize + * -> buffersize + * + */ + JVX_MEX_READ_SINGLE_FROM_STRUCT(res, "fftsize", arrFft, fftSize); + if (res != JVX_NO_ERROR) mexPrintf("--> Failed to read entry for in struct.\n"); + + JVX_MEX_READ_SINGLE_FROM_STRUCT(res, "ifcf_length_max", arrFft, core_inst->cfg.ifcf_length_max); + if (res != JVX_NO_ERROR) mexPrintf("--> Failed to read entry for in struct.\n"); + + JVX_MEX_READ_SINGLE_FROM_STRUCT(res, "ir_length_max", arrFft, core_inst->cfg.ir_length_max); + if (res != JVX_NO_ERROR) mexPrintf("--> Failed to read entry for in struct.\n"); + + JVX_MEX_READ_SINGLE_FROM_STRUCT(res, "hopsize", arrFft, core_inst->cfg.hopsize); + if (res != JVX_NO_ERROR) mexPrintf("--> Failed to read entry for in struct.\n"); + + JVX_MEX_READ_SINGLE_FROM_STRUCT(res, "buffersize", arrFft, core_inst->cfg.buffersize); + if (res != JVX_NO_ERROR) mexPrintf("--> Failed to read entry for in struct.\n"); + + JVX_MEX_READ_SELECTION_FROM_STRUCT(res, "selectFftFramework", arrFft, core_inst->cfg.fftFrameworkType, JVX_FFT_TOOLS_FWK_LIMIT, jvxFftTools_fwkType); + if (res != JVX_NO_ERROR) mexPrintf("--> Failed to read entry for in struct.\n"); + + // ASYNC + + JVX_MEX_READ_SINGLE_FROM_STRUCT(res, "auto_anti_aliasing", arrFft, core_inst->async.auto_aliasing); + if (res != JVX_NO_ERROR) mexPrintf("--> Failed to read entry for in struct.\n"); + + JVX_MEX_READ_SINGLE_FROM_STRUCT(res, "antialias", arrFft, core_inst->async.employ_antialias_weight_processing); + if (res != JVX_NO_ERROR) mexPrintf("--> Failed to read entry for in struct.\n"); + + JVX_MEX_READ_SINGLE_FROM_STRUCT(res, "ifcf_length", arrFft, core_inst->async.ifcf_length); + if (res != JVX_NO_ERROR) mexPrintf("--> Failed to read entry for in struct.\n"); + + // ASYNC + + JVX_MEX_READ_SINGLE_FROM_STRUCT(res, "percentAnalysisWinFftSize", arrFft, core_inst->sync.percentAnalysisWinFftSize); + if (res != JVX_NO_ERROR) mexPrintf("--> Failed to read entry for in struct.\n"); + + JVX_MEX_READ_SELECTION_FROM_STRUCT(res, "wintype", arrFft, core_inst->sync.wintype, JVX_WINDOW_LIMIT, jvx_windowType); + if (res != JVX_NO_ERROR) mexPrintf("--> Failed to read entry for in struct.\n"); + + /* + JVX_MEX_READ_SELECTION_FROM_STRUCT(res, "fftType/jvxSelection_value", arrFwk, fftType, jvxFFTSize::JVX_FFT_TOOLS_FFT_SIZE_8192, jvxFFTSize); + + /* + JVX_MEX_READ_SINGLE_FROM_STRUCT(res, "FFTSize", arrFwk, R); + if (res != JVX_NO_ERROR) mexPrintf("--> Failed to read entry for in struct.\n"); + + JVX_MEX_READ_SELECTION_FROM_STRUCT(res, "fftType/jvxSelection_value", arrFwk, fftType, jvxFFTSize::JVX_FFT_TOOLS_FFT_SIZE_8192, jvxFFTSize); + if (res != JVX_NO_ERROR) mexPrintf("--> Failed to read entry for in struct.\n"); + */ + } + + // ================================================================================================================ + jvxSize loc_fftsize; + jvx_get_nearest_size_fft(&core_inst->cfg.fftType, fftSize, JVX_FFT_ROUND_NEAREST, &loc_fftsize); + + jvx_fft_signal_processing_updateCfg(&core_inst->derived, &core_inst->cfg); + assert(core_inst->derived.fftsize == loc_fftsize); + + // FFT Size must be multiples of 2 + if ( + ((core_inst->derived.fftsize % 2) == 1) || + (core_inst->derived.fftsize < core_inst->cfg.buffersize) || + (core_inst->derived.fftsize < core_inst->cfg.hopsize)) + + { + mexPrintf("--> Failed to initialize fft processor handle - invalid configuration.\n"); + } + + + // ================================================================================= + // INITIALIZATION + // ================================================================================= + + + // Allocate global data for FFT usage (reuse twiddle factors in Mac cases) + jvxErrorType resL = jvx_create_fft_ifft_global(&global_hdl, (jvxFFTSize)core_inst->cfg.fftType); + assert(resL == JVX_DSP_NO_ERROR); + + /* + -> updateCfg will be called in prepare!!! + jvx_fft_signal_processing_updateCfg(&H->runtime.noise_signal_proc.cfg, &H->runtime.noise_signal_proc.cfg); + jvx_fft_signal_processing_updateCfg(&H->runtime.announce_signal_proc.cfg); + */ + + // Configuration for noise signal + core_inst->cfg.allocateAnalysisFft = true; + core_inst->cfg.allocateWeightCorrection = true; + core_inst->cfg.allocateProcessingFft = true; + + M2P1 = core_inst->derived.fftsize / 2 + 1; + hopsize = core_inst->cfg.hopsize; + + jvx_fft_signal_processing_prepare(core_inst, global_hdl); + + } + + return JVX_NO_ERROR; +} + +jvxErrorType +CjvxFFTFwk::term_fft_fwk() +{ + if (core_inst == nullptr) + { + return JVX_ERROR_WRONG_STATE; + } + + jvx_fft_signal_processing_postprocess(core_inst); + JVX_SAFE_DELETE_OBJECT(core_inst); + + return JVX_NO_ERROR; +} + +jvxErrorType +CjvxFFTFwk::process_fft_fwk_input(jvxData* input, jvxDataCplx* outputBufProc, jvxDataCplx* outputBufAna) +{ + int i; + + if (core_inst == nullptr) + { + return JVX_ERROR_WRONG_STATE; + } + + jvx_fft_signal_processing_input(core_inst, input, core_inst->cfg.hopsize); + + if (outputBufProc) + { + memcpy(outputBufProc, core_inst->derived.outFftBuffer, sizeof(jvxDataCplx) * M2P1); + } + + if (outputBufAna) + { + if (core_inst->derived.outFftBufferAnalysis) + { + memcpy(outputBufAna, core_inst->derived.outFftBufferAnalysis, sizeof(jvxDataCplx) * M2P1); + } + else + { + memcpy(outputBufAna, core_inst->derived.outFftBuffer, sizeof(jvxDataCplx) * M2P1); + } + } + + return JVX_NO_ERROR; +} + +jvxErrorType +CjvxFFTFwk::process_fft_fwk_output(jvxDataCplx* input, jvxData* weights, jvxData* output) +{ + int i; + if (core_inst == nullptr) + { + return JVX_ERROR_WRONG_STATE; + } + + if (input) + { + memcpy(core_inst->derived.outFftBuffer, input, sizeof(jvxDataCplx) * M2P1); + } + + jvx_fft_signal_processing_output(core_inst, output, weights, core_inst->cfg.hopsize); + return JVX_NO_ERROR; +} + diff --git a/sources/jvxApplications/mex/jvxFFTFwk/src/CjvxFFTFwk.h b/sources/jvxApplications/mex/jvxFFTFwk/src/CjvxFFTFwk.h new file mode 100644 index 00000000..57bcb936 --- /dev/null +++ b/sources/jvxApplications/mex/jvxFFTFwk/src/CjvxFFTFwk.h @@ -0,0 +1,33 @@ +#ifndef __CJVXNECORE_H__ +#define __CJVXNECORE_H__ + +#include "jvx.h" + +#include "localMexIncludes.h" + +extern "C" +{ +#include "jvx_fft_processing/jvx_fft_processing.h" +} + +class CjvxFFTFwk +{ +protected: + + jvx_fft_signal_processing* core_inst = nullptr; + jvxFFTGlobal* global_hdl = nullptr; + +public: + + CjvxFFTFwk(); + jvxErrorType init_fft_fwk(const mxArray* arrCfg); + jvxErrorType term_fft_fwk(); + jvxErrorType process_fft_fwk_input(jvxData* input, jvxDataCplx* outputBufProc, jvxDataCplx* outputBufAna); + jvxErrorType process_fft_fwk_output(jvxDataCplx* input, jvxData* weights, jvxData* output); + + jvxSize M2P1 = 0; + jvxSize hopsize = 0; + +}; + +#endif diff --git a/sources/jvxApplications/mex/jvxFFTFwk/target/entryMex.cpp b/sources/jvxApplications/mex/jvxFFTFwk/target/entryMex.cpp new file mode 100644 index 00000000..f918d32e --- /dev/null +++ b/sources/jvxApplications/mex/jvxFFTFwk/target/entryMex.cpp @@ -0,0 +1,305 @@ +#include "jvx.h" + +#include "localMexIncludes.h" +#include "CjvxCToMatlabConverter.h" +#include "CjvxMatlabToCConverter.h" + +#include "CjvxFFTFwk.h" + +jvxSize uniqueId = 1; +std::map instances; + +void mexFunction(int nlhs, mxArray* plhs[], + int nrhs, const mxArray* prhs[]) +{ + jvxSize i; + jvxErrorType res = JVX_NO_ERROR; + int retValId = -1; + SZ_MAT_TYPE ndim = 2; + SZ_MAT_TYPE dims[2] = { 1, 1 }; + const mxArray* in = NULL; + mxArray* pplhs0 = NULL; + mxArray* pplhs1 = NULL; + + jvxBool paramsOk = false; + if ((nlhs >= 1) && (nlhs <= 4)) + { + res = JVX_ERROR_INVALID_ARGUMENT; + if (nrhs >= 1) + { + if (mxIsChar(prhs[0])) + { + std::string cmd = CjvxMatlabToCConverter::jvx_mex_2_cstring(prhs[0]); + if (cmd == "init") + { + if (nrhs == 2) + { + // Initialize noise estimator + paramsOk = true; + in = prhs[1]; + CjvxFFTFwk* fftInst = nullptr; + JVX_DSP_SAFE_ALLOCATE_OBJECT(fftInst, CjvxFFTFwk); + res = fftInst->init_fft_fwk(in); + if (res == JVX_NO_ERROR) + { + retValId = uniqueId++; + instances[retValId] = fftInst; + } + else + { + JVX_DSP_SAFE_DELETE_OBJECT(fftInst); + } + } + } + else if (cmd == "term") + { + if (nrhs == 2) + { + jvxSize idx = JVX_SIZE_UNSELECTED; + res = CjvxMatlabToCConverter::mexArgument2Index(idx, prhs, 1, nrhs); + if (res == JVX_NO_ERROR) + { + auto elm = instances.find(idx); + if (elm != instances.end()) + { + // Terminate noise estimator + paramsOk = true; + retValId = idx; + res = elm->second->term_fft_fwk(); + JVX_SAFE_DELETE_OBJECT(elm->second); + instances.erase(elm); + } + else + { + std::string txt = "Passed instance id <"; + txt += jvx_size2String(idx); + txt += "> is not a valid handle reference."; + mexWarnMsgTxt(txt.c_str()); + } + } + else + { + std::string txt = "Invalid type to pass instance id for processing instance."; + mexWarnMsgTxt(txt.c_str()); + } + } + } + else if (cmd == "input") + { + if (nrhs == 3) + { + jvxSize idx = JVX_SIZE_UNSELECTED; + res = CjvxMatlabToCConverter::mexArgument2Index(idx, prhs, 1, nrhs); + if (res == JVX_NO_ERROR) + { + auto elm = instances.find(idx); + if (elm != instances.end()) + { + if (mxIsData(prhs[2]) && !mxIsComplex(prhs[2])) + { + int M = mxGetM(prhs[2]); + int N = mxGetN(prhs[2]); + if ((M == 1) && (N == elm->second->hopsize)) + { + paramsOk = true; + retValId = idx; + jvxData* inBuf = (jvxData*)mxGetData(prhs[2]); + jvxSize szIn = N; + jvxSize szOut = elm->second->M2P1; + jvxDataCplx* outBufProc = nullptr; + jvxDataCplx* outBufAna = nullptr; + + // Allocate output buffer + SZ_MAT_TYPE ndim = 2; + SZ_MAT_TYPE dims[2] = { 1, 1 }; + dims[1] = (int)szOut; + if (nlhs > 0) + { + pplhs0 = mxCreateNumericArray(ndim, dims, JVX_DATA_MEX_CONVERT, mxCOMPLEX); + outBufProc = (jvxDataCplx*)mxGetData(pplhs0); + } + if (nlhs > 1) + { + pplhs1 = mxCreateNumericArray(ndim, dims, JVX_DATA_MEX_CONVERT, mxCOMPLEX); + outBufAna = (jvxDataCplx*)mxGetData(pplhs1); + } + + res = elm->second->process_fft_fwk_input(inBuf, outBufProc, outBufAna); + } + else + { + std::string txt = "Input data is of wrong dimension, it should be <1x"; + txt += jvx_size2String(N); + txt += ">."; + mexWarnMsgTxt(txt.c_str()); + res = JVX_ERROR_INVALID_FORMAT; + } + } + else + { + std::string txt = "Input data is of wrong format, it should be <"; + txt += jvxDataFormat_txt(JVX_DATAFORMAT_DATA); + txt += "-real>."; + mexWarnMsgTxt(txt.c_str()); + res = JVX_ERROR_INVALID_FORMAT; + } + + } + else + { + std::string txt = "Passed instance id <"; + txt += jvx_size2String(idx); + txt += "> is not a valid handle reference."; + mexWarnMsgTxt(txt.c_str()); + } + } + else + { + std::string txt = "Invalid type to pass instance id for processing instance."; + mexWarnMsgTxt(txt.c_str()); + } + } + else + { + std::string txt = "Invalid number of input arguments for sub-command ."; + mexWarnMsgTxt(txt.c_str()); + } + } + else if (cmd == "output") + { + if (nrhs == 4) + { + jvxSize idx = JVX_SIZE_UNSELECTED; + res = CjvxMatlabToCConverter::mexArgument2Index(idx, prhs, 1, nrhs); + if (res == JVX_NO_ERROR) + { + auto elm = instances.find(idx); + if (elm != instances.end()) + { + if (mxIsData(prhs[2]) && mxIsComplex(prhs[2])) + { + int M = mxGetM(prhs[2]); + int N = mxGetN(prhs[2]); + if ((M == 1) && (N == elm->second->M2P1)) + { + jvxDataCplx* inBuf = (jvxDataCplx*)mxGetData(prhs[2]); + jvxSize szIn = N; + + if ( + (nrhs > 3) && + (mxGetM(prhs[3]) == M) && + (mxGetN(prhs[3]) == N) && + mxIsData(prhs[3]) && + !mxIsComplex(prhs[3])) + { + jvxData* inWeights = (jvxData*)mxGetData(prhs[3]); + + if (nlhs > 0) + { + paramsOk = true; + retValId = idx; + jvxSize szOut = elm->second->hopsize; + jvxData* outBuf = nullptr; + + // Allocate output buffer + SZ_MAT_TYPE ndim = 2; + SZ_MAT_TYPE dims[2] = { 1, 1 }; + dims[1] = (int)szOut; + + pplhs0 = mxCreateNumericArray(ndim, dims, JVX_DATA_MEX_CONVERT, mxREAL); + outBuf = (jvxData*)mxGetData(pplhs0); + + res = elm->second->process_fft_fwk_output(inBuf, inWeights, outBuf); + } + else + { + std::string txt = "No space for output data, there should be 1 output argument."; + mexWarnMsgTxt(txt.c_str()); + res = JVX_ERROR_INVALID_ARGUMENT; + } + } + else + { + std::string txt = "Weight input data is of wrong format, it should be a real vector of dimension <1x"; + txt += jvx_size2String(N); + txt += "> and type <"; + txt += jvxDataFormat_txt(JVX_DATAFORMAT_DATA); + txt += ">"; + mexWarnMsgTxt(txt.c_str()); + res = JVX_ERROR_INVALID_FORMAT; + } + } + else + { + std::string txt = "Signal data is of wrong dimension, it should be <1x"; + txt += jvx_size2String(N); + txt += ">."; + mexWarnMsgTxt(txt.c_str()); + res = JVX_ERROR_INVALID_FORMAT; + } + } + else + { + std::string txt = "Signal data is of wrong format, it should be <"; + txt += jvxDataFormat_txt(JVX_DATAFORMAT_DATA); + txt += "-real>."; + mexWarnMsgTxt(txt.c_str()); + res = JVX_ERROR_INVALID_FORMAT; + } + } + else + { + std::string txt = "Passed instance id <"; + txt += jvx_size2String(idx); + txt += "> is not a valid handle reference."; + mexWarnMsgTxt(txt.c_str()); + } + } + else + { + std::string txt = "Invalid type to pass instance id for processing instance."; + mexWarnMsgTxt(txt.c_str()); + } + } + else + { + std::string txt = "Invalid number of input arguments for sub-command ."; + mexWarnMsgTxt(txt.c_str()); + } + } + else + { + mexWarnMsgTxt("Invalid command token, expecting to initialize and to terminate noise estimator."); + } + } // if(mxIsChar) + } + if (pplhs0 == nullptr) + { + CjvxCToMatlabConverter::mexReturnInt32(pplhs0, retValId); + } + plhs[0] = pplhs0; + if (pplhs1) + { + plhs[1] = pplhs1; + } + } + + if (!paramsOk) + { + mexWarnMsgTxt( + "Invalid call to mex function to run noise estimation.\n" + "The module must be initialized first and can then be involved frame by frame.\n" + "The following call options are available:\n" + "Option 1 -- init: Input Argument #1: text , followed by a configuration struct. This function returns a reference handle (id).\n" + "Option 2 -- term: Input Argument #1: text , followed by the previously obtained reference id. Function returns the passed reference handle (id).\n" + "Option 3 -- input: Input Argument #1: text , input argument #2: reference handle (id), input argument #3: A <1 x HOPSIZE> array holding input signal buffer. Function returns 1 output array to hold complex vector of fft data for processing and 1 output array to hold complex vector of fft data for analysis.\n" + "Option 4 -- output: Input Argument #1: text , , input argument #2: reference handle (id), input argument #3: A <1 x M2P1> array holding complex fft vector, input argument #4: A <1 x M2P1> array holding real weight vector. Function returns 1 output array to hold real vector of (processed) output signal.\n"); + } + + return; +} + + + + + diff --git a/sources/jvxLibraries/ayf-mex-connect/include/CjvxMatlabToCConverter.h b/sources/jvxLibraries/ayf-mex-connect/include/CjvxMatlabToCConverter.h index a6071d32..87fea4a8 100644 --- a/sources/jvxLibraries/ayf-mex-connect/include/CjvxMatlabToCConverter.h +++ b/sources/jvxLibraries/ayf-mex-connect/include/CjvxMatlabToCConverter.h @@ -26,8 +26,15 @@ res = JVX_ERROR_ELEMENT_NOT_FOUND; \ if (val = CjvxMatlabToCConverter::jvx_mex_read_single_reference(curPtr, token)) \ { \ - value.assign(CjvxMatlabToCConverter::jvx_mex_2_cstring(val)); \ - res = JVX_NO_ERROR; \ + if(mxIsChar(val)) \ + { \ + value.assign(CjvxMatlabToCConverter::jvx_mex_2_cstring(val)); \ + res = JVX_NO_ERROR; \ + } \ + else \ + { \ + res = JVX_ERROR_INVALID_SETTING; \ + } \ } \ } @@ -36,6 +43,12 @@ jvxBool err = false; \ jvxApiString astr; \ JVX_MEX_READ_STRING_FROM_STRUCT(res, token, curPtr, astr); \ + if(res != JVX_NO_ERROR) \ + { \ + std::string tokenP = token; \ + tokenP += "/jvxSelection_value"; \ + JVX_MEX_READ_STRING_FROM_STRUCT(res, tokenP, curPtr, astr); \ + } \ if(res == JVX_NO_ERROR) \ { \ jvxBitField bf = jvx_string2BitField(astr.std_str(), err); \ diff --git a/sources/jvxLibraries/jvx-dsp-base/include/jvx_fft_tools/jvx_fft_tools.h b/sources/jvxLibraries/jvx-dsp-base/include/jvx_fft_tools/jvx_fft_tools.h index 7e327dbd..b165a2a0 100644 --- a/sources/jvxLibraries/jvx-dsp-base/include/jvx_fft_tools/jvx_fft_tools.h +++ b/sources/jvxLibraries/jvx-dsp-base/include/jvx_fft_tools/jvx_fft_tools.h @@ -83,7 +83,8 @@ typedef enum JVX_FFT_TOOLS_FWK_OLS, JVX_FFT_TOOLS_FWK_OLS_CF, JVX_FFT_TOOLS_FWK_OLS_IFCF, - JVX_FFT_TOOLS_FWK_ANALYSIS + JVX_FFT_TOOLS_FWK_ANALYSIS, + JVX_FFT_TOOLS_FWK_LIMIT } jvxFftTools_fwkType; /** diff --git a/sources/jvxLibraries/jvx-dsp-base/include/jvx_windows/jvx_windows.h b/sources/jvxLibraries/jvx-dsp-base/include/jvx_windows/jvx_windows.h index d690e3f5..832cec14 100644 --- a/sources/jvxLibraries/jvx-dsp-base/include/jvx_windows/jvx_windows.h +++ b/sources/jvxLibraries/jvx-dsp-base/include/jvx_windows/jvx_windows.h @@ -46,7 +46,8 @@ enum JVX_WINDOW_HALF_LINEAR = 8, JVX_WINDOW_HALF_HAMMING = 9, JVX_WINDOW_HAMMING_ASYM = 10, - JVX_WINDOW_KAISER = 11 + JVX_WINDOW_KAISER = 11, + JVX_WINDOW_LIMIT }; typedef jvxInt16 jvx_windowType; diff --git a/sources/jvxLibraries/jvxLexternalCall/include/CjvxMexCallsProfileTpl.h b/sources/jvxLibraries/jvxLexternalCall/include/CjvxMexCallsProfileTpl.h index bc9f9437..146b9815 100644 --- a/sources/jvxLibraries/jvxLexternalCall/include/CjvxMexCallsProfileTpl.h +++ b/sources/jvxLibraries/jvxLexternalCall/include/CjvxMexCallsProfileTpl.h @@ -51,25 +51,28 @@ class CjvxMexCallsProfileTpl : public CjvxMexCallsTpl, public CjvxMexCallsPro // ============================================================================================= if (res == JVX_NO_ERROR) { - // Matlab initialization is complete here - CjvxMexCalls::prepare_connect_icon_leave(_common_set_icon.theData_in, &_common_set_ocon.theData_out); - // Here, run the c code initialization! res = local_prepare_connect_icon(JVX_CONNECTION_FEEDBACK_CALL(fdb)); + } + + if (res == JVX_NO_ERROR) + { + // Matlab initialization is complete here + res = CjvxMexCalls::prepare_connect_icon_leave(_common_set_icon.theData_in, &_common_set_ocon.theData_out); + } - if (res == JVX_NO_ERROR) - { - JVX_SAFE_ALLOCATE_2DFIELD_CPP_Z(dbgFldCopyInputs, - jvxData, - _common_set_icon.theData_in->con_params.number_channels, - _common_set_icon.theData_in->con_params.buffersize); + if (res == JVX_NO_ERROR) + { + JVX_SAFE_ALLOCATE_2DFIELD_CPP_Z(dbgFldCopyInputs, + jvxData, + _common_set_icon.theData_in->con_params.number_channels, + _common_set_icon.theData_in->con_params.buffersize); - if (config.matlab_debug_enabled && config.matlab_profiling_enabled) - { - res = local_allocate_profiling(); - } + if (config.matlab_debug_enabled && config.matlab_profiling_enabled) + { + res = local_allocate_profiling(); } - } + } if (res != JVX_NO_ERROR) {