Wednesday, 21 May 2008

SuperCollider for Human Beings

This time with gedit support!!!

And here's a short hands-on tutorial, just in case anyone would like to try out this extremely efficient synthesis environment for the first time...

UPDATE: the binaries also work with the amd64/chroot configuration, that's commonly used for native execution of SC3 on 64-bit distributions. Thanks to Sornen for the instructions, which you can read here!

UPDATE: the PPA is now signed with a generated key, which can be added to your system with the following command:
gpg --keyserver keyserver.ubuntu.com --recv DD9300F1 && gpg --export --armor DD9300F1 | sudo apt-key add -

The i386 (and amd64 server-only) packages are available through my PPA. In order to install them on Hardy, add the following lines to your sources.list (replace hardy with intrepid or jaunty to suit your Ubuntu version):
deb http://ppa.launchpad.net/artfwo/ppa/ubuntu hardy main
deb-src http://ppa.launchpad.net/artfwo/ppa/ubuntu hardy main
And apt-get install supercollider and supercollider-gedit packages:
sudo apt-get update && sudo apt-get install supercollider supercollider-gedit
Then start gedit and open Edit->Preferences. Enable Sced plugin from the Plugins tab:


Okay, now we can try the interpreter. Select Tools->SuperCollider Mode from the gedit menu. The SuperCollider output panel will appear with a message that SuperCollider has started. Now type the following code just inside the currently open document:
"Hello, World!".postln;
Make sure that the cursor is on the same line and press CTRL+E. You should see "Hello, World" printed two times in the output window. The string is duplicated because "postln" returned the same string as a value, and the output also prints the results of the evaluated expressions.

If you'd like to get some sound, make sure that JACK is started. If not, start it with qjackctl or the following command:
jackd -d alsa
After JACK has started, select SuperCollider->Start Server from the gedit menu and execute the following code string, just like we did with the "Hello, World" example above:
{SinOsc.ar}.play;
You should hear an annoying beep from your left speaker. Not much, huh? Well, press ESC (Stop Sound) inside gedit for now. And append something like the following code to your document (yes, you can do all the work in the same document):
// This example is a modified patch
// from the SuperCollider book by David Cottle
// You can enable syntax highlighting
// by selecting View->Highlight Mode->Others->SuperCollider
( // press CTRL+E here
{
  RLPF.ar(
    Saw.ar(55),
    LFNoise1.kr([5, 5], mul: 440, add: 880),
    0.1,
    mul: 0.25
  )
}.play;
)
Note the brackets around the actual code. They're used to group code together into "blocks" and execute SuperCollider instructions simultaneously. In this example you will need to press CTRL+E where indicated to select and run our block. Remember, that you can shutdown the sound anytime with ESC! :)

As you can see, we have a Saw oscillator, connected to a resonant low-pass filter (RLPF) here and the cutoff frequency is controlled by an interpolated random value (LFNoise1). You can open reference pages for the respective modules (UGens) by positioning the cursor over them and pressing CTRL+U, but make sure that you install supercollider-doc package to get those.

Well, I hope this tutorial will help you get started with SuperCollider. Make sure you also stop by the SuperCollider website and the wiki for more tutorials and examples.

48 comments:

Jaime said...

Yeah! We just installed supercollider on 18 classroom machines in less than 30 minutes thanks to you. Could you do a follow-up showing how to install SwingOSC along with your packages. I tried the default SwingOSC instructions and couldn't get it to work.

artfwo said...

Hi, Jaime! You can install SwingOSC very quickly as well by copying the contents of SuperCollider/SCClassLibrary directory from SwingOSC-0.60.zip to:

/usr/share/SuperCollider/Extensions
(You'll get /usr/share/SuperCollider/Extensions/SwingOSC)

Copy the "Help" directory to the Extensions folder as well, if you need interactive help.

Then place build/SwingOSC.jar anywhere you like and evaluate the following command before starting the GUI server:

SwingOSC.program = "/path/to/swingosc/SwingOSC.jar";

I usually put the jar in my home directory. Then you won't even need to specify SwingOSC.program :)

Miguel Angel said...

Hi artfwo,

I'm new to supercollider on linux, just switching from Max/MSP. I would like to ask you about the startup file for supercollider. There is nothing on my home folder and would like to have it load my SwingOsc.jar location on startup (placing it in home doesn't work for some reason).
I'm using your gedit plugin which works great, I was wondering if it would be possible to launch gedit from a scrip so it switches to supercollider mode and activates the syntax colors.

Thanks in advance and keep up the good work.

-Miguel

artfwo said...

Miguel, the startup file for SuperCollider would be ~/.sclang.sc. Try placing the following code inside the startup file:

SwingOSC.default.boot; GUI.swing;

This should start SwingOSC automatically. Also, make sure that SwingOSC.jar is in your home directory (or the directory you start gedit from). Hope this helps :)
-Artem.

Anonymous said...

Thanks for this short and sweet howto and your time saver packages!

ascriptedmelody said...

I know this is an old post, but I really appreciate your work in making these packages available along with some helpful directions. Thank you!

Anonymous said...

HI,

I've been using 7:10 - I have an older computer (Omnibook XE3). Is there a 7:10 workaround for the dependencies?

thanks

artfwo said...

No, there's no version for 7.10, but I'm going to try and build this one for you as well, stay tuned!

Visruth Ram K V said...

Thankz lot for u'r grt info
Really it ws very much useful for me

artfwo said...

A little update on this. The packages are now built on an almost weekly basis for Jaunty, Intrepid and Hardy.

Unfortunately, no builds for 7.10 yet, because Scons in Gutsy does not have --install-sandbox option, that is crucial for the current build scripts (and is very useful for building debs out of Scons-based software in a sane way). Sorry, but I have to give up building these, please consider upgrading at least to Hardy.

Anonymous said...

Thanks a lot for this tutorial! Everything working in Ubuntu 8.10. Been using MAX and PD, but this SC is amaising...
I also added the swingOSC sartup script and works (although I do get some errors but the tutorial examples work)

Just to add my token: to copy the SwingOSC zip contents to the /usr/share on my system I had do it as su.

Thanks again and kind regards,
Lorenzo

Anonymous said...

Thanks a lot for this. One problem I'm having is I can't pull up help files from within arguments, also 'Help' from the pulldown menu doesn't work. Any ideas? Do I need to put the helpfile anywhere??

artfwo said...

Do you mean that the Find Help shortcut does not work for you? Do you use Gedit, Emacs, or Vim? Do you have supercollider-doc package installed?

Anonymous said...

neither the shortcut or the tool bar. I get error messages (tried to post here but the blog reads them as html and won't accept them. I'm using gedit, and suod apt-get install confirms I have th elatest version installed

artfwo said...

Could you please E-mail the log messages to me, so that I could check what's wrong for you? (artfwo KLMRF gmail DOT com)

Anonymous said...

Just a public 'thank you' to Artem for helpingme solve the above problem

Anonymous said...

hi artfwo,

unfortunately i have not been able to install swingosc. when starting gedit in supercollider mode, i get the following output:

init_OSC
compiling class library..
NumPrimitives = 544
compiling dir: '/usr/share/SuperCollider/SCClassLibrary'
compiling dir: '/usr/share/SuperCollider/Extensions'
pass 1 done
ERROR: Class extension for nonexistent class 'SCDragView'
In file:'/usr/share/SuperCollider/Extensions/SwingOSC/extCocoaCompat.sc'

...and a couple of additional error messages. could you please tell me what is wrong?

artfwo said...

That's okay, those error messages can simply be ignored, and swingOSC will work.

Anonymous said...

thanks for this post!
/r

Anonymous said...

It doesn't look like supercollider is installable on Intrepid 64-bit...

Any ideas?

artfwo said...

Well, the only non-dev package, installable on amd64, is the server (deb here). Is it uninstallable directly for you as well?

Oh, and would you provide more details (error messages, if any)? Thanks.

Marc said...

Hi,

sorry a definite beginner here... I got everything working except the SwingOSC... I followed the directions here, as well as the directions on the Swing OSC site, both ways when I open SC it still says

GUI.fromID : The GUI scheme 'swing' is not installed
The current scheme is still 'nil'!

And when I run the command I get

ERROR: Class not defined.
in file 'selected text'
line 1 char 8:
SwingOSC•.program = "/path/to/swingosc/SwingOSC.jar";

artfwo said...

Marc, have you copied the SwingOSC classes (*.sc) into ~/share/SuperCollider/Extensions/SwingOSC?

I have the classes in the following directories:

~/share/SuperCollider/Extensions/SwingOSC/
~/share/SuperCollider/Extensions/SwingOSC/SwingGUI.sc
etc...

Anonymous said...

Hey thank you for your great work!!
Everything is running fine, except one thing:
I'm a beginner as well, and I'm wondering if the missing classes (e.g. SCDragView.sc etc.) can be found anywhere? Some of the tutorials are using the SCWindow class for example, and,thus,they don't work. What can I do to fix that?


@Marc
... and perhaps you should enter the correct path instead of "/path/to/swingosc/" (if that's the original error message you get).

Thanx

artfwo said...

It looks like the missing classes problem (SCDragView, etc.) is no longer a problem with the latest SwingOSC preview release (swingosc-preview-0.61), available from the SwingOSC project page.

I'm unable to test it myself right now (no Java), but the interpreter loads without an error. Woot!!

Anonymous said...

yupp, the error msgs at startup have disappeared. but the problem is still there. I get an "Class not defined" error, when I'm trying to use SCDragView for example. (This classes are not included in the swingOSC .zip file). Are they obsolete? As I said I'm an absolute beginner with SC, so maybe it's just somthing, taht I don't understand...

artfwo said...

SCDragView works for me right now. If you're using Ubuntu packages from PPA, please try upgrading to 3.3~svn8801 first...

Then, I suppose, it's best for you to remove all the SwingOSC traces from /usr/share/SuperCollider and ~/share/SuperCollider, download SwingOSC Preview-0.61 and run the following commands as your regular user:

1. unzip SwingOSC-0.61RC_SVN156-090130.zip
2. mkdir -p ~/share/SuperCollider/Extensions
3. cp -a SwingOSC/SuperCollider/SCClassLibrary/SwingOSC ~/share/SuperCollider/Extensions
4. cp SwingOSC/build/SwingOSC.jar ~

And (optional) remove the unzipped sources:
5. rm -rf SwingOSC

Anonymous said...

Hi,
is there a way to specify in sced the supercollider folder? When i install supercollider on ubuntu it is in the folder /usr/share/. but when i start supercollider from gedit with sced, it wants to compile the class library in /usr/local/share/Supercollider.
I have to move my installation from /usr/share to /usr/local/share in order to be able to use supercollider.

artfwo said...

Hi! There's not. Sced simply runs sclang, which is being found in your $PATH, and if sclang has been compiled/installed into /usr/local, it will pick up the class library from /usr/local as well.

So, you'll have to check if you've got sclang/scsynth binaries in /usr/local/bin first. And get rid of 'em, but that depends on which SuperCollider you'd like to keep.

Anonymous said...

Thank you very much. It was the perfect solution for my problem. I use the supercollider version which i install through apt-get but i compiled it once from the sources, thats why there was sclang in /usr/local/bin. thanks

Anonymous said...

Thanks much for these directions. Worked like a charm for SC. (Though I ended up using sc-emacs instead of sc-gedit.)

Here's what I did to make SwingOSC work on a Ubuntu install:

1) Fetch swingOSC: http://sourceforge.net/project/showfiles.php?group_id=155586

2) unzip SwingOSC-0.61RC_SVN156-090130.zip

3) sudo mkdir -p /usr/share/SuperCollider/Extensions

4) sudo cp -a SwingOSC/SuperCollider/SCClassLibrary/SwingOSC /usr/share/SuperCollider/Extensions

5) sudo cp SwingOSC/build/SwingOSC.jar /usr/share/SuperCollider/Extensions/SwingOSC

Then start up your SC program with:

SwingOSC.program="/usr/share/SuperCollider/Extensions/SwingOSC/SwingOSC.jar";

SwingOSC.default.boot;

GUI.swing;

And it works! Woot.

sarigama's oil vending orchestra said...

hi!
am on intrepid and did the:
apt-get install supercollider
and
apt-get install supercollider-vim
to do the scvim

well ... didn't make any dir in my ~ .. but anyway just did a first try for the command:
scvim

but the result was:

Error detected while processing command line:
E492: Not an editor command: SClangStart
Press ENTER or type command to continue

am using dwm as wm
and did the command on terminator

was away from sc for a while and like dicided only to take advantage on it when booting pure:dyne .. but if your package is gonna make things simple for me .. yes i'd like to go sc@ubuntu once again

tia

artfwo said...

Right, supercollider-vim is now packaged to conform with the new policy for packaging Vim addons: they're not enabled by default. If you want to enable it for your user account just execute:

vim-addons install supercollider-vim

Similarly, to enable it for all users of this system just execute (as root):

vim-addons -w install supercollider-vim

vim-addons is provided by the vim-addon-manager package, that is not specified as a dependency for current builds of supercollider-vim. This will be fixed (with a proper README) as soon as I package the release candidate for 3.3.

sarigama's oil vending orchestra said...

my english reading is not good enough but this is what you mean in the last sentence?

~/podp# apt-get install vim-addon-manager
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
vim-addon-manager
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 13.7kB of archives.
After this operation, 127kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com intrepid/universe vim-addon-manager 0.4 [13.7kB]
Fetched 13.7kB in 1s (12.7kB/s)
Selecting previously deselected package vim-addon-manager.
(Reading database ... 83794 files and directories currently installed.)
Unpacking vim-addon-manager (from .../vim-addon-manager_0.4_all.deb) ...
Processing triggers for man-db ...
Setting up vim-addon-manager (0.4) ...
~/podp# vim-addons install supercollider-vim
Warning: Ignoring unknown addons: supercollider-vim
~/podp# apt-get install supercollider-vim
Reading package lists... Done
Building dependency tree
Reading state information... Done
supercollider-vim is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

artfwo said...

Oops, sorry! My mistake... Please try to run "vim-addons install supercollider" instead. This have been tested to work properly for sure.

sarigama's oil vending orchestra said...

yes!! it came out at last!
i warns me about swing but i won't use it so ignored
and tested my superold code and ..
the sound is here ..
i didn't imagine it would be this easy!!
i didn't even create ~/share/supercollider by myself
maybe the package system did it for me?
am always using the system as root and not using the rt kernel
so didn't have to add anything for that limit something
i think am back to the sc's world
thank you sooooooooooooooooooo much!

whale-fins said...

so i added the keys, and updated my sources.list.

and i run the install command and i get this..

I am running ubuntu intrepid.

sudo apt-get update && sudo apt-get install supercollider supercollider-gedit
Hit http://mirrors.kernel.org intrepid Release.gpg
Ign http://mirrors.kernel.org intrepid/main Translation-en_US
Ign http://mirrors.kernel.org intrepid/universe Translation-en_US
Hit http://mirrors.kernel.org intrepid Release
Hit http://mirrors.kernel.org intrepid/main Packages
Hit http://mirrors.kernel.org intrepid/universe Packages
Hit http://archive.canonical.com intrepid Release.gpg
Ign http://archive.canonical.com intrepid/partner Translation-en_US
Hit http://security.ubuntu.com intrepid-security Release.gpg
Ign http://security.ubuntu.com intrepid-security/main Translation-en_US
Ign http://security.ubuntu.com intrepid-security/restricted Translation-en_US
Get:1 http://ppa.launchpad.net intrepid Release.gpg [307B]
Ign http://ppa.launchpad.net intrepid/main Translation-en_US
Hit http://packages.medibuntu.org intrepid Release.gpg
Ign http://packages.medibuntu.org intrepid/free Translation-en_US
Hit http://us.archive.ubuntu.com intrepid Release.gpg
Ign http://us.archive.ubuntu.com intrepid/main Translation-en_US
Hit http://archive.canonical.com intrepid Release
Ign http://security.ubuntu.com intrepid-security/universe Translation-en_US
Ign http://security.ubuntu.com intrepid-security/multiverse Translation-en_US
Hit http://security.ubuntu.com intrepid-security Release
Get:2 http://ppa.launchpad.net intrepid Release [46.7kB]
Ign http://packages.medibuntu.org intrepid/non-free Translation-en_US
Hit http://packages.medibuntu.org intrepid Release
Ign http://us.archive.ubuntu.com intrepid/restricted Translation-en_US
Ign http://us.archive.ubuntu.com intrepid/universe Translation-en_US
Ign http://us.archive.ubuntu.com intrepid/multiverse Translation-en_US
Hit http://us.archive.ubuntu.com intrepid-updates Release.gpg
Ign http://us.archive.ubuntu.com intrepid-updates/main Translation-en_US
Ign http://us.archive.ubuntu.com intrepid-updates/restricted Translation-en_US
Hit http://archive.canonical.com intrepid/partner Packages
Ign http://us.archive.ubuntu.com intrepid-updates/universe Translation-en_US
Ign http://us.archive.ubuntu.com intrepid-updates/multiverse Translation-en_US
Hit http://us.archive.ubuntu.com intrepid Release
Ign http://ppa.launchpad.net intrepid/main Packages
Hit http://security.ubuntu.com intrepid-security/main Packages
Hit http://packages.medibuntu.org intrepid/free Packages
Hit http://archive.canonical.com intrepid/partner Sources
Hit http://us.archive.ubuntu.com intrepid-updates Release
Ign http://ppa.launchpad.net intrepid/main Sources
Hit http://security.ubuntu.com intrepid-security/restricted Packages
Hit http://security.ubuntu.com intrepid-security/main Sources
Hit http://security.ubuntu.com intrepid-security/restricted Sources
Hit http://security.ubuntu.com intrepid-security/universe Packages
Hit http://packages.medibuntu.org intrepid/non-free Packages
Hit http://us.archive.ubuntu.com intrepid/main Packages
Hit http://us.archive.ubuntu.com intrepid/restricted Packages
Hit http://us.archive.ubuntu.com intrepid/main Sources
Hit http://us.archive.ubuntu.com intrepid/restricted Sources
Hit http://us.archive.ubuntu.com intrepid/universe Packages
Hit http://ppa.launchpad.net intrepid/main Packages
Hit http://security.ubuntu.com intrepid-security/universe Sources
Hit http://security.ubuntu.com intrepid-security/multiverse Packages
Hit http://security.ubuntu.com intrepid-security/multiverse Sources
Hit http://us.archive.ubuntu.com intrepid/universe Sources
Hit http://us.archive.ubuntu.com intrepid/multiverse Packages
Hit http://us.archive.ubuntu.com intrepid/multiverse Sources
Hit http://us.archive.ubuntu.com intrepid-updates/main Packages
Hit http://us.archive.ubuntu.com intrepid-updates/restricted Packages
Hit http://us.archive.ubuntu.com intrepid-updates/main Sources
Hit http://us.archive.ubuntu.com intrepid-updates/restricted Sources
Hit http://ppa.launchpad.net intrepid/main Sources
Hit http://us.archive.ubuntu.com intrepid-updates/universe Packages
Hit http://us.archive.ubuntu.com intrepid-updates/universe Sources
Hit http://us.archive.ubuntu.com intrepid-updates/multiverse Packages
Hit http://us.archive.ubuntu.com intrepid-updates/multiverse Sources
Fetched 308B in 1s (175B/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package supercollider is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package supercollider has no installation candidate
randy@randy-laptop:/etc/apt$ sudo apt-get install supercollider
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package supercollider is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package supercollider has no installation candidate


if i can get this to work on my machine i wont have to switch to windows for audio production!
plz help!
thank you

artfwo said...

2whale-fins: A friend of mine has successfully installed supercollider for Intrepid from the PPA several minutes ago. Please check if everything is okay with your sources.list and re-run "apt-get update". The appropriate line for Intrepid would be:

deb http://ppa.launchpad.net/artfwo/ppa/ubuntu intrepid main

Perhaps, there could be a problem with Launchpad at the time you tried to update APT cache... Email me if you have further problem with the packages (the address is in the sidebar to the right).

Anonymous said...

Anyone had any luck using a Wii Remote with supercollider? I've been trying things left and right, and can't make any progress. I've heard it's not that hard. :(

artfwo said...

Yes, it's very easy. See the WiiMote helpfile for an example (worked for me without problems).

sarigama's oil vending orchestra said...

today i wanted to view the help in scim
so i did :SChelp as it says so when sc gets booted
buh

help tag cache does not exist, you must run SCVim.updateHelpCache in supercollider in o
rder have help docs
Error detected while processing function SChelp:
line 6:
E149: Sorry, no help for SC:SCVim
Press ENTER or type command to continue

hmm...what's that "in supercollider" sayin?

sarigama's oil vending orchestra said...

sorry i was so stupid...
i just had to run SCVim.updateHelpCache
in the SCVim window that i opened ;D

blogekle said...

thanks for this post!

tacitdynamite said...

I can't seem to get the install to work on jaunty. I've added:

deb http://ppa.launchpad.net/artfwo/ppa/ubuntu jaunty main
deb-src http://ppa.launchpad.net/artfwo/ppa/ubuntu jaunty main

to the end of my /etc/apt/sources.list, and then ran

sudo apt-get update && sudo apt-get install supercollider supercollider-gedit

with the result:

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Couldn't find package supercollider

What gives? Any idea?

artfwo said...

tacitdynamite, that is strange, because Jaunty packages are even built for amd64 now and they're residing in the pool.

Could you try to run "sudo apt-get update" separately and email the output to me? (together with your sources.list)

tacitdynamite said...

artfwo, this morning I ran "sudo apt-get update" and then ran sudo apt-get update && sudo apt-get install supercollider supercollider-gedit again, and this time it installed just fine. I'm not sure what the deal was. Thanks for your fast help! Great tutorial.

halalkebabhut said...

Thanks so much the first thing that I have got to work on Ubuntu . Just one thing can't find the start-up file to add that code ... where would it be ?

artfwo said...

If you mean the startup file for sclang, that would be ".sclang.sc", which must be stored in your home directory. Hope that helps!

Post a Comment