Tips for editing and compiling Audapter C++ code

Use this if you need help getting started with editing Audapter in C++, or need help compiling it in Visual Studio.

To make changes to Audapter, you will need to edit its source code in C++ and recompile it into a .mex file which MATLAB can use at runtime. You may also need to edit corresponding .m files in MATLAB which feed info to Audapter. This article will primarily help you with compiling the code. Make sure you have the Audapter Manual handy (download link here) and have already glanced at Appendices 1 and 2.

Setup for Editing Audapter

  1. Download and install Visual Studio from Microsoft. (Not Visual Studio Code)
  2. Clone the blab-lab/audapter_mex Github repo to your machine. Make a new branch for your changes.
  3. When you open Visual Studio, you want to open the Audapter "solution" file, Audapter.sln. This pulls in both "projects"--Audapter and audioIO.

You're now free to code.

Tips for Compiling

You've made your code changes and you want to test them. Great! If you're using the blab-lab/audapter_mex repo mentioned above, the solution file will already have some configuration done for you. You should check all of these settings regardless.

  1. You will be making changes to the Audapter and audioIO projects. To open up the project settings, right click the Project name in the Solution Explorer (the left pane by default), then click Properties at the very bottom. All changes mentioned below will need to be completed in both the Audapter and the audioIO project.
  2. In Configuration Properties >> General, the Windows SDK Version should be 10.0 (latest version installed). If you are using a version of Visual Studio other than Visual Studio 2019, you may need to change the Platform Toolset to your current version. (You may need to test this.)
  3. In C/C++ >> General, notice that Additional Include Directories is a list of semicolon-delimited file paths. Also note that one of those paths references the MATLAB install directory. Take a moment and find the MATLAB install directory on your own computer. The default for Windows is C:\Program Files\MATLAB\[MATLAB version name]\extern\include. You will need to replace the MATLAB path referenced in Additional Include Directories with the MATLAB path for your computer. If your version of MATLAB is 32 bit, you may need to end this section with \extern\include\win32\, if that directory exists. For 64 bit, it should end \extern\include\.
  4. Still in C/C++ >> General, in Additional Include Directories, make sure $(SolutionDir)\SibShift; is included in the list.
  5. In C/C++ >> Code Generation, Runtime Library should be Multi-threaded Debug (/MTd).
  6. In Linker >> General, Additional Library Directories should reference your MATLAB path. It should end in \extern\lib\win64\microsoft\.
  7. In Linker >> Input, Additional Dependencies should be the same as below. Ignore where the Audapter manual says you need a type of libmax.mat. It is a typo of libmat.lib, which is included in the list below. libmx.lib;libmex.lib;libmat.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies).
  8. Either close Matlab entirely, or run clear Audapter in Matlab before trying to compile.

You should now be ready to compile. You can do this from the top menu Build >> Rebuild Solution. When you compile, as the manual says, "a number of warning messages are expected." The final few lines in the output window should summarize if both projects successfully compiled. Also listed in the output window will be the directory containing your new .mex file.

Keywordsaudapter, mex, sln, solution, matlab   Doc ID107666
OwnerChris N.GroupSMNG Lab Manual
Created2020-12-08 11:00:56Updated2024-03-13 10:01:45
SitesSpeech Motor Neuroscience Group
Feedback  0   0