Is CSound more powerful than ChucK? // ;-) |
Yes |
|
50% |
[ 4 ] |
No |
|
50% |
[ 4 ] |
|
Total Votes : 8 |
|
Author |
Message |
Stochastic

Joined: Feb 25, 2008 Posts: 45 Location: Vancouver
|
Posted: Thu Sep 11, 2008 9:31 pm Post subject:
Translating CSound pieces to ChucK Subject description: confused about a few of the details |
 |
|
So I'm in a detailed computer synthesis class this semester and the language we're supposed to use is CSound.
ugh.
I know, it's robust, it's stable, yada, yada... I don't like the logical flow of it (can you even write to an array in that language?).
I've presented my critiques of CSound to my prof (Barry Truax) and he's allowed me to use ChucK for the assignments instead if I want. The thing is that he's still teaching the course in CSound, so I'm sitting through the tutorials on GEN routines and foscili stuff anyways. So to keep myself on the same learning curve with ChucK I've decided that I'll go along with the tutorials but translate them into ChucK code instead. This will also help teach Barry chuck so that he's not lost when I hand in my (//well commented) chuck assignments.
As I pondered the first steps to doing this, I'm immediately met with some issues that I'm sure wouldn't be such big issues if I wasn't starting from CSound code/logic flow. So here are my questions to the community:
- Is there any table-lookup means in chuck (I know an array would work for simple functions, but what about the more complex GEN routines such as Chebyshev polynomials)?
- I've started by designing the csound instrument declarations into chuck functions and the csound score file into function calls. Should I be declaring variables outside the functions or inside? If they're declared in the function input parameters will I see garbage buildup after multiple function calls?
- Is there anywhere that I can find a pdf copy of the language specification? (I've got me an e-book reader from sony and Ge's thesis has been my bus fodder, but it regularly points back to the language spec for more info and the thing handles pdf files best)
- Are there any danger flags that I should be weary of when translating csound into chuckian? any potential missing features in the language that I'll run head first into half-way through the semester?
P.S. I know the poll is a silly question with no real answer, but isn't that true of most internet polls? _________________ http://greyrock.blogspot.com |
|
Back to top
|
|
 |
Kassen
Janitor


Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Fri Sep 12, 2008 4:55 am Post subject:
|
 |
|
Wow, this a interesting matter.
As for power; no. Any (valid) wave file that could be created by any process could also be created by either CSound or ChucK. All hail Turing completeness (admittedly Turing completeness means you can sleep soundly knowing it's possible yet will lie awake thinking of *how* it's possible for a infinite number of cases).
*Table lookup; Arrays are your friend if you really need tables. The Gen(n) UGens are functions, as far as I know. I'm not sure why this matters. CSound deals with tables mostly because of CPU constraints in the computers it was originally designed for.
*Garbage; Yes, defining variables in function will lead to garbage. For a few floats and integers this is no big issue; a integer is 32 bits, let's say you can spare a half gig of RAM for ChucK... do the math; that's quite a few garbage variables. There will of course be issues if your garbage consists of large arrays and you are pumping out a few thousand notes per second. What I'd do would be making instruments into classes and have the variables outside of the function yet inside of the class. I'd make a array for every type of instrument and outfit the classes with a variable that keeps track of whether they are in use. If a note is needed I'd loop over the array of voices, taking the fist instance that's "free", if none is to be found I'd grow the array by one.
my_voices_array << new my_instrument;
//don't use .size() here! there is a bug in instantiating the new members currently
//use a explicit "new"
You could also consider using sporked functions and signalled Events, signalling of events pritty much gives you voice cycling for free, though no easy detection for running out of voices. This depends on your design and preferences, I'd go with the classes.
This will mean you won't use any more memory then you need to (at least no more then you need in a system without garbage collection). You'll end up using n voices for every instrument where n is the largest amount of voices ever used at the same time for that instrument. Remember to unchuck unused UGens.
*The manual and Ge's thesis won't do? I think those are the only PDF files, if you need a PDF of the online reference I fear you'll need to make it yourself.
*I'm no CSound expert (I do understand the basics) but I don't think there is anything that will be impossible. CSound's score macro's might be a issue but we have functions, arrays and time as a data type so if push comes to shove you can just emulate all of that. Another issue may be the UGens that Csound has and that we don't.
My bet is that you will end up thinking more and typing less then your fellow students.
Great project, either way your (and Barry Truax's) findings will be interesting, do shout if you get stuck; there are rules about doing anybody else's homework but we're quite good at getting people un-stuck :¬).
Keep on ChucKing! _________________ Kassen |
|
Back to top
|
|
 |
Underwaterbob
Joined: Sep 03, 2008 Posts: 26 Location: Chungju, South Korea
|
Posted: Fri Sep 12, 2008 6:56 am Post subject:
|
 |
|
I think ChucK will only handle your coursework until it grows more complex.
I'm completely biased in this since I've been using ChucK for less than a hundredth of the time I've been using CSound, but there are quite a few more complex tasks relatively easily implemented in CSound that could become a nightmare in ChucK. While ChucK is much more akin to a typical computer programming language, utilizing arrays and robust err.. math, CSound is very focused on functional methods of generating sound. This initially makes CSound seem to be far more verbose than ChucK , but in the long run, more complex, conventional sound synthesis methods will be easier to produce in CSound than ChucK.
By all means give a go. I took a sound synthesis course and instead of using all the different and very specific synthesis apps (7 years old now) I vowed to reproduce every assignment in CSound, was pretty successful and learned more than I can remember about computer generated sound in the meantime.
I think an amalgamation of the two languages would be awesome. I would love to be able to use some of ChucK's math and timing functions in an instrument in CSound. Sounds like a project for someone who knows a lot more about computers than I. |
|
Back to top
|
|
 |
chuckles
Joined: Apr 02, 2007 Posts: 72 Location: San Diego, California
|
Posted: Fri Sep 12, 2008 12:58 pm Post subject:
|
 |
|
(Re the polls): Yes, perhaps, but is Csound more FUN to use than Chuck? (That's a big NO.)
As an early experiments I took a simple Csound instrument to try to convert it to ChucK.
I wrote about it in a blog entry in csound.wordpress.com, "ChucK meets Csound" |
|
Back to top
|
|
 |
Kassen
Janitor


Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Fri Sep 12, 2008 8:19 pm Post subject:
|
 |
|
Underwaterbob wrote: |
I'm completely biased in this since I've been using ChucK for less than a hundredth of the time I've been using CSound, but there are quite a few more complex tasks relatively easily implemented in CSound that could become a nightmare in ChucK. While ChucK is much more akin to a typical computer programming language, utilizing arrays and robust err.. math, CSound is very focused on functional methods of generating sound. This initially makes CSound seem to be far more verbose than ChucK , but in the long run, more complex, conventional sound synthesis methods will be easier to produce in CSound than ChucK.
|
Cool! It's good to see somebody being passionate about their language. Could you name some examples where CSound would do better then ChucK? I'm very up-front about how ChucK changed my thinking about music and sound. To me this has advantages but there might be down-sides. I'd be very interested to hear about situations that would be a nightmare to deal with in ChucK, as you see things. Could you please elaborate? There may well be things I'm missing exactly *because* ChucK changed the way I think about these topics.
To be clear; I think CSound is great. To me CSound represents decades of collaboration of many of the world's experts in digital sound. It's a amazing example of both early open source and digital synthesis but I have to say that on the musical level it's abstractions (as I understood them) aren't mine. _________________ Kassen |
|
Back to top
|
|
 |
Inventor
Stream Operator

Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 267
|
Posted: Fri Sep 12, 2008 10:05 pm Post subject:
|
 |
|
I do not recommend taking a class and also burdening yourself with the translation of all the classwork from one language to another. I've paid my dues, I've done my time (BS EE, MS EE), and college is just way too burdensome without throwing obstacles like that in front of yourself. If the prof is teaching CSound, be a good little student and play along, that's what I'd do. Just my two cents. _________________ "Let's make noise for peace." - Kijjaz |
|
Back to top
|
|
 |
kijjaz

Joined: Sep 20, 2004 Posts: 765 Location: bangkok, thailand
Audio files: 4
|
Posted: Fri Sep 12, 2008 10:39 pm Post subject:
|
 |
|
i'm always amazed at how they combine many tools and generators in Csound..
but i'm still too lazy to dig a lot into csound heheh..
i hope ChucK will be extended much more that i can get that Csound feeling with the power of ChucK soon! |
|
Back to top
|
|
 |
Stochastic

Joined: Feb 25, 2008 Posts: 45 Location: Vancouver
|
Posted: Sat Sep 13, 2008 2:05 am Post subject:
|
 |
|
Kassen wrote: | ... and digital synthesis but I have to say that on the musical level it's abstractions (as I understood them) aren't mine. |
meh, heh, heh, heh, heh, heh, heh, heh, heh, heh, heh, heh, heh, heh, heh, heh, heh, heh, heh, heh, heh, heh, heh, heh, heh, heh, heh, heh, heh, heh, heh, heh, heh, heh, heh, heh, heh, heh, heh, me too.
But seriously, CSound adds a good ten opcodes (or UGens - in chuckian) every update. CSound is a ROBUST language. ChucK lacks the pre-built functions. It's algorithmic possibilities are much larger - I'm still waiting for some CSound enthusiast to explain how I would emulate this bit of ChucK code in a CSound implementation: Code: | float markovChainWeights[ [ [ 4.23, 1.07, 8.1 ], [ 2.18, 1.62, 1.13 ], [ 1.26, 1.00, 0.61 ] ], [ [ 7.29, 3.85, 1.68 ], [ 3.54, 0.64, 0.11 ], [ 0.11, 0.43, 0.75 ] ], [ [ 0.37, 0.946, 0.18 ], [ 3.27, 3.27, 0.03 ], [ 1.36, 1.57, 1.63 ] ] ]; | I'd rather not have to write out the markov chain logic on this, but you get the idea...
Although that whole "I'd rather not have to write out the {logic formation here} on this" is a massive argument that CSounders raise again and again. Though in theory, because both languages are GPL (aren't they?) then they could easily borrow/take from one another.
P.S. as for the academic honesty / solving my homework, subject is concerned, I will be very explicit if I were to be asking for advice (//unsticking) on such a topic - these are merely class tutorials I'm following along with for now. _________________ http://greyrock.blogspot.com |
|
Back to top
|
|
 |
Kassen
Janitor


Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Sat Sep 13, 2008 4:46 am Post subject:
|
 |
|
Stochastic wrote: |
Although that whole "I'd rather not have to write out the {logic formation here} on this" is a massive argument that CSounders raise again and again. |
Well, there's no need to write anything out but I would like to hear some examples of things that are easy in CSound yet would be "a nightmare" in ChucK, I'm simply curious what that was in reference to.
Quote: | Though in theory, because both languages are GPL (aren't they?) then they could easily borrow/take from one another. |
Yes, but I think the syntax is so different that the main thing to share would be UGens/Opcodes.
Quote: |
P.S. as for the academic honesty / solving my homework, subject is concerned, I will be very explicit if I were to be asking for advice (//unsticking) on such a topic - these are merely class tutorials I'm following along with for now. |
I'm sure all will be fine and I don't doubt your honesty. I'd just like the forum to work with classes and not against them :¬) _________________ Kassen |
|
Back to top
|
|
 |
Underwaterbob
Joined: Sep 03, 2008 Posts: 26 Location: Chungju, South Korea
|
Posted: Sat Sep 13, 2008 7:50 am Post subject:
|
 |
|
Things that might be more difficult to do in ChucK... an example:
GEN19 in CSound allows me to create a wave function with any number of harmonics and non-harmonic partials and control their strength, relative phase and DC offset in one line of code. To do the same in ChucK would require defining a lot of different sinusoids; their phase, amplitude and gain; and some mathematical manipulation to get the DC offset. Suppose you want an instrument with four different functions like this each with 20 harmonics. CSound could define the four functions with four (fairly long) lines of code. In Chuck you would have to define 80 different oscillators
As far as I know, is there a UGen in ChucK that lets you define the waveform according to it's harmonic series?
CSound has physical modeling opcodes (wgpluck, marimba), formant generators, audio analysis and manipulation (vocoding, harmon opcode), extensive granular synthesis opcodes, Butterworth filters and some other things I think would require quite a bit more code in ChucK (though not impossible) to reproduce.
I think both languages could benefit immensely from each other. CSound code syntax is severely dated and the amalgamation of the orc and sco files with CSound 5 if anything, made it worse (IMO). Learning ChucK has made me a better CSound programmer. I have always been coming at sound synthesis from a CSound approach, but ChucK has shown me there are other ways to do things. |
|
Back to top
|
|
 |
radarsat1
Joined: Mar 14, 2008 Posts: 85 Location: Montreal
|
Posted: Sat Sep 13, 2008 11:42 am Post subject:
|
 |
|
Underwaterbob wrote: |
As far as I know, is there a UGen in ChucK that lets you define the waveform according to it's harmonic series? |
perhaps the GenX or Blit ugens are what you are looking for?
Quote: | CSound has physical modeling opcodes (wgpluck, marimba), formant generators, audio analysis and manipulation (vocoding, harmon opcode), extensive granular synthesis opcodes, Butterworth filters and some other things I think would require quite a bit more code in ChucK (though not impossible) to reproduce. |
A lot of these would be awesome to port to chuck. We gotta make unit generators easier to code..
Things like filter calculations can be expressed in chuck code, but it would certainly be nice to have them wrapped up and available by default. Same goes for vocoding (using uanas). Granular synthesis I think is one of the more entertaining things to do with Chuck. |
|
Back to top
|
|
 |
dewdrop_world

Joined: Aug 28, 2006 Posts: 858 Location: Guangzhou, China
Audio files: 4
|
Posted: Sat Sep 13, 2008 12:53 pm Post subject:
|
 |
|
Well, I know this is a chuck thread, but a bit of supercollider-ism might be entertaining.
Underwaterbob wrote: | GEN19 in CSound allows me to create a wave function with any number of harmonics and non-harmonic partials and control their strength, relative phase and DC offset in one line of code. To do the same in ChucK would require defining a lot of different sinusoids; their phase, amplitude and gain; and some mathematical manipulation to get the DC offset. Suppose you want an instrument with four different functions like this each with 20 harmonics. CSound could define the four functions with four (fairly long) lines of code. In Chuck you would have to define 80 different oscillators |
Without the DC offset, this is a one-liner in SC -- either by wavetable buffer or the Klang ugen. DC offset... actually that could be a one-liner too, thanks to multichannel expansion. SinOsc.ar(freqArray, phaseArray, ampArray, dcOffsetArray).sum If you're not modulating the parms, FSinOsc is more cpu-friendly.
Quote: | As far as I know, is there a UGen in ChucK that lets you define the waveform according to it's harmonic series? |
SC, yes, easy.
Quote: | CSound has physical modeling opcodes (wgpluck, marimba), formant generators, audio analysis and manipulation (vocoding, harmon opcode), extensive granular synthesis opcodes, Butterworth filters and some other things I think would require quite a bit more code in ChucK (though not impossible) to reproduce. |
In SC, Butterworth filters and granular synthesis ugens are standard. Physical modeling is less well developed. The frequency domain side is improving but csound's history makes it more powerful here than probably any other tool.
Quote: | CSound code syntax is severely dated and the amalgamation of the orc and sco files with CSound 5 if anything, made it worse (IMO). |
Since my interests are realtime generative work, it's hard to imagine how to bend csound to my will. If I weren't using SC, I'd be using ChucK.
James _________________ ddw online: http://www.dewdrop-world.net
sc3 online: http://supercollider.sourceforge.net |
|
Back to top
|
|
 |
Kassen
Janitor


Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Sat Sep 13, 2008 5:12 pm Post subject:
|
 |
|
Underwaterbob wrote: |
GEN19 in CSound allows me to create a wave function with any number of harmonics and non-harmonic partials and control their strength, relative phase and DC offset in one line of code. To do the same in ChucK would require defining a lot of different sinusoids; their phase, amplitude and gain; and some mathematical manipulation to get the DC offset. Suppose you want an instrument with four different functions like this each with 20 harmonics. CSound could define the four functions with four (fairly long) lines of code. In Chuck you would have to define 80 different oscillators
|
I think that for this I'd use the ifft UGen and supply it with a manually generated spectrum array. That would be about two lines in addition to however much space the definition of the amplitudes and phases would take.
We do have ChucK ports of Gen 10 and 17, which seem somewhat similar to me.
I wouldn't call defining 80 oscillators a big task, by the way, I'd simply go;
Code: |
SinOsc my_sines[80]; |
Let's say we have a array of type float that holds a list of frequencies and amplitudes, first a frequency, then a amplitude, and so on, let's call it "foo[]"
Code: |
[lots, of, numbers, etc] @=> float foo[];
Gain mixer => dac;
for(int n; n< foo.cap(); 2+=> n)
{
SinOsc s => mixer;
foo[n] => s.freq;
foo[n+1] => sgain;
} |
There you go. You can add phase if you'd like. Not as elegant as a single UGen/ Opcode but far from a "nightmare". I'd personally still use ifft for simplicity but that would give some rounding errors in frequency due to the limited number of bands.
Quote: |
As far as I know, is there a UGen in ChucK that lets you define the waveform according to it's harmonic series? |
If harmonics will do then In think Gen 10 and 17 would be it?
Quote: | CSound has physical modeling opcodes (wgpluck, marimba), |
We have some of those thanks to the STK, I'm sure there is a pluck and fairly sure there's a marimba somewhere.
Quote: | formant generators, |
There is some vocal synthesis in ChucK, thanks to Perry Cook's work. It's limited for true speech but I think a more elaborate version is in the works. If push came to shove I might use some parallel BiQuad's for this.
Quote: | audio analysis and manipulation (vocoding, harmon opcode), |
While it's a fairly recent development I do think ChucK's take on audio analysis and manipulations on this data is quite powerful. We could use more analysers and the ones that are there could stand some more documentation. There is a good paper on this here; http://soundlab.cs.princeton.edu/publications/uana_icmc2007.pdf
Quote: |
extensive granular synthesis opcodes, |
While not "extensive" I think LiSa serves quite well for this task. LiSa does lack some features for "windowing" grains as it will only ramp up and down linearly.
Quote: |
Butterworth filters and some other things I think would require quite a bit more code in ChucK (though not impossible) to reproduce.
|
The LPF UGen is a second order Butterworth filter, making that type of filter one of the easiest to use in ChucK. Generally any IIR filter you might need can be used, assuming you supply a function to calculate the coefficients.
None of these sound very hard to me to implement at all, certainly no "nightmare" (unless I have to do Z-transform stuff for the filter coeficients myself....). I have to say that CSound's list of Opcodes is enviable, quite possibly it's one of the largest resources in all of digital electronic music. However the idea of building more complicated structures out of smaller building blocks also appeals to me a lot. This leads to more detailed control and even if I would end up copying the exact functionality of a CSound Opcode I could still give it a interface (in member functions) that conforms to how I'd like to use this structure.
Quote: | I think both languages could benefit immensely from each other. CSound code syntax is severely dated and the amalgamation of the orc and sco files with CSound 5 if anything, made it worse (IMO). Learning ChucK has made me a better CSound programmer. I have always been coming at sound synthesis from a CSound approach, but ChucK has shown me there are other ways to do things. |
Absolutely. I'd like to make it clear that I didn't reply to your post point by point to "compete" with you; I meant to illustrate how you might do certain things in ChucK and perhaps point out some features you may have missed.
BTW, when I sometimes write non-interactive programs/pieces to render audio (for example sound design work) I often end up with a structure of "instruments" and a "score" that's not at all unlike what one would do in CSound. Typically to me writing ChucK never results in nightmarish structures though like with any program planning can take time and effort. Some things are simply very hard, like -say- the analysis and pattern recognition of incoming audio but that's a hard task anywhere, no nightmare, in fact quite a enjoyable challenge but still hard. _________________ Kassen Last edited by Kassen on Sat Sep 13, 2008 5:36 pm; edited 1 time in total |
|
Back to top
|
|
 |
Kassen
Janitor


Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Sat Sep 13, 2008 5:34 pm Post subject:
|
 |
|
dewdrop_world wrote: | Well, I know this is a chuck thread, but a bit of supercollider-ism might be entertaining. |
Absolutely. I think it's always interesting to see what things are easy and which ones are hard in various languages. I of course like to keep a eye on the debates in the CS world (and of course keep my CSound book at hand at times!)
Quote: |
Physical modeling is less well developed. The frequency domain side is improving but csound's history makes it more powerful here than probably any other tool.
|
I would imagine SC might be very well suited for modal synthesis? That might actually be my pick for arbitrary physical models in ChucK as well, if push came to shove.
Quote: |
Since my interests are realtime generative work, it's hard to imagine how to bend csound to my will. If I weren't using SC, I'd be using ChucK.
|
Yes, for me as well (if I can swap SC and CK here). Right now I'm mainly interested in realtime performance, particularly live improvisation. In the past years I spend too much time on my own minutely tweaking prepared pieces only to find that when it came to playing them back before a audience they didn't quite conform to what I wanted to communicate to that audience at that time (and how could they?). While some people have been very right to point out weak-spots in ChucK I do feel that (at least for me) ChucK is very well suited for this for of performance. Another factor is that I experience the syntax as very expressive for my purposes right now. With CSound it's a bit hit and miss, for some things I have found CSound's syntax very expressive, in the hands of a master it can read like a novel or poem but at other moments I've felt it seemed slightly "clumsy" and indeed a bit dated. Of course you can write clumsy code in ChucK as well, I know I do when my thoughts haven't yet formed :¬). Still, whenever I feel CSound looks dated I remember this is partially because it wants (needs?) to be compatible with pieces written decades ago, pieces we can still render to enjoy on modern DAC's in perfect quality, something no other set of pieces that age can lay claim to. This is quite beautiful to me. Another thing is that CSound is a truly inspiring example of a open source project, I'd be hard pressed to name a better one. _________________ Kassen |
|
Back to top
|
|
 |
Stochastic

Joined: Feb 25, 2008 Posts: 45 Location: Vancouver
|
Posted: Sun Sep 14, 2008 3:02 pm Post subject:
|
 |
|
Kassen wrote: | I wouldn't call defining 80 oscillators a big task, by the way, I'd simply go;
Code: |
SinOsc my_sines[80]; |
|
Wow, nice little trick - that totally didn't cross my mind that an array could be made of ugens. If that array is chucked to the dac are all 80 connected in one line of code? Could the gain of them all be defined by Code: | 0.5=>my_sines[].gain; |
As I ponder this subject more, I am beginning to think ChucK is easier to read than CSound, as when parameters are set there is a declaration statement of what the parameter is (i.e. sine.freq or sine.gain) rather than a mere comma (or whitespace depending on whether its in the orc or sco file - these inconsistencies annoy me too). SC also lacks these explicit parameter declarations from what I've seen of the language (am I wrong?). This is a major pedagogical leap forward, as code tutorials read much more like pseudo-code than lists of numbers and braces.
But some stealing of CSound UGens into Chuck would be something to consider - not that it's essential, but it'd be nice. _________________ http://greyrock.blogspot.com |
|
Back to top
|
|
 |
renderful

Joined: Apr 18, 2007 Posts: 29 Location: Boulder, Co
|
Posted: Sun Sep 14, 2008 5:33 pm Post subject:
|
 |
|
Stochastic wrote: |
Code: |
SinOsc my_sines[80]; |
Wow, nice little trick - that totally didn't cross my mind that an array could be made of ugens. If that array is chucked to the dac are all 80 connected in one line of code? Could the gain of them all be defined by Code: | 0.5=>my_sines[].gain; |
|
I couldn't get that going, but I did get something only slightly longer and more obvious working:
Code: |
SinOsc my_sines[80];
while (true) {
for( 0 => int foo; foo < 79 ; foo++ )
{
my_sines[foo] => dac;
Math.rand2(440, 4400) => my_sines[foo].sfreq;
1::samp => now;
}
1::second => now;
}
|
|
|
Back to top
|
|
 |
renderful

Joined: Apr 18, 2007 Posts: 29 Location: Boulder, Co
|
Posted: Sun Sep 14, 2008 6:00 pm Post subject:
|
 |
|
The above revised with Array.cap(), SawOsc and timing changed:
Code: |
SawOsc my_saws[80];
while (true) {
for(0 => int foo; foo <= my_saws.cap(); foo++)
{
my_saws[Math.rand2(0, 79)] => dac;
Math.rand2(440, 4400) => my_saws[foo].sfreq;
5000::samp => now;
}
1::second => now;
}
|
|
|
Back to top
|
|
 |
Antimon
Joined: Jan 18, 2005 Posts: 4145 Location: Sweden
Audio files: 371
G2 patch files: 100
|
Posted: Mon Sep 15, 2008 2:14 am Post subject:
|
 |
|
Er...
Code: | my_saws[Math.rand2(0, 79)] => dac; |
looks interesting, but the old version looked a bit more... rational. This new version will take a random subset of my_saws and connect it to dac, if I read correctly (I think chucking something twice isn't different from chucking once, am I correct?)
/Stefan _________________ Antimon's Window
@soundcloud @Flattr home - you can't explain music |
|
Back to top
|
|
 |
Kassen
Janitor


Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Mon Sep 15, 2008 5:38 am Post subject:
|
 |
|
Stochastic wrote: |
Wow, nice little trick - that totally didn't cross my mind that an array could be made of ugens. |
Yes, you can. You can make arrays of any type of object, including Shreds and including object types you defined yourself (as a class). If you would find yourself writing monotonous code (like 80 lines of defining SinOsc's) it's typically time to go up one level and involve arrays, functions and/or classes. These are more advanced techniques but they mean fewer lines to type, fewer lines to change when you want a update and so fewer typo's and bugs.
CSound and ChucK are very different systems and for more complicated structures like some of these examples you should probably use ChucK as the OOP language that it is and not in a way similar to how you'd use CSound. If you were to do that then yes; nightmares may follow soon after because ChucK lacks CSound's way of dealing with these matters (in this case a huge set of Opcodes) and instead has other methods (building larger structures out of smaller ones, then stacking those up until we have the structure we need).
I think Renderful covered how to connect arrays to the DAC and set their parameters nicely.
SC, BTW, can do things to arrays in one swoop in one line, you could call that syntactic sugar but to me it looks like nice syntactic sugar.
Quote: | As I ponder this subject more, I am beginning to think ChucK is easier to read than CSound, as when parameters are set there is a declaration statement of what the parameter is (i.e. sine.freq or sine.gain) rather than a mere comma (or whitespace depending on whether its in the orc or sco file - these inconsistencies annoy me too). |
Yes, I agree. To me this is a big deal as I tend to have trouble remembering "random" data. If I were to meet you, then talk for a evening I may well have forgotten your name the next week but still remember everything we talked about. I've wondered whether that may be related to my dyslexia. For me that makes CK a lot more usable then CS or SC; when I see those huge lists of numbers I tend to have trouble remembering their meaning.
Quote: | SC also lacks these explicit parameter declarations from what I've seen of the language (am I wrong?). |
James did give some examples of SC usage that seemed quite explicit to me, those were slightly more verbose then typical SC code but I think you could do it in many cases. James?
Quote: | This is a major pedagogical leap forward, as code tutorials read much more like pseudo-code than lists of numbers and braces. |
Yes, and that was exactly the plan. CK is supposed to be accessible as a first programming language, even if it's also a first introduction into working with sound/music. Fortunately that doesn't mean there is nothing to be had for experts in both fields; if you don't mind the CPU strain it's also well suited for writing straight DSP directly, at the very least that would have advantages in prototyping.
Quote: | But some stealing of CSound UGens into Chuck would be something to consider - not that it's essential, but it'd be nice. |
Yes, I'd like that. That wouldn't be "stealing" though. Many CSound Opcodes were first implemented as a way to illustrate a new technique somebody discovered, this goes back all the way to the dawn of FM, probably Karplus-Strong as well. Some techniques were published that way with the express intention of being used elsewhere; CSound is open/free for a reason. We could and probably should borrow more, I'd like some of SC's UGen's as well :¬). _________________ Kassen |
|
Back to top
|
|
 |
renderful

Joined: Apr 18, 2007 Posts: 29 Location: Boulder, Co
|
Posted: Mon Sep 15, 2008 8:49 am Post subject:
|
 |
|
Antimon wrote: | Er...
Code: | my_saws[Math.rand2(0, 79)] => dac; |
looks interesting, but the old version looked a bit more... rational. This new version will take a random subset of my_saws and connect it to dac, if I read correctly (I think chucking something twice isn't different from chucking once, am I correct?)
/Stefan |
Nice.
I realized the over-chucking error on my walk to work this morning. Is it any different? Seems like I should keep that my_saws[] => dac loops separate from the frequencing modding loop. |
|
Back to top
|
|
 |
Kassen
Janitor


Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Mon Sep 15, 2008 9:55 am Post subject:
|
 |
|
Yes. Over (or "double") chucking is once again relevant. It results in two connections, meaning twice the volume. This is useful in chucking to a Gain set to multiply where it will square the signal (as it gets multiplied by itself).
There is a bug in this though as double connections to the dac aren't properly cleaned up right now.
Please do note that this feature was once again added with the latest version of ChucK (1.2.1.2) and that the canonical version of the Mini doesn't use the latest version of the VM yet so if you're chucking in the Mini then right now double-chucking doesn't do anything after the first connection.
Confused yet? ;¬) _________________ Kassen |
|
Back to top
|
|
 |
radarsat1
Joined: Mar 14, 2008 Posts: 85 Location: Montreal
|
Posted: Mon Sep 15, 2008 11:40 am Post subject:
|
 |
|
renderful wrote: | I realized the over-chucking error on my walk to work this morning. |
That's pretty impressive. I don't suggest chucking while driving, of course. |
|
Back to top
|
|
 |
Kassen
Janitor


Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Mon Sep 15, 2008 1:03 pm Post subject:
|
 |
|
Quote: | If you cannot grok the overall structure of a program while taking a shower, e.g., with no external memory aids, you are not ready to code it. ~Richard Pattis |
_________________ Kassen |
|
Back to top
|
|
 |
renderful

Joined: Apr 18, 2007 Posts: 29 Location: Boulder, Co
|
Posted: Mon Sep 15, 2008 6:25 pm Post subject:
|
 |
|
Antimon wrote: | Er...
Code: | my_saws[Math.rand2(0, 79)] => dac; |
looks interesting, but the old version looked a bit more... rational. This new version will take a random subset of my_saws and connect it to dac, if I read correctly (I think chucking something twice isn't different from chucking once, am I correct?)
/Stefan |
Heh, the random ChucKing was an experiment which ended up on the forum.
A more rational, interesting sounding(only slightly modified) version:
Code: |
SawOsc my_saws[80];
while (true) {
for(0 => int foo; foo < my_saws.cap(); foo++)
{
my_saws[foo] => dac;
Math.rand2(220, 880) => my_saws[foo].sfreq;
5000::samp => now;
}
20::second => now;
}
|
|
|
Back to top
|
|
 |
rogan

Joined: Dec 16, 2007 Posts: 83 Location: Urbana, IL
Audio files: 5
|
Posted: Mon Sep 15, 2008 7:37 pm Post subject:
|
 |
|
As a grad student, I'm going to second what Inventor said, for probably the same reasons . If you're going to take this class, do the homework in the language that the class is using. It'll save you a lot of time, plus you'll actually be able to talk to others in the class about your work. You have plenty of time to use Chuck after you've learned the basic theory from this class.
I actually still use the big CSound book, and port various things to Chuck. The only difference for me seems to be doing math, for example:
Code: | krate = 0.5 * krate2 |
, which can be done using gains, and the conversion of tables (talked about above) to not-tables.... Which, actually, leads me to a question: How do people do exponential envelopes? The Envelope UGen only does linear transitions. Do people code the exponential math in by hand, ie.
Code: |
math.exp(i) => something.gain;
|
? |
|
Back to top
|
|
 |
|