New basic Csound tutorials on youtube

I just happened across these by accident. Apparently they have only been uploaded within the last few weeks.

He shows how to get your first sound out of Csound using the QuteCsound front end.

Search for user “ketchupok” or here are some direct links:

Configure QuteCsound:

60 second intro to Csound (using QuteCsound front end)

I think he may be assuming a little more expertise than a beginner might have, but in any case well worth checking out his short videos.

He’s also using a Macintosh, although the principles are supposed to be the same over all platforms.

ChucK meets Csound

I also have experimented with converting a Csound instrument (#1706) to ChucK which seemed to work:

I had to upload the files with .doc format since I’m using this free blog software. Hopefully you can decode them.


This is really a zip archive I renamed with a .doc extension so I could upload it in wordpress. It has the original csound files, and my chuck version.

Some months ago, there was a great discussion on the ChucK discussion list ( called “One-line ChucK Crazy.” People contributed their own tiny ChucK programs to make interesting sounds/music as long as it fit on only one line.

One of the most active and creative contributors to the list is user “kijjaz” from Thailand. He submitted an amazing little program that used three oscillators hooked up in an FM configuration that created a bizarre drone if left to run for several minutes (or longer).

I’ve been tinkering with that algorithm, and want to experiment with various parameters and variables. And as an exercise, I’m also going to try to rewrite it as a Csound instrument.

I don’t have the Csound .orc finished yet, so I’m just going to give the ChucK program here. If you don’t know about ChucK, you need to learn! See other posts on this blog for pointers.

Note once again that I had to upload the file with a “.doc” extension to make wordpress happy. I don’t think ChucK cares very much what the file is named that you launch, but for consistency I always name executable ChucK programs with a .ck


More on “Deep Note”

First of all, thanks to Steven Yi for his comment on the previous post about Deep Note (the THX sound). For those of you who don’t know, he’s a Csound master and author of a timeline based composition environment for Csound called Blue (see

Meanwhile I’ve continued my experimentation with the Hans Mikelson instrument gran2. The problem with it was that it took 180 seconds to compute 8 seconds of stereo output, so tweaking it was a slow process. I decided to try using a newer opcode called “grain3” (introduced in Csound 4.15). I guessed the right parameters to use more or less and ran it, and it sounds pretty good. It runs essentially in real time with less than a 50% CPU usage on a Celeron 2.2GHz. (The csd file is appended below.)

I still need to tweak some parameters and envelopes on it as well, but at the moment it’s a very promising approach. It’s quite different in design from what I read in the article pointed to by Steven, but I supposed that will make sense later.

Incidentally, I have been struggling to get Csound programs to look right in WordPress, but I haven’t been able to figure out how to do it.

In the WordPress FAQ they mentioned a very cool site called pastebin ( This is a site that allows you to post chunks of code that other people can read. I created a “private” pastebin called that I’ll use to point to my examples and snippets.

So here’s where you can see my take on grain3.

The most famous piece of computer music…

….is probably the huge sound effect that plays in the movie theater when the THX logo comes on. Well, maybe it’s not really a piece of music as a sound effect, or more properly an audio logo.

Going through the Csound instrument demos files, I found one by Hans Mikelson which is supposedly intended to show the grain opcode. But when you render it it sounds exactly like the THX sound. It cuts off sort of abruptly at the end (it’s only :08 long), and takes an ungodly amount of CPU time. Anyway here it is.

As a pedagogical exercise I’ve been analyzing the file to eliminate unused code, try the grain3 and granule opcodes, etc., but I haven’t got that done yet. When I do I’ll post updates here

It appears that the score statement after the e is leftover from something.

N.B. The two calls to grain are not redundant (i.e., not the same as computing aoutl and then setting aoutr = aoutl) since each call to grain uses a different random number.

Added 2000717: I moved the code over to:“Deep Note” version 1 Csound program (this will open the example in a new browser window).

…Lighting a candle

I posted a link to my (well-meaning) gripes about the Csound examples/ subdirectory and got some great responses on the Csound forums (

If you’re already past the point where you have the basics of Csound running (i.e., you can play an orchestra and score, and/or create a sound file output from them), there are really a good wealth of tutorials and help files all over, particularly on (start with

Do note however that on the “Other tutorials” page two of the five English links are broken (!) but this is just a result of the enormous size and complexity of the Csound universe.

Playing Csound instruments from a MIDI keyboard (draft version 2)

OK, this mini-tutorial still isn’t “complete,” but I’ll keep improving it little by little and maybe someday I’ll  look at it and be amazed that it’s “done.”

“I don’t want to do any programming AT ALL!”

OK, if you insist…here I’m going to show a couple ways I connected my MIDI keyboard such that I could play a Csound instrument.

Again with the apologies to Mac and Linux users: this is all Windows (2000/XP) stuff. Sorry about that…

To work this example, I recommend you use the CsoundVST tool. csound5gui will work, but the latency [i.e., the time lag or delay between when you press a key and when you hear the sound] when you set it up for MIDI input is huge (at least on my system).

Remember this will require that you install the “python” package as referred to elsewhere. It’s not that bad, you just run the .msi installer as with other conventional Windows software. You don’t really need to know anything about it at first. But at this writing, you should have the latest version of the Csound release (5.06) and 2.5.x of Python. If not you may be setting yourself up for more grief than you really want!

The “Classic Csound command line” box in CsoundVST reads:

csound --midi-device=9 --midi-key=4 --midi-velocity=5 temp.orc temp.sco

Starting with the tutorial2.csd file in Program Files/Csound/tutorials… (and with help from Michael Gogins excellent tutorial)

1. First make sure you can get some sounds out of tutorial2.csd. Bring up csound5gui, use the browser (…) button on the left of the Orchestra/CSD box to select that file. (The Edit button on the right should open a Notepad window with the .csd file in it in case you want to make tweaks.)

For output file use dac — that should work no matter what even if you have a better audio card on your system. You can experiment with dac1, dac2, etc. if you have other sound output hardward available on your system.

2. Press Play/Pause (the right pointing triangle under the time display). You should see time advance and hear a series of simple tones playing the 6 instruments in the .orc (orchestra) part of the .csd file, about 30 seconds worth.

3. If you have a MIDI interface on your system with a keyboard hooked up, make the following changes to the .csd file.

In the <CsOptions> section it reads

--midi-key=4 --midi-velocity=5

To this line, add the following string: “–midi-device=9999” (without the quote marks, of course.)

and run it again. It should figure that the MIDI device number is out of range a print a list of the legal ones in the messages window. On my system I get

The available MIDI in devices are: 
0: MIDI Yoke NT: 1 (MMSystem) 
1: MIDI Yoke NT: 2 (MMSystem) 
2: MIDI Yoke NT: 3 (MMSystem) 
3: MIDI Yoke NT: 4 (MMSystem) 
4: MIDI Yoke NT: 5 (MMSystem) 
5: MIDI Yoke NT: 6 (MMSystem) 
6: MIDI Yoke NT: 7 (MMSystem) 
7: MIDI Yoke NT: 8 (MMSystem) 
8: micro lite: Port 1 (MMSystem) 
9: micro lite: Port 2 (MMSystem) 
10: micro lite: Port 3 (MMSystem) 
11: micro lite: Port 4 (MMSystem) 
12: micro lite: Port 5 (MMSystem)   

*** PortMIDI: error: device number is out of range   

*** error opening MIDI in device: -1 (Unknown MIDI error)

OK: this tells me that my Oxygen 8 MIDI keyboard is hooked up to the micro lite interface port 2, so I change –midi-device=9999 to -midi-device=9

4. You should also remove the i statements in the <CsScore> section or you’ll hear those play at the same time. Change that section to this:

f 0 3600

5. Under


I also changed the sample rate frrom 88200

sr = 44100

Since there’s no benefit on my system to using anything less.

6. Now play notes on your MIDI keyboard. When I do this I see in the messages window for instance

rtevent: T 2.136 TT 2.136 M: 0.0 0.0             

new alloc for instr 6:             

rtevent: T 2.879 TT 2.879 M: 729.3 846.7 
rtevent: T 4.551 TT 4.551 M: 129.6 129.5 
rtevent: T 5.759 TT 5.759 M: 729.3 846.7 
rtevent: T 6.409 TT 6.409 M: 168.4 152.9 
rtevent: T 6.594 TT 6.594 M: 427.9 496.9

Where each key press and release results in a message.

Well, it’s a start. The only problem, and it’s a pretty nasty one, is that more than 2 seconds elapses between a key press on the Oxygen keyboard and a note sounding. This is not so great.
One trick to reduce CPU usage is to increase the control rate (kr) which is currently = 1. Setting that to even 100 doesn’t help the latency.

7. Well, let’s try a couple other routes. We can use CsoundVST as a standalone program.

You can launch CsoundVST from the Start>Programs>Csound>CsoundVST menu. Once the GUI displays, use the Import… button to get out tutorial2-MIDI.csd file. I know you don’t want to know about code (!) but You can inspect the Orchestra and Score code using the tabs in the GUI. (You can resize the GUI in the usual way to see the code better)

8. In the “Classic Csound Command Line” box you should see:

csound --midi-key=4 --midi-velocity=5 --midi-device=9 temp.orc temp.sco

Now we are getting used to the meanings of these parameters and arguments. I don’t know if it’s a default in Csound, but you may need to add “-o dac” after the csound token in the above. (I think if you don’t put anything for an output destination, Csound VST will attempt to play realtime.)
Ideally now, when you click the “Perform” tab at the top of the GUI, the program should wait for MIDI notes and play them. In my case this works, and the latency is MUCH improved.