This is not guaranteed to work. I have not tried it since a few weeks after I wrote this blog post. I get emails now and again asking to help debug compilation errors, but I don't know how to help. This was already a very hacky fix, and it's highly dependent on a lot of software versions. I'm not as deep in MATLAB as I used to be, so I don't know exactly what would need to be done to adapt this guide to newer versions.

If you've taken a look at my projects page, you might have seen the Audio Player/Crossover MATLAB project I did for a Digital Signal Processing course. Last night, I was sitting around thinking about what a shame it is that the project doesn't work on Mac simply because of the necessity of msound.

I emailed a guy I knew had once been working on a Mac version of msound called macsound. I wanted to know if he had succeeded or found a replacement. Unfortunately, he had not had time to complete macsound, but he pointed me toward playrec. playrec claims that it can be run on any machine, thanks to Portaudio, but I was skeptical. Sure enough, I tried the instructions listed on the original website, but they did not work. Furthermore, the forum there has been dead since 2011, and the author won't respond to inquiries.

After a lot of work, though (about 4 hours or so), I got a fully-compiled, functioning version of playrec. Here is a step-by-step of how you can do it.

Disclaimer: My machine is a 2013 MacBook Air. It runs OS X 10.8 in 64-bit. I cannot guarantee this process will work for any other machines, but you should give it a try.

Bolded and italicized steps may not be best practice, but they work in this particular case.

  1. Start by visiting
  2. Download and extract playrec to your working MATLAB directory.
  3. Do not download the latest stable PortAudio release like the playrec website suggests. Download the latest nightly tarball. Extract it into the 'lib' folder of the playrec directory.
  4. Run 'mex -setup' in the MATLAB command window.
  5. Patch for your OS version via this link:
  6. In terminal, type "open ~/.matlab/R2012a"
  7. open in Textedit
  8. Find the section labeled "#PATCH: MacOSX10.?" where ? is your version number
  9. After the last line starting with "LDFLAGS" in that section, hit enter and paste "LDFLAGS="$LDFLAGS -framework Carbon -framework AudioToolbox -framework AudioUnit -framework CoreAudio"" then save the file.
  10. Open playrec_2_1_0/m_files/compile_playrec_func.m in matlab
  11. On line 65, replace 'src/common/pa_skeleton.c" with "src/hostapi/skeleton/pa_hostapi_skeleton.c'
  12. On line 78, replace 'src/os/mac_osx/pa_mac_hostapis.c' with 'src/os/unix/pa_unix_hostapis.c'
  13. Open playrec_2_1_0/m_files/is_os.m in matlab
  14. On line 25, remove or comment out ", 'builtin'" 
  15. Open playrec_2_1_0/lib/portaudio/src/common/pa_hostapi.h in matlab
  16. Comment out lines 70-72 and 110-112
  17. Make sure all of the folders we've added are in your PATH and run 'compile_playrec_gui'
  18. deselect all options other than 'CoreAudio'
  19. locate the 'portaudio' folder using the Browse button.
  20. Press compile.
  21. Put the playrec.mexmac/.mexmaci/.mexmaci64 in your usual MATLAB folder and play!
The next part will be integrating playrec into the audio crossover/player project in place of msound!