2009/12/04

Howto Use SCVim For SuperCollider On OSX

I've been playing a lot with SuperCollider lately. In case you haven't heard of supercollider yet:

SuperCollider is an environment and programming language for real time audio synthesis and algorithmic composition. It provides an interpreted object-oriented language which functions as a network client to a state of the art, realtime sound synthesis server.

Without going into to much detail about SuperCollider there's one thing which was bugging me, namely the built-in editor you get with the OSX distribution. If you're used to vim, working with a different editor is generally quite a pain. On Linux you have the choice between integrating SuperCollider into gedit, emacs, or vim via plugins and all of those are decent editors compared to this:

SuperCollider Editor

Luckily, it has been reported that scvim also works on OSX. However, I wasn't able to find any docs about the installation process, so I thought I share the way I got it working.

Prerequisites

Obviously you'll need to install vim and SuperCollider ;-).

  • SuperCollider - I used the *-with-extras distribution
  • MacVim - works with other Vim distributions as well but that's the one I'm using

Download the latest scvim archive. The scvim page mentions that you'll need scons and unhtml for the installation but we'll do a manual install (the scon script doesn't quite work on OSX anyway) and we also don't install unhtml, which is needed to generate the help docs, because this is the only thing I haven't got working so far.

After unpacking the scvim archive we move the vim relevant files into our ~/.vim folder (create it you don't have one already).

Inside the scvim directory:

$> mkdir ~/.vim
$> cp -a {ftplugin,syntax,indent} ~/.vim
$> cp scvimrc ~/.vim

Then copy the pipe script in the scvim/bin/ directory to your ~/bin (create it if necesarry) and make it executable.

$> mkdir ~/bin
$> cp -a bin/sclangpipe_app.sh ~/bin
$> chmod +x ~/bin/sclangpipe_app.sh

In order to make sure that scvim finds the sclang executable of SuperCollider we just symlink it into our ~/bin directory.

$> cd ~/bin
$> ln -s /Applications/SuperCollider/sclang .

Then we have to copy the SCVim.sc SupperCollider class into our extentions directory (I had to create it too).

$> mkdir ~/Library/Application\ Support/SuperCollider/Extentions
$> cp scclasses/SCVim.sc ~/Library/Application\ Support/SuperCollider/Extentions

SCVim comes with a start script which I've slightly modified to make it working with MacVim. I also stripped out the the whole vimrc testing because I'm using only one scvimrc anyway.

scvim
#!/bin/sh
 
vim=/Applications/MacVim-7_2-stable-1_2/mvim
#parse ops
while getopts "gh" opt; do
	case $opt in
		h  )	echo "supercollider in vim"
				echo "usage:\nscvim [-h] [-g]"
				echo "\t -h prints this help"
				exit 0;;
	esac
done
 
exec $vim --cmd "source ~/.vim/scvimrc" -c "set filetype=supercollider | runtime ftplugin/supercollider.vim | SClangStart" $@

And as the last step we have to make sure that ~/bin is in our $PATH. Therefore just edit your ~/.bashrc, creat it if necessary and insert the following.

export PATH=~/bin:$PATH

Source it afterwards, or open a new terminal.

$> source ~/.bashrc

That's it if we now run scvim MacVim should start as well as the SuperCollider interpreter. To get an idea what commands you can use just check the scvimrc. For a quick test just start scvim enter the following, select it in Vims visual mode and run <`/`>:call SClang_send() on both lines. The server should boot and then play a sine wave at 440Hz.

s.boot;
{ SinOsc.ar(440, 0, 0.5) }.play;

I'm thinking about remapping the whole keys though, the whole <Fn> key mappings don't seem to work that well here :-/.

That's it, I hope this might be of help to someone else who's looking for a way to run scvim on OSX. If someone found a way to make the SuperCollider help working with SCVim please let me know :-).

Related Articles:

Comments




MGDHF