Playrec Installation Notes (日本語バージョン)


Overview

This page introduces the latest installation method for playrec, a multi-channel audio input/output library for MATLAB.
#As of July 16, 2025
#Test environment: Windows 11, Intel 64-bit, MATLAB 2023a, Visual Studio 2019
#                  macOS 15.5, AppleSilicon 64-bit, MATLAB 2024a, Xcode 15
#This page is translated by chatGPT.

Background

Playrec development was discontinued around 2015, and since then, it has not been updated to support Win64 or recent changes in PortAudio/Windows SDK/macOS specifications.
As a result, it is no longer possible to install it using only the official information, and even using online resources as a guide, installation is extremely difficult and time-consuming. Therefore, I have compiled the relevant information on this site.
Currently, MATLAB's Audio Toolbox supports functions nearly equivalent to those of Playrec (via audioPlayerRecorder), so if you are an academic or individual MATLAB user, I recommend using Audio Toolbox instead.
However, since Audio Toolbox can be expensive for commercial licenses, we hope this site will be of help to those facing similar difficulties, as the author has.

Installation Procedure (Common to All OS)

First, prepare by referring to the latest official information on Playrec.
The latest files can be downloaded from GitHub.
Regardless of your OS, you will also need to download the latest version of PortAudio (v19.7.0 stable release).

Next, you will need to make some minor modifications to the '.m' scripts of Playrec.
For 64-bit Windows support, refer to Professor Yoichi Haneda’s website, and for adapting to changes in the PortAudio specifications, refer to the thread by alastairhmoore on GitHub.

playrec-master/m_files/compile_playrec_func.m
    line 42-56: remove 'src/os/mac_osx'
Original pa_include_dirs = {'src/common',... 'src/hostapi/alsa',... 'src/hostapi/asihpi',... 'src/hostapi/asio',... 'src/hostapi/coreaudio',... 'src/hostapi/dsound',... 'src/hostapi/jack',... 'src/hostapi/oss',... 'src/hostapi/wasapi',... 'src/hostapi/wdmks',... 'src/hostapi/wmme',... 'src/os/mac_osx',... 'src/os/unix',... 'src/os/win',... 'include'}; %just include all possibilities! Modified pa_include_dirs = {'src/common',... 'src/hostapi/alsa',... 'src/hostapi/asihpi',... 'src/hostapi/asio',... 'src/hostapi/coreaudio',... 'src/hostapi/dsound',... 'src/hostapi/jack',... 'src/hostapi/oss',... 'src/hostapi/wasapi',... 'src/hostapi/wdmks',... 'src/hostapi/wmme',... 'src/os/unix',... 'src/os/win',... 'include'}; %just include all possibilities! line 78-80: revise 'src/os/mac_osx/pa_mac_hostapis.c' to 'src/os/unix/pa_unix_hostapis.c'
Original pa_os_specific_files = [pa_os_specific_files, ... {'src/os/mac_osx/pa_mac_hostapis.c', ... 'src/os/unix/pa_unix_util.c'}]; Modified pa_os_specific_files = [pa_os_specific_files, ... {'src/os/unix_osx/pa_unix_hostapis.c', ... 'src/os/unix/pa_unix_util.c'}]; (Optional, as ASIO for macOS has not been tested) line 84-93: modifications for ASIO support on macOS
Original api_include_dirs = [api_include_dirs, ... resolve_paths(asio_path,... {'common',... 'host',... 'host/mac'})]; api_files = [api_files,... resolve_paths(asio_path,... {'host/asiodrivers.cpp',... 'host/mac/asioshlib.cpp',... 'host/mac/codefragements.cpp'})]; Modified api_include_dirs = [api_include_dirs, ... resolve_paths(asio_path,... {'common',... 'host'})]; api_files = [api_files,... resolve_paths(asio_path,... {'host/asiodrivers.cpp'})]; line 104: modifications for CoreAudio support on macOS
Original compiler_flags = [compiler_flags, {'PA_USE_COREAUDIO'}]; Modified compiler_flags = [compiler_flags, {'PA_USE_COREAUDIO=1',... '__MACOSX_CORE__'}]; line 114: modifications for WIN64
Original compiler_flags = [compiler_flags, {'WIN32'}]; Modified if strcmp(computer, 'PCWIN64') compiler_flags = [compiler_flags, {'WIN64'}]; else %strcmp(computer, 'PCWIN32') compiler_flags = [compiler_flags, {'WIN32'}]; end
playrec-master/m_files/build_mex.m
    line 94: modifications for WIN64
Original build_args = {build_args{:}, ['LIB#', cell2mat(lib_dirs(n)), ';$LIB']}; Modified if strcmp(computer, 'PCWIN64') build_args = {build_args{:}, ['-L', cell2mat(lib_dirs(n))]}; else %strcmp(computer, 'PCWIN32') build_args = {build_args{:}, ['LIB#', cell2mat(lib_dirs(n)), ';$LIB']}; end
The other modifications described on Professor Haneda’s website have already been updated in the latest version on GitHub, so no further changes are necessary.

Installation Procedure (Windows)

For Windows, you will need to download a C++ compiler (the author used Visual Studio 2019) and the Windows SDK (the author used version 10.0.26100.0).
If you plan to use ASIO, please prepare the ASIO SDK in advance.
DirectSound was supported in the past, but the author was unable to install it with the current SDK.

Run 'playrec-master/compile_playrec.m' and follow the instructions — installation should be possible.
#As mentioned earlier, please uncheck the DirectSound option.
#If you place the PortAudio and ASIO folders into 'playrec-master/lib', the script will automatically detect their paths during execution.
#The Platform SDK Directory should be 'C:\Program Files (x86)\Windows Kits\10'.
#If 'playrec.mexw64' is generated in the folder, the installation is most likely successful.

Installation Procedure (macOS)

Installation on macOS is quite challenging — the author felt discouraged many times — but if you are using only CoreAudio, it should be possible by following the steps below.

As same as for Windows, run 'playrec-master/compile_playrec.m' and follow the on-screen instructions.
#Uncheck the ASIO option, as enabling it will cause the script to use the C++ compiler (Xcode Clang++), which will fail to compile PortAudio.
#Also uncheck Jack Audio Connection Kit, as it will result in a file-not-found error during the process.
#Be sure to check both the Debug and Verbose options.

During the process, an error will occur and compilation will stop, but if around ten '.o' files (e.g., 'mex_dll_core.o') have been generated in the folder, proceed to the next step.
At this point, scroll back through the command window log. Copy the two lines right before the error message.
The exact content may vary depending on your environment, but you will likely see something like the following in the log. ([USERNAME] represents your login username.)
    Command A
    
        /Applications/MATLAB_R2024a.app/bin/maca64/usResourceCompiler3 --manifest-add 
        /private/var/folders/4t/wrqf688j0tldphxlqcl8nggc0000gn/T/mex_20302766153414_11620//mw_mex_tempmex_manifest.json 
        --bundle-name mexVersioning --out-file 
        /private/var/folders/4t/wrqf688j0tldphxlqcl8nggc0000gn/T/mex_20302766153414_11620//mw_mex_tempmex_bundle.zip
    
    Command B
    
        /usr/bin/xcrun -sdk macosx15.5 clang -Wl,-twolevel_namespace  -arch arm64 -mmacosx-version-min=11.0 -Wl,
        -syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk 
        -bundle  -Wl,-exported_symbols_list,"/Applications/MATLAB_R2024a.app/extern/lib/maca64/mexFunction.map" 
        mex_dll_core.o pa_dll_playrec.o pa_allocation.o pa_converters.o pa_cpuload.o pa_debugprint.o pa_dither.o 
        pa_front.o pa_process.o pa_ringbuffer.o pa_hostapi_skeleton.o pa_stream.o pa_trace.o pa_mac_core.o pa_mac_core_utilities.o 
        pa_mac_core_blocking.o pa_unix_hostapis.o pa_unix_util.o c_mexapi_version.o  -g -Wl,-exported_symbols_list,
        "/Applications/MATLAB_R2024a.app/extern/lib/maca64/c_exportsmexfileversion.map"  -L"/Applications/MATLAB_R2024a.app/bin/maca64" 
        -lmx -lmex -lmat -lc++ -o /Users/[USERNAME]/Documents/MATLAB/playrec-master/playrec.mexmaca64 -Wl,
        -sectcreate,__TEXT,us_resources,/private/var/folders/4t/wrqf688j0tldphxlqcl8nggc0000gn/T/mex_20282859537241_11620//mw_mex_tempmex_bundle.zip 
    
Paste these commands into a text editor for editing.

First, in Command B, add the following content just before 'mex_dll_core.o' on line 3 (there is only one line in the command window through).
    
        -framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework CoreFoundation -framework CoreServices
    
Next, modify the '/private/var/...'' path found on line 2 and line 4 of Command A, as well as at the end of Command B, to a suitable folder that you have access to. For example:
    
        /Users/[USERNAME]/Downloads/mw_mex_tempmex_manifest.json 
    
    
        /Users/[USERNAME]/Downloads/mw_mex_tempmex_bundle.zip 
    
#This '.zip' file will be temporarily generated. Please delete it manually after the installation is complete.
After editing, the commands should look like this:
    Command A
    
        /Applications/MATLAB_R2024a.app/bin/maca64/usResourceCompiler3 --manifest-add 
        /Users/[USERNAME]/Downloads/mw_mex_tempmex_manifest.json  
        --bundle-name mexVersioning --out-file 
        /Users/[USERNAME]/Downloads/mw_mex_tempmex_bundle.zip 
    
    Command B
    
        /usr/bin/xcrun -sdk macosx15.5 clang -Wl,-twolevel_namespace  -arch arm64 -mmacosx-version-min=11.0 -Wl,
        -syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk 
        -bundle  -Wl,-exported_symbols_list,"/Applications/MATLAB_R2024a.app/extern/lib/maca64/mexFunction.map" 
        -framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework CoreFoundation -framework CoreServices 
        mex_dll_core.o pa_dll_playrec.o pa_allocation.o pa_converters.o pa_cpuload.o pa_debugprint.o pa_dither.o 
        pa_front.o pa_process.o pa_ringbuffer.o pa_hostapi_skeleton.o pa_stream.o pa_trace.o pa_mac_core.o pa_mac_core_utilities.o 
        pa_mac_core_blocking.o pa_unix_hostapis.o pa_unix_util.o c_mexapi_version.o  -g -Wl,-exported_symbols_list,
        "/Applications/MATLAB_R2024a.app/extern/lib/maca64/c_exportsmexfileversion.map"  -L"/Applications/MATLAB_R2024a.app/bin/maca64" 
        -lmx -lmex -lmat -lc++ -o /Users/[USERNAME]/Documents/MATLAB/playrec2025/playrec.mexmaca64 -Wl,
        -sectcreate,__TEXT,us_resources,/Users/[USERNAME]/Downloads/mw_mex_tempmex_bundle.zip
    
Open terminal in mac, and navigate to the folder where the '.o' files were generated.
    
        cd /Users/[USERNAME]/Documents/MATLAB/playrec-master
    
Run the edited Command A in the terminal. An error will appear, just ignore it.
At this point, the 'mw_mex_tempemx_bundle.zip' file should have been generated.
Then, run Command B in the terminal.
Once completed, if 'playrec.mexmaca64' has been created in the folder containing the '.o' files, the installation is complete.
#You can safely delete the '.o' files after the process is finished.