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.
- Start by visiting playrec.co.uk
- Download and extract playrec to your working MATLAB directory.
- 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.
- Run 'mex -setup' in the MATLAB command window.
- Patch mexopts.sh for your OS version via this link: http://www.mathworks.com/support/solutions/en/data/1-FR6LXJ/
- In terminal, type "open ~/.matlab/R2012a"
- open mexopt.sh in Textedit
- Find the section labeled "#PATCH: MacOSX10.?" where ? is your version number
- 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.
- Open playrec_2_1_0/m_files/compile_playrec_func.m in matlab
- On line 65, replace 'src/common/pa_skeleton.c" with "src/hostapi/skeleton/pa_hostapi_skeleton.c'
- On line 78, replace 'src/os/mac_osx/pa_mac_hostapis.c' with 'src/os/unix/pa_unix_hostapis.c'
- Open playrec_2_1_0/m_files/is_os.m in matlab
- On line 25, remove or comment out ", 'builtin'"
- Open playrec_2_1_0/lib/portaudio/src/common/pa_hostapi.h in matlab
- Comment out lines 70-72 and 110-112
- Make sure all of the folders we've added are in your PATH and run 'compile_playrec_gui'
- deselect all options other than 'CoreAudio'
- locate the 'portaudio' folder using the Browse button.
- Press compile.
- 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!