Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Institute of Technical Acoustics (ITA)
VAMatlab
Commits
08ea2fa2
Commit
08ea2fa2
authored
Nov 29, 2016
by
Dipl.-Ing. Jonas Stienen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Testing getRenderer and getReproduction
parent
804aa8dd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
26 deletions
+40
-26
matlab/itaVA_build.m.proto
matlab/itaVA_build.m.proto
+2
-2
src/VAMatlabExecutable.cpp
src/VAMatlabExecutable.cpp
+38
-24
No files found.
matlab/itaVA_build.m.proto
View file @
08ea2fa2
...
...
@@ -22,9 +22,9 @@ if exist( 'VAMatlab', 'file' )
warning
(
'VAMatlab already found at location "%s", are you sure to build itaVA against this executable? Will proceed now.'
,
which
(
'VAMatlab'
)
)
else
%
Add
to
PATH
temporarily
and
attempt
to
move
lib
to
bin
dir
addpath
(
script_dir
,
bin
_dir
)
addpath
(
script_dir
,
deploy
_dir
)
[
s
]
=
movefile
(
fullfile
(
lib_dir
,
'VAMatlab*'
),
bin
_dir
);
[
s
]
=
movefile
(
fullfile
(
lib_dir
,
'VAMatlab*'
),
deploy
_dir
);
if
~
s
&&
~
exist
(
'VAMatlab'
,
'file'
)
error
(
'Could locate VAMatlab executable. Please make sure that it can be found.'
)
end
...
...
src/VAMatlabExecutable.cpp
View file @
08ea2fa2
...
...
@@ -132,12 +132,15 @@ ConnectionHandle GenerateConnectionHandle() {
}
// Get connection handle from Matlab arguments and validate it
ConnectionHandle
GetConnectionHandle
(
const
mxArray
*
pArray
,
bool
bAllowNullHandle
=
false
)
{
ConnectionHandle
GetConnectionHandle
(
const
mxArray
*
pArray
,
bool
bAllowNullHandle
=
false
)
{
// Strict typing! Make sure that the parameter has a valid type (scalar + handle datatype)
if
(
matlabIsScalar
(
pArray
)
&&
(
mxGetClassID
(
pArray
)
==
CONNECTIONHANDLE_CLASS_ID
))
{
if
(
matlabIsScalar
(
pArray
)
&&
(
mxGetClassID
(
pArray
)
==
CONNECTIONHANDLE_CLASS_ID
)
)
{
ConnectionHandle
hHandle
=
*
((
ConnectionHandle
*
)
mxGetData
(
pArray
));
if
((
hHandle
>=
0
)
&&
(
hHandle
<=
VAMATLAB_MAX_CONNECTIONS
))
{
if
(
g_vpConnections
[
hHandle
]
||
((
hHandle
==
0
)
&&
bAllowNullHandle
))
if
(
(
hHandle
>=
0
)
&&
(
hHandle
<=
VAMATLAB_MAX_CONNECTIONS
)
)
{
if
(
g_vpConnections
[
hHandle
]
||
(
(
hHandle
==
0
)
&&
bAllowNullHandle
)
)
return
hHandle
;
}
}
...
...
@@ -151,22 +154,25 @@ ConnectionHandle GetConnectionHandle(const mxArray *pArray, bool bAllowNullHandl
// USED FOR? Convenience baby! This saves some lines of code below ...
// NOTE: In this MEX we are always checking for the exact number of arguments
// Optional values are predefined in the Matlab facade class
void
vCheckInputArguments
(
int
nrhs
,
int
iRequiredNumArgs
)
{
if
(
nrhs
!=
iRequiredNumArgs
)
{
switch
(
iRequiredNumArgs
)
{
case
0
:
VA_EXCEPT1
(
"This function does not take any arguments"
);
case
1
:
VA_EXCEPT1
(
"This function takes exactly one argument"
);
case
2
:
VA_EXCEPT1
(
"This function takes exactly two arguments"
);
case
3
:
VA_EXCEPT1
(
"This function takes exactly three arguments"
);
case
4
:
VA_EXCEPT1
(
"This function takes exactly four arguments"
);
case
5
:
VA_EXCEPT1
(
"This function takes exactly five arguments"
);
case
6
:
VA_EXCEPT1
(
"This function takes exactly six arguments"
);
void
vCheckInputArguments
(
int
nrhs
,
int
iRequiredNumArgs
)
{
if
(
nrhs
!=
iRequiredNumArgs
)
{
switch
(
iRequiredNumArgs
)
{
case
0
:
VA_EXCEPT1
(
"This VAMatlab function does not take any arguments"
);
case
1
:
VA_EXCEPT1
(
"This VAMatlab function takes exactly one argument"
);
case
2
:
VA_EXCEPT1
(
"This VAMatlab function takes exactly two arguments"
);
case
3
:
VA_EXCEPT1
(
"This VAMatlab function takes exactly three arguments"
);
case
4
:
VA_EXCEPT1
(
"This VAMatlab function takes exactly four arguments"
);
case
5
:
VA_EXCEPT1
(
"This VAMatlab function takes exactly five arguments"
);
case
6
:
VA_EXCEPT1
(
"This VAMatlab function takes exactly six arguments"
);
// Do we need more?
default:
{
char
buf
[
64
];
sprintf_s
(
buf
,
64
,
"This function takes exactly %d arguments"
,
iRequiredNumArgs
);
VA_EXCEPT1
(
buf
);
sprintf_s
(
buf
,
64
,
"This
VAMatlab
function takes exactly %d arguments"
,
iRequiredNumArgs
);
VA_EXCEPT1
(
buf
);
}
}
}
...
...
@@ -3176,11 +3182,9 @@ void getRenderingModuleGain( int nlhs, mxArray *plhs[], int nrhs, const mxArray
REGISTER_PUBLIC_FUNCTION
(
getRenderingModules
,
"Get list of rendering modules"
,
""
);
DECLARE_FUNCTION_OPTIONAL_INARG
(
getRenderingModules
,
bFilterEnabled
,
"boolean-1x1"
,
"Filter activated (true)"
,
"1"
);
DECLARE_FUNCTION_OUTARG
(
getRenderingModules
,
renderers
,
"cell-array of struct-1x1"
,
"Renderer infos (names, descriptions, etc.)"
);
void
getRenderingModules
(
int
nlhs
,
mxArray
*
plhs
[],
int
nrhs
,
const
mxArray
*
prhs
[]
)
{
REQUIRE_INPUT_ARGS
(
0
);
bool
bFilterEnabled
=
true
;
if
(
nrhs
>
1
)
bFilterEnabled
=
matlabGetBoolScalar
(
prhs
[
1
],
"bFilterEnabled"
);
...
...
@@ -3191,8 +3195,9 @@ void getRenderingModules( int nlhs, mxArray *plhs[], int nrhs, const mxArray *pr
std
::
vector
<
CVAAudioRendererInfo
>
voRenderers
;
pConnection
->
pCoreInterface
->
GetRenderingModules
(
voRenderers
,
bFilterEnabled
);
const
size_t
nDims
=
int
(
voRenderers
.
size
()
);
const
int
nFields
=
2
;
const
int
nFields
=
4
;
const
char
*
ppszFieldNames
[]
=
{
"id"
,
"class"
,
"enabled"
,
"desc"
};
plhs
[
0
]
=
mxCreateStructArray
(
1
,
&
nDims
,
nFields
,
ppszFieldNames
);
...
...
@@ -3280,11 +3285,9 @@ void getReproductionModuleGain( int nlhs, mxArray *plhs[], int nrhs, const mxArr
REGISTER_PUBLIC_FUNCTION
(
getReproductionModules
,
"Get list of rendering modules"
,
""
);
DECLARE_FUNCTION_OPTIONAL_INARG
(
getReproductionModules
,
bFilterEnabled
,
"boolean-1x1"
,
"Filter activated (true)"
,
"1"
);
DECLARE_FUNCTION_OUTARG
(
getReproductionModules
,
reproductionmodules
,
"cell-array of struct-1x1"
,
"Reproduction module infos (names, descriptions, etc.)"
);
void
getReproductionModules
(
int
nlhs
,
mxArray
*
plhs
[],
int
nrhs
,
const
mxArray
*
prhs
[]
)
{
REQUIRE_INPUT_ARGS
(
0
);
bool
bFilterEnabled
=
true
;
if
(
nrhs
>
1
)
bFilterEnabled
=
matlabGetBoolScalar
(
prhs
[
1
],
"bFilterEnabled"
);
...
...
@@ -3295,8 +3298,19 @@ void getReproductionModules( int nlhs, mxArray *plhs[], int nrhs, const mxArray
std
::
vector
<
CVAAudioReproductionInfo
>
voReproductions
;
pConnection
->
pCoreInterface
->
GetReproductionModules
(
voReproductions
,
bFilterEnabled
);
size_t
nDims_
=
1
;
const
int
nFields_
=
4
;
const
char
*
ppszFieldNames_
[]
=
{
"id"
,
"class"
,
"enabled"
,
"desc"
};
plhs
[
0
]
=
mxCreateStructArray
(
1
,
&
nDims_
,
1
,
ppszFieldNames_
);
mxSetField
(
plhs
[
0
],
0
,
ppszFieldNames_
[
0
],
mxCreateString
(
"hooo1"
)
);
mxSetField
(
plhs
[
0
],
0
,
ppszFieldNames_
[
1
],
mxCreateString
(
"h2ooo"
)
);
mxSetField
(
plhs
[
0
],
0
,
ppszFieldNames_
[
2
],
mxCreateString
(
"ho3oo"
)
);
mxSetField
(
plhs
[
0
],
0
,
ppszFieldNames_
[
3
],
mxCreateString
(
"hoo4o"
)
);
return
;
const
size_t
nDims
=
int
(
voReproductions
.
size
()
);
const
int
nFields
=
2
;
const
int
nFields
=
4
;
const
char
*
ppszFieldNames
[]
=
{
"id"
,
"class"
,
"enabled"
,
"desc"
};
plhs
[
0
]
=
mxCreateStructArray
(
1
,
&
nDims
,
nFields
,
ppszFieldNames
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment