Jack to work with SuperCollider in Linux

I am still quite new to Linux in general. I am learning a lot by just trying to use it, and trying not to move back to OSX just to do a simple task. So that this post might be for a person like me, who has struggled a lot on this ‘new’ way of patching sound in and out and configuring in a right way.
I have used Jack before in OSX when I was trying to do a virtual multichannel test, but there was a graphical interface, not at all complicated. There is also ‘system preference’ that OSX offers. When I change the soundcards, or using different inputs/outputs, I didn’t need to do much. But here, it might be a simple thing, but I was in panic.
So that I would like to share my experience if this can help anyone who is like me.

I have two different versions of linux that I am using in different laptop. 11.04/11.10.

Here I am focusing on 11.04, because 11.10 had less issues.

Jack versions and library installed : jackd, libjack-jackd2-dev, jackd2-firewire, jackd2, libjack-jack2-0, libasound2-plugins

First of all, I was at the first moment trying to use ‘qjackctl‘ that offers graphical user interface. But weiredly, the value that I have changed was not applied to the result.

Screenshot of qjackctl setup window

The default sample rate was set to 48000, and I wanted to change it into 44100. Even though I was doing it, it didn’t change.

Asking some people around, I found that pulsa audio can be the cause of issue, so I removed it and tried to use only ‘alsa.’

Jack setup

When I run scvim, I use a bash script in order to reduce any possible complications such as already-running-sclang. I saved it as ‘iscvim’ and fixed chmod to an exacutable, and put it into a path (i.g. /usr/local/bin.).

Here I include jack setup as well.

cd ~
killall jackd
killall sclang
killall scsynth
killall scvim
killall sclangpipe_app
jackd -t 500 -d alsa -d hw:0 -r 44100 -p 1024 -s -S &
sleep 1

Here I set to use alsa as the driver, and device as hw:0, sample rate: 44100, period 1024, softmode and the last of -S is to cofigure card for 16bit. This configuration can differ from soundcard. I tried to use 32 bit, but my sound card only supports 32 bit-float. But this created problem with sc3, (creating distortion) and I assume that this is because of -float- (it could be supposed to be integer).

Check something like this when you run jack,

ALSA: final selected sample format for capture: 32bit float little-endian


ALSA: final selected sample format for capture: 16bit little-endian

In order to know what card you have;

cat /proc/asound/cards

In order to know what other configuration will be possible with your soundcard, use ‘jack_control,’ which shows you all possible options for your setup, and not difficult to use.

For Realtime Scheduling

This is followed by what ‘jack’ website suggests, and it works very well. (http://jackaudio.org/linux_rt_config)

Open /etc/security/limits.d/audio.conf

Then fix as below.

# Provided by the jackd package.

# Changes to this file will be preserved.
# If you want to enable/disable realtime permissions, run
# dpkg-reconfigure -p high jackd
@audio - rtprio 95
@audio - memlock unlimited
#@audio - nice -19

So far, no issue when I am using SCVim, and I run Jack when I need to use it.  Hope this helps.

SCVim with Auto completion and Snippets

The nicest part of using vim for me is to use the window management. It gives an opportunity to work in a clean environment that windows are not floating around, no need to search for a window behind another.

The second part that I discovered is to use all the functionality on Vim. I love vim more and more everyday. At the beginning, it was too difficult to know all the shorcuts and function keys, but after some time forcing myself to use them more and more and putting some ‘postits’ with some cheat-notes on the frame of my monitor, I think it is a powerful tool.

I would like to introduce some of powerful sides of using vim for SuperColliding. (it works in both Linux and OSX)


I use the snippet plugin that you can download from vim website. It is called ‘snipMate‘ and you can also see the screencast.

Download the zip file into ~/.vim and unzip it, then you can find ‘snippets’ folder too. There, you can create your own snippets for any language (that vim supports) you are using.

Here, since I installed scvim, I will give you an example of how this snippets work.

Create a file on ~/.vim/snippets/supercollider/example.snippet
The file name is an important element because you are going to call the snippet with the file name.
In this case, when you edit vim, you are going to write ‘example’ and then tab key.
Here I will write a SynthDef snippet since I make SynthDef a lot.

Here is the example.

  arg ${2:arg1};
  var ${3:var1};
  $3 = ${4:write};

In this way, you created a snippet. I named it as ‘syndef’

When you call, you will see this

Because we setup the synth name as an argument by doing ${number:name}, your cursor will stop at the first argument.
After you fill up the synth name, and click ‘TAB’ button, then it will move to the second argument, in this case ‘arg1.’

The best part of this is that the name of argument becomes flexible. In this example, ‘var1’ is used in two places. If you fix one of ‘var1’ name, then the other one will follow. You don’t need to go down to the name and try to fix it!!

This is a simple example. I don’t use a lot of snippet, but some that save lots of time for me.


Auto Completion

For auto completion, I use ‘AutoComplPop‘ plugin.

If you have installed correctly, you will find those files ‘sc_object_completion’ and ‘supercollider_objects.vim.’ in ~/.scvim folder. Those files are going to be used to create auto completion.
If you don’t get it successfully, copy those two files into ~/.vim folder. Then when you type in, you will see this :

That’s quite easy!!

I am still exploring what could be useful for coding. I will post when I discover something useful. Hope you enjoy!

Supercollider and Vim (SCVim) in OSX

After a while struggling with the supercollider editor, which for me has an issue with lots and lots of windows floating around the window, I decided to move to another editing environment to code SuperCollider.There are several options for this, such as using TextMate with sc bundle(https://github.com/sbl/scmate.tmbundle), but I wanted to have a more simple platform.

Then there was ”VIM’ and SCVim. (for more options : http://supercollider.sourceforge.net/wiki/index.php/Systems_interfacing_with_SC)

I will explain a bit how to make a proper install in OSX. (Lion, 10.7.2 at the moment of this posting)
First of all, I normally compile SC from the latest source using git. (for more information about download the latestSC source codes: http://supercollider.sourceforge.net/developers/)
In the source folder, there already is the editor source for SCVIM in the editor folder.
Go to the folder /yourSCSourcedirectory/editor/scvim.
If you want to compile scvim seperate, using those command

cmake ..
sudo make install

Then your scvim is located in /usr/local/bin/scvim (to see where your scvim is located: type this in terminal ‘which scvim’)
I assume that your SuperCollider is located in /Applications/SuperCollider, which by default this newly compiled supercollider should be there,
scvim is working by an application called ‘sclangpipe_app,’ which makes possible to run sclang.
When you run scvim, it automatically opens up this sclangpipe_app and this should be able to link all your SCClassLibrary and library files.
In your folder, you see the library files such as libsclang.dylib.
(In the official SuperCollider, you don’t see this so that you can skip this part) and those files should be symlinked to sclangpipe.
To do so, type this in your terminal

cd /usr/local/lib; sudo ln -s <build-dir>/SuperCollider/lib* 

There is another problem with scvim + sclangpipe_app.

When you run scvim on your terminal, your sclangpipe_app is not entirely loading SCClassLibrary, which somehow doesn’t work properly.
So that you need to execute sclangpipe_app seperate from scvim.
In order to do so, I use shell script that automaticallt does this job.
This is the example.

open -a "iTerm.app"
  killall sclang
  /usr/local/bin/sclangpipe_app -l /Applications/SuperCollider&
  sleep 0.5
  open -a "iTerm.app" /usr/local/bin/scvim

I saved this file as ‘scvimsc’ and did ‘chmod +x scvimsc’ to make it executable, and put it into the folder /usr/local/bin/ .
Then what you need to do is in terminal, just type


Then it will automatically open both scvim and sclangpipe_app in a proper way.


Optional use of iIerm2 for scvim

I use iTerm2.app(free application) instead of default osx terminal, because I like the way it can do window management.
I wanted to put both ‘post window’ and ‘editing window’ on ‘one window’ so that I do not need to have several windows floating around.
In order to do that, you need to use apple script instead of shell script to set up this.
This is the apple script that I use.

tell application "iTerm"
  -- my project workspace
  set myterm to (make new terminal)
  tell myterm
  launch session "sclang"
  set number of rows to 150
  set number of columns to 40
  tell the last session to write text "killall sclang"
  tell the last session to write text "/usr/local/bin/sclangpipe_app -l /Applications/SuperCollider"
  tell i term application "System Events" to keystroke "d" using command down
  tell the last session to write text "scvim"
  set number of columns to 100
  set number of rows to 10
  end tell

I saved it as an application called ‘iscvim.app’ (from the apple script editor) and put it into /Applications/
So that I can only execute this application to open up iTerms, and scvim, and sclang together in one window!

In theory, this compiling process should be all to make scvim to happen. But surely there is an issue with library links.
But for now all are working fine with some lines on terminal, and can be solved with premade script to make things work.

A nice part of using vim is not only ‘window management’ but also using plugin for VIM. such as snippets for supercollider.
I will get back to this subject some day.
any remarks and commends and questions are welcome.