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:
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.
Obviously you'll need to install vim and SuperCollider
.
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.
#!/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:
I was able to get scvim running on OSX 10.6 and using Terminal.app for the post window.
1. Like the above poster says, you must change $SCLANG_RUNDIR in the scvimrc to your build directory.
I checkout and compile SC from the svn repo, so my rundirectory is /path/to/SuperCollider3/mac/build.
2. I found that this variable does not propagate to sclangpip_app, the script that calls sclang, so you need to hardcode the 'rundir' variable there too.
3. Uncomment the two OSX specific lines declaring sclangTerm and sclangPipeApp added recently to scvimrc (comment reads “the following worked with osx”).
let g:sclangTerm = “open -a /Applications/Utilities/Terminal.app” let g:sclangPipeApp = “path/to/sclangpipe_app”
4. If you're using Macvim with an mvim script that's hacked to open files from the command line in a new tab, the sclang call script won't work. I had to create a separate mvim script (mvimnotab). You can set scvim to open mvimnotab by changing the 'vim' variable in the scvim script.
5. On that note, I didn't use the OP's scvim script. I think there's a new script since this post was written (it's Ruby, not Bash), so I just changed the 'vim' variable and that did the trick.
6. Suggestions for keybindings (still working on this)
<S-D-CR> :call SClang_block()<CR>
<S-D-CR> :call SClang_block()<CR>a
<S-D-CR> :call SClang_block()<CR>
<D-CR> :call SClang_send()<CR>
<D-CR> :call SClang_send()<CR>
<D-CR> :call SClang_send()<CR>a
<C-S> :call SClang_free(“s”)<CR>
<C-S> :call SClang_free(“s”)<CR>a
NOTE: The first time I tried all this, SC stopped working. I had to delete the entire install including scvim, restart, re-checkout, recompile, and follow the steps above to get everything back to normal. Now it works great.
2010/06/21 04:04
Thanks for this! Spot on.
A few things that might help out others:
The plugin is available on vim.org: http://www.vim.org/scripts/script.php?script_id=1620
Also, when you run SCLang, you might get errors. I had to change my runtime from /tmp to /Applications/SuperCollider to give it access to the source files (this is defined in scvimrc). Once you get to errors related to the GUI, just ignore them and try to get a sound out of it - it should work anyway.