Off Topic – A Mac diversion

Having just completed the Sounding-Off project, I was intrigued by the lilypond music engraver program. I wanted to explore it more fully, but found that the version on the Pi was not the latest, and that my early model Pi with only 256Mb of RAM was prone to running out of memory when compiling longer music pieces. I decided to install lilypond on my Mac as well. This was easy using the installer here and there were instructions on the installer page on adding one line script wrappers to enable it to be called from the command line as well as via the built in GUI for running scripts.
I then thought about running the sounding-off scripts from my Mac. This threw up some problems. FIrst I would need to also install Timidity, lame and ImageMagick. Also shuf which is not native on the Mac. A more fundamental problem is that the Mac is based on BSD Unix and the syntax for commands like sed and readlink is different from that used by a gnu based linux.

Unlike a Pi where you don’t mind trashing your OS because it is so easy and quick to flash your SD card again, with a computer like a Mac you are always concerned not to trash it by installing items which are non standard, and you want to be sure that you can easily remove them again if need be. There are several systems to import extra non-Mac packages to the machine including macports, fink and my favourite brew. This project enables you to install packages from the command line using a simple command brew install xxx. Packages are installed to /usr/local/Cellar and symbolic links are placed in usr/local/bin to the binaries. So they are easy to remove either with brew or manually. Brew is installed from here.

With brew installed I added timidity lame coreutils and gnu-sed all using commands like
brew install nnnnnn
Timidity needs a configuration file to be added, and also sound fonts. For tge sound font I used the freepats package which is bundled with the timidity package on the Pi. I downloaded the tar file here and moved the extracted folder to the
/usr/local/Cellar/timidity/2.14.0/share/timidity/ folder.
I created a timidity.cfg file in the same folder with the single line content

source /usr/local/Cellar/timidity/2.14.0/share/timidity/freepats/freepats.cfg

and I also edited the file freepats.cfg inside the freepats folder and added the line

dir /usr/local/Cellar/timidity/2.14.0/share/timidity/freepats immediately after the first two comment lines.

The final package needed was ImageMagick. This is not in the brew setup but can be installed from here. This is in a different location, but uninstall details are provided on the installer page should you wish to remove it later. Once installed, I added it to my PATH by typing /usr/libexec/path_helper
and then copying and pasting the output supplied to execute it. If you then type
which convert you see /opt/ImageMagick/convert showing that it is installed and recognised ok.

The only remaining thing to do is to update the sounding-off scripts by replacing all sed commands with gsed, readlink with greadlink, shuf with gshuf. You also need to remove any sections to display the file in a browser in the Pi.
I modified two of the scripts, the and scripts to create two Mac versions, and which together create web pages of the long versions of the 12tone tune, but a lot faster than on the Pi, because of the more substantial resources available.

This was a slightly tricky exercise overall, but well worth the final results.

I am now investigating the Mozart Musilakisches Wurfelspiel, KV516f pieces. Dnases can be created with the throw of two dice, to select bars which slot together to give reasonable tunes in Mozartian style. A good starting point is the python version, which outputs to lilypond, by Martin Tarenskeen available here.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s