MPTK Matlab API FAQ
FAQ overview
- What are the Matlab utilities for MPTK ?
- How to use MPTK with Matlab ?
- How to find help for the Matlab functionalities ?
- What about Mex files ?
- MPTK for Matlab creates a "??? Invalid MEX-file 'Path_to_MPTK\MPTK\matlab\getmptkinfo.mexw32'" under windows
What are the Matlab utilities for MPTK ?
Some Matlab utilities are bundled with the distribution to help loading and visualizing books under Matlab:
-
bookread.m: to load a binary book into Matlab;
-
bookplot.m: to plot a book in a spectrogram-like fashion;
-
bookover.m: to overlay a book plot on a STFT spectrogram.
-
dictread.m: under development. Don't use.
How to use MPTK with Matlab ?
In order to use the MPTK functionalities in Matlab, there is some Matlab script files (.m). This files are initially located in the /extra/matlab folder of the MPTK source tree, this functionalities are not automatically installed when building MPTK: you should copy the .m files manually to a location accessible to your MATLABPATH.
How to find help for the Matlab functionalities ?
Each of these functions is equipped with some help info, e.g. to get help about bookplot use:
>> help bookplot
under Matlab.
What about Mex files ?
MEX means MATLAB Executables. The MEX files are produced from a C compiler to improve the speed of MATLAB when executing a function. This kind of features for MPTK is actually under development.
There is a toolbox of MEX implementation of the matlab utilities included in MPTK developped as a contribution by Emmanuel Ravelli at LAM: Laboratoire d'Acoustique Musicale (UPMC (Paris 6), CNRS, Ministere de la culture)
At this time, only the functions bookread and bookwrite are implemented. This toolbox has been tested with the version 0.5.2 of MPTK. The following blocks are supported: gabor, harmonic, mdct, mclt, dirac.
MPTK for Matlab creates a "??? Invalid MEX-file 'Path_to_MPTK\MPTK\matlab\getmptkinfo.mexw32'" under windows
MPTK Matlab toolbox is a MEX implementation of the matlab utilities included in MPTK.
On all platforms, the utilities need an environment variable called MPTK_CONFIG_FILENAME to be set with the path
of the path.xml file located in the bin directory.
This file defines the path to the Atoms/Block plugin location. On Windows system in the case you have installed MPTK library and utilities in an non standard directory
(eg different of "C:/Program Files/MPTK") you have to modify the path inside of this file with the real installation path.
In order to set an environment variable on Linux like os:
-with Bash shell:
export MPTK_CONFIG_FILENAME="path_to_MPTK/bin/path.xml"
-with C-shell:
setenv MPTK_CONFIG_FILENAME "path_to_MPTK/bin/path.xml"
You can check if the environment variable is correctly set with:
echo $MPTK_CONFIG_FILENAME
On Mac OSX an other solution is to edit ~/.MacOSX/environment.plist to add a key-value pair MPTK_CONFIG_FILENAME="/Users/your-username/.mptk/path.xml"
In order to set environment variable on Windows like system:
Lauch a command line and use the SET command:
SET MPTK_CONFIG_FILENAME=path_to_MPTK/bin/path.xml
for example SET MPTK_CONFIG_FILENAME=C:/Program Files/MPTK/bin/path.xml
To check if the environment variable is correctly set you can use the ECHO command:
ECHO %MPTK_CONFIG_FILENAME%
And matlab search path variable has to be set with the mptk bin directory for allowing Matlab to use mptk.dll and other external lib (fftw...):
for instance "C:\Program Files\MPTK\bin" for Windows OS,
alternatively the PATH environment variable may be set with "C:\Program Files\MPTK\bin"
Lauch a command line and use the SET command:
for example SET PATH=C:\Program Files\MPTK\bin
To check if the environment variable is correctly set you can use the ECHO command:
ECHO %PATH%