<?
PulseOsc p 
=> dac;
0.3 => p.gain;
0.3 => float g;
440 => p.freq;
55 => int f;

int e;
int t;
float b;
36 => e;
170 => t;
1.0 => b;

while ( 
e>)
{

<<< 
>>>;
1.05946309 => b;
t::ms => now;
=> e;

if ( 
e==24 ) { 130 => t; }
if ( 
e==12 ) { 50 => t; }

Math.rand2f (0.10.99) => p.width;
440 => p.freq;

}

while ( 
5000 )
{
10 => f;
f=> p.freq;
10::ms => now;
0.0014 => g;
=> p.gain;

}
?>
<?
SinOsc m
=>SinOsc c =>dac;
2=>c.sync;
int t;
while(
1)
{
if(
t<5){300=>t;}
t::ms=>now;
Math.rand2f(99,999)=>m.gain;
Math.rand2(99,300)=>m.freq;
t-3=>t;
}
?>
<?
SinOsc s
=> dac;        // connect sin oscillator to output
440 => s.freq;        // make sin osc play at 440 Hz
while(1)        // generate infinite loop
{            // open infinite loop
1::ms=>now;        // increment time so sound will play
}            // close infinite loop
?>
<?
if (me.args() > 1) {
    
dac.chan(0) => Gain g0 => WvOut w0 => blackhole;
    
dac.chan(1) => Gain g1 => WvOut w1 => blackhole;
    
0.5 => g0.gain;
    
0.5 => g1.gain;
    
me.arg(0) => w0.wavFilename;
    
me.arg(1) => w1.wavFilename;
    <<< 
"writing stereo output to files"me.arg(0), me.arg(1) >>>;
} else if (
me.args() > 0) {
    
dac => Gain g => WvOut w => blackhole;
    
0.5 => g.gain;
    
me.arg(0) => w.wavFilename;
    <<< 
"writing mono output to file"me.arg(0) >>>;
}
?>
<?
SinOsc s 
=> NRev verb => dac.left;
SinOsc t => NRev verb2 => dac.right;

.3=>s.gain;        // set sin osc levels
.3=>t.gain;
.1=>verb.mix;        // set reverb levels
.1=>verb2.mix;
int q;
int r;
300=>int time;        // set timing variable

while(1)
{

Math.rand2(1,6)=>q;    // generate random integer
330=>t.freq;        
220*q=>s.freq;        // multiply osc freq by random int to get new octave
time::ms=>now;


Math.rand2(1,6)=>r;    // generate random integer
220*r=>t.freq;        // multiply osc freq by random int to get new octave
70::ms=>now;        // delay right channel a bit
330=>s.freq;
time::ms=>now;

time-5=>time;        // speed it up
if(time<40){300=>time;}    // reset speed to slow if really fast
}
?>
ChucK: audio programming language - TranceAddict Forums - Production Studio
return to tranceaddict TranceAddict Forums Archive > DJing / Production / Promotion > Production Studio

Pages: [1] 2 
ChucK: audio programming language
View this Thread in Original format
MrJiveBoJingles
http://chuck.cs.princeton.edu/

I recently downloaded ChucK, which runs on Windows, Linux, and Mac. ChucK is a programming language centered around audio synthesis, playback, manipulation. "Ugens" are your basic building blocks in the language: they include oscillators, filters, and effects, can do different kinds of synthesis, and you can modulate and sequence them in all kinds of ways. You can also manipulate ChucK with external controllers and events, although I haven't tried that yet.

It's kind of a fun experience, building things up from very raw elements and thinking of a sequence in abstract, mathematical terms rather than as keys on a keyboard or squares in a sequencer. ChucK is used alongside the other languages CSound and SuperCollider in universities for crazy sound experimentation, but since I just got it the other day I am still taking baby steps obviously. So far I've found it quite a bit easier to get into than CS or SC, the syntax is much easier to me and it was simple to get some basic sounds going and write them to a WAV file. It also has a ton of example files that are very helpful. And just like the other languages, it is free, no payment or registration needed whatsoever.

Here are a couple Tetris-ish sounds I have gotten so far. You can copy and paste this text into your own files and play them or edit as you like. :-)
PHP:


http://jbj.raceriv.com/sounds/ChucK/exponent.mp3

^ Pulse wave that descends from 440 Hz (A4) by semitones, then climbs back up in pitch and volume. The rate of descent speeds up twice (those two "ifs"). Width of the pulse is randomized by "Math.rand2f".
PHP:


http://jbj.raceriv.com/sounds/ChucK/fm.mp3

^ Basic FM synthesis, randomized modulating frequency and modulation intensity. Speed builds up gradually then suddenly slows and starts speeding up again, in a loop.

Here are some more links that might be helpful:

http://wiki.cs.princeton.edu/index....Install_and_Run (Windows installation)
http://chuck.cs.princeton.edu/doc/build/ (Mac + Linux instructions)
http://chuck.cs.princeton.edu/doc/learn/tutorial.html (bare basic tutorial)
http://chuck.cs.princeton.edu/doc/language/ (all about the language)
http://chuck.cs.princeton.edu/doc/program/ugen.html (guide to Ugens)

For editing code ".ck" files, it's useful to get a decent text editor like TextPad, which will ensure they display properly. Also you can display line numbers, very useful for when ChucK spits out an error message and a line number back at you because you messed up the syntax or something. :-)
MrJiveBoJingles
Oh, and just so you don't get too intimidated by looking at all that, here is the simplest possible program to start you out, with every step explained:
PHP:


Once you get ChucK installed, put that in a .ck file and run it. Now you've made a test tone. :-)
atxbigballer1
Thanks for the cool info man!
MrJiveBoJingles
Found a useful tool. ChucK outputs in mono to a single WAV file by default, but this guy wrote a piece of code that outputs two mono files, one from the left channel and one from the right channel, so if you have a stereo effect all the panning and stuff can be preserved:
PHP:


Just tack this on to the beginning of any of your .ck files, then when you run the program type "filename.ck:left.wav:right.wav".

Here is an example with that piece of code added to a loop mangling program (link to code {not written by me}):

Original loop: http://jbj.raceriv.com/sounds/ChucK/loop1.wav
Mangled: http://jbj.raceriv.com/sounds/ChucK/stereo-loop.mp3
jupiterone
thanks for bringing this to my attention! going to download this and play around with it tomorrow
MrJiveBoJingles
Something a bit more euphonic to play around with:
PHP:


Plays sin waves at intervals of a fifth in different octaves. Nice and stereo with a bit of reverb (denoted by "NRev" at the top). Speeds up, then slows suddenly and loops back around. Octaves are random so it sounds a bit different each loop. Listen:

http://jbj.raceriv.com/sounds/ChucK/beeps.mp3
hexadecimal
can u giv me presets 4 it?

wear do u put sampols?

i nead a trants loop two
MrJiveBoJingles
quote:
Originally posted by hexadecimal
can u giv me presets 4 it? wear do u put sampols? i nead a trants loop two

Nope, you're on your own.

As far as I know Vengeance hasn't coded stuff for ChucK that you can torrent yet. :-D
MrJiveBoJingles
I made a little video showing control of synth settings by mouse movement in ChucK:

http://www.youtube.com/watch?v=u0RhFYfiqak&fmt=18

The mouse's vertical movement controls the gain of a modulating oscillator (mod index) in an FM synth, while the horizontal movement controls the modulating oscillator's frequency. Depressing the mouse button turns the synth on, and releasing it turns it off again. The code used is just one of the example files that you get when you download the program ("examples\hid\mouse-fm.ck"). Incorporating the mouse into more interesting synths should be pretty fun.
hexadecimal
how do u make it sound like "wump wump wump wump", or "boom boom boom clap boom boom"?

MrJiveBoJingles
quote:
Originally posted by hexadecimal
how do u make it sound like "wump wump wump wump", or "boom boom boom clap boom boom"?

You could always try a descending sine oscillator for the "booms" and a noise generator with envelope for the "clap." But it seems like using ChucK just to make standard dance tunes would be rather pointlessly complicated. :-P
alanzo
I looked briefly at CSound but I think I would like ChucK better because it's more like an actual programming language.
CLICK TO RETURN TO TOP OF PAGE
Pages: [1] 2 
Privacy Statement