SuperCollider with Emacs on OSX

SuperCollider (Github) has a decent IDE these days. But perhaps you’d like to use an actual editor like Emacs.

Sam Aaron published an article on this, but it is badly outdated. It was also overly complicated including copying several core directories out of the app. He’s probably too busy doing his good work with Overtone to update it. You should check out Overtone, by the way.

You need to get the current source for scmode. There is no separate repo, so you need the whole SuperCollider repo. Once you clone the repo, the scmode code is under supercollider/editors/scel. The contents of the sc directory needs to be copied to the Extensions directory of your application support directory. You can discover the location of your application support directory by evaluating this in the SuperCollider interpreter:

On OSX that will be ~/Library/Application Support/SuperCollider, so copy scel to ~/Library/Application Support/SuperCollider/Extensions, creating the directory if it doesn’t already exist.

You need to add the contents of supercollider/editors/scel/el to your load path. You can just point to where you cloned the git repo, but I prefer to have my emacs lisp in a logical place. I copied the el directory to ~/.emacs.d/vendor/scel/el directory.

Add this to your init file:

You need to set your path within Emacs also. The sclang program is located in /Applications/SuperCollider/SuperCollider.app/Contents/Resources, so that needs to be in your path.
(For hacking in iTerm, I’ve also added it to my PATH in my bash startup file).

Launch Emacs. When the dust settles, type

The interpreter will start in a buffer named SCLang:PostBuffer and you will be presented with a new buffer named SCLang:Workspace.

Start the server in the workspace.

There will be a SCLang menu and you can execute commands from there. You’ll see the C-x C-f will evaluate the entire document. (Or type C-c C-p b to boot. Of course you can type C-h m to get the help for sclang mode).

Create a simple noisemaker.

C-c C-s will stop playing.

Have fun!

15 thoughts on “SuperCollider with Emacs on OSX”

  1. Awesome, thank you! I wasn’t doing two things exactly right and this post was the missing link among all the various bits of emacs-supercollider info out there.

    Two notes that may be helpful to others, or may simply be the result of mistakes on my part:

    1. In my scel/el directory, there was a file with a .in ending (specifically “sclang-vars.el.in”) that was causing a problem.
    It has something to do with cmake, I’ve inferred, but I simply just changed to the file ending to “.el” and I stopped getting the error.

    2. Apparently, there were/are two “Document.sc” files (one in Supercollider/extensions directory and one buried in the SCClassLibrary/Common/GUI directory); that caused an error. I simply removed the one from the Supercollider/extensions (they appeared to hold the same contents) and, voilá/voilà!

    Thanks again for spelling things out nicely. Will try to check back and dig the other things on your blog!

  2. Thanks for the thorough guide to ‘collide’ SC to Emacs.

    I am not sure this meant to be only for a specific OS so apologies to jump in.

    For MacOS note that the ‘exec-path’ line must amend to (setq exec-path (append exec-path ‘(“/Applications/SuperCollider” “/Applications/SuperCollider/SuperCollider.app/Contents/MacOS” )))

    And that seems to solve the problem.

    Thanks again for the guide!

    Best
    K.

  3. I think I found the problem, as of 3.7 sclang is in MacOS folder, instead of the Resources folder. However, I try to change that with MacOS folder but when I try to start sclang by sclang-start I am getting an error that says it can’t find the sclang file or directory, and what is strange is that still uses the old path instead the one I am putting here: (setenv “PATH” (concat (getenv “PATH”) “:/Applications/SuperCollider:/Applications/SuperCollider/SuperCollider.app/Contents/Resources”))

    (setq exec-path (append exec-path ‘(“/Applications/SuperCollider” “/Applications/SuperCollider/SuperCollider.app/Contents/Resources” )))

    Any tips?

    Best
    K.

        1. Any progress on this? It just doesn’t work to change the path to ‘…/Contents/MacOS’ instead of ‘…/Contents/Resources’ in .emacs or within sclang-customize, I still get:

          /usr/local/Cellar/emacs/24.5/Emacs.app/Contents/MacOS/Emacs: /Applications/SuperCollider/SuperCollider.app/Contents/Resources/sclang: No such file or directory

          *** SCLang exited abnormally with code 127 ***

          1. Thank you for the clear info, but we’re talking about 3.7, not 3.6, I’m afraid. As far as I understand, that is the version of SC Konstantinos was referring to, and what I also have trouble with. So I was wondering if you guys had made any progress on the matter. Anyway, many thanks! The search goes on!

            All the best,

            D.

          2. In 3.7.0 beta 1, sclang, scsynth, and SuperCollider are under MacOS now instead of Resources.

  4. Yes, exactly. And it doesn’t work changing it by customizing sclang path in emacs scel. For some reason it looks for the executables in the Resources folder instead, no matter what. So, it would be great if we could figure out why and where it looks for the sc path.
    .

      1. Thanks for all the info.

        I was just using 3.6 and had no idea there was a problem with 3.7, so I’m glad to know what’s going on.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.