electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Links  |  Store
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks GalleryGallery 
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » ChucK programming language
Can someone explain...
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [13 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
chuckles



Joined: Apr 02, 2007
Posts: 63
Location: San Diego, California

PostPosted: Wed Oct 31, 2007 12:18 pm    Post subject: Can someone explain... Reply with quote  Mark this post and the followings unread

As I was looking through one of Inventor's files, I noticed that he had this construction

Code:
Impulse i1 => BPF f1 => JCRev r1 => dac;
i1 => BPF f2 => r1 => dac;
i1 => BPF f3 => r1 => dac;
i1 => BPF f4 => r1 => dac;
i1 => BPF f5 => r1 => dac;


I know I should experiment with this and try to figure out what it means in terms of sound, but I would like to ask a ChucK expert if they could explain this to me.

In fact, what would it mean to do something like this:

Code:
Impulse i1 => dac;
i1 => dac;
i1 => dac;


etc.

Is this even meaningful?

Thanks a lot for whatever light you can shed on this,

[and for those of you where it's observed...

HAPPY HALLOWEEN]

Evil or Very Mad
Back to top
View user's profile Send private message
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 6239
Location: The Hague, NL
G2 patch files: 3

PostPosted: Wed Oct 31, 2007 1:49 pm    Post subject: Reply with quote  Mark this post and the followings unread

I'm not sure what you want to know exactly, but what you have there is a single impulse that gets processed by a set of independent filters. After that the whole thing is treated with reverb.

The idea is that BPF's will "ring" to a certain degree after getting "excited" by the impulse so basically you have a set of similar sound sources that all get activated at the same time by the same source to create a sort of "chord" .

Sending the same impulse to the dac multiple times, like in your example, will do the same as having the same signal on a mixer several times (let's disregard effects and eq on mixers here) so that will just result in more volume.

As for how useful doing almost the same thing several times in paralel as compared to the *exact same* thing several times is you can consider for example choirs. Get the nearest girl (asuming your a boy) and sing a simple song with her together or try to hit two pans at the same time using one large wooden spoon (that last example is exactly what we have here).

I could tell you more but I'm not sure exactly what you'd like to know, excuse me if this was trivial.

_________________
while(!machine.crash() ) <<<"all is well">>>;
Back to top
View user's profile Send private message Send e-mail Visit poster's website
chuckles



Joined: Apr 02, 2007
Posts: 63
Location: San Diego, California

PostPosted: Wed Oct 31, 2007 3:03 pm    Post subject: Reply with quote  Mark this post and the followings unread

Thanks Kassen; I knew I would get a quick and thorough answer here. Everything you explained seems to make sense. Maybe I'm making things too complicated. The confusion in my mind I guess would be if instead of the same impulse i1 being fed into the filters/reverbs/dacs, what would be the difference if instead of repetitions of i1 they were replaced with Impulse i2, Impulse i3, etc. That would confuse me if they did exactly the same thing. Using a single Impulse UG i1 would seem to be the more efficient way to go, if so.

A side question would be: is it legal to create an array of Impulse UGs like other UGs?

I hope I am explaining this coherently. And thanks in advance again!
Back to top
View user's profile Send private message
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 6239
Location: The Hague, NL
G2 patch files: 3

PostPosted: Wed Oct 31, 2007 4:09 pm    Post subject: Reply with quote  Mark this post and the followings unread

Well, in a precise and explicit programing language like ChucK when you have two "identical" things they will behave the same way, exactly.

This is different from some digital modulars like for example Clavia's Nord Modular series where using three identical oscillators will give you a fairly complex wave thanks to the engine randomising the phase at which they start. Clavia uses that as it's a realistic emulation of what happens in "real" synths, if you want that sort of behaviour in ChucK you will have to define exactly what sort of behaviour you want, ChucK is (or rather aims to be) very predictable and consistent.

So; using two impulse fired off at the same time and summed yields the *exact* same result as a single one with a gain of 2. Here Inventor used a single one (as well as a single reverb) in order to save the cpu. Obviously one is also easier to control then five.

About arrays; yes you can! To go even further you can have arrays of anything that's a primitive or a object. Maybe things like "dac" and "blackhole" are exceptions but you can, for example, have a array of Events or strings or Impulse Ugens. If you define your own class you can also have a array of instances of that. You can't, however, have a array of functions, those aren't objects.

So; to create a group of line&file soldiers;

Code:
//define a soldier
class soldier
{
string name;

//default name in case we send them to war before giving them one
"john doe" => name;

fun void fire()
  {
  <<<"boom!">>>;
  }
}

//a small army in rank and file
soldier army[10][10];

//have them all fire!
for (0 => int n; n<10; n++)
    {
    for (0 => int m; m< 10; m++)
      {
      army[n][m].fire();
      }
    }


See? you can have arrays of anything and when you have a lot of objects (like a 100) it's quite convenient. Doing the same thing by hand and without classes would literally take you 100's of lines.

_________________
while(!machine.crash() ) <<<"all is well">>>;
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kkissinger



Joined: Mar 28, 2006
Posts: 366
Location: Kansas City, Mo USA
Audio files: 2

PostPosted: Wed Oct 31, 2007 6:08 pm    Post subject: Reply with quote  Mark this post and the followings unread

For years I've known of the story where programmers modified a battle simulation program for use in Australia by reusing an infantryman class to create a kangaroo class.

And, by golly, snopes says it is a TRUE story.

http://www.snopes.com/humor/nonsense/kangaroo.asp

To make a long story short, they included all the infantryman methods in the kangaroo class -- with hilarious results!

Smile

_________________
-- Kevin
http://kevinkissinger.com
http://myspace.com/kkissinger
Back to top
View user's profile Send private message Visit poster's website
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 6239
Location: The Hague, NL
G2 patch files: 3

PostPosted: Wed Oct 31, 2007 6:38 pm    Post subject: Reply with quote  Mark this post and the followings unread

Funny!

Extending the soldier with a .hop() function would be easy enough but then we run into the issue that ChucK lacks a appropriate (ready made) structure to put kangaroos in, that would have to be more like a group , flock or set then like orderly rank&file.

Such a data structure would be quite good for grains as well, perhaps somebody should make one :¬).

I'm strongly opposed to outfitting ChucK with stinger missiles, at least until stability improves. (I wanted a explosion emoticon here but can't find one quickly')

_________________
while(!machine.crash() ) <<<"all is well">>>;
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dewdrop_world



Joined: Aug 28, 2006
Posts: 545
Location: NoVA, USA
Audio files: 2

PostPosted: Wed Oct 31, 2007 7:21 pm    Post subject: Reply with quote  Mark this post and the followings unread



Well, it's sort of an explosion. The kind of thing that's likely to happen if you spend too much time looking at code!

James

_________________
ddw online: http://www.dewdrop-world.net
sc3 online: http://supercollider.sourceforge.net
Back to top
View user's profile Send private message Visit poster's website AIM Address
kijjaz



Joined: Sep 20, 2004
Posts: 452
Location: bangkok, thailand
Audio files: 2

PostPosted: Wed Oct 31, 2007 10:48 pm    Post subject: Reply with quote  Mark this post and the followings unread

One thing we have to consider here..
is that rechucking (chucking a chucked pair of UGens)
like doing r1 => dac; then r1 => dac; later
.. would not do anything.

You can investigate into this patch and see how it performs.
It will show you that rechucking does nothing new.
But using a Gain, we can make a duplicate of a signal and use it as another source to chuck.

Code:
Step one => Gain g1 => blackhole;
1 => one.next;

samp => now; <<< "after time passed," , "" >>>;

<<< "one step : ", one.last() >>>;
<<< "g1       : ", g1.last() >>>;

one => g1;
samp => now; <<< "after rechucking one to g1,", "" >>>;

<<< "g1       : ", g1.last() >>>;

one => Gain duplicate => g1;
samp => now; <<< "after adding a duplicate,", "" >>>;

<<< "g1       : ", g1.last() >>>;

.4 => one.next;
samp => now; <<< "with this method, it'd add the inputs.", "" >>>;

<<< "one =", one.last(), " duplicate =", duplicate.last(), " g1 =", g1.last() >>>;

3 => g1.op;
samp => now; <<< "or with gain option = 3, it'd multiply.", "" >>>;

<<< "one =", one.last(), " duplicate =", duplicate.last(), " g1 =", g1.last() >>>;

// that's all folks!


result:
Code:
after time passed, 
one step :  1.000000
g1       :  1.000000
after rechucking one to g1, 
g1       :  1.000000
after adding a duplicate, 
g1       :  2.000000
with this method, it'd add the inputs. 
one = 0.400000  duplicate = 0.400000  g1 = 0.800000
or with gain option = 3, it'd multiply. 
one = 0.400000  duplicate = 0.400000  g1 = 0.160000
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 6239
Location: The Hague, NL
G2 patch files: 3

PostPosted: Wed Oct 31, 2007 11:05 pm    Post subject: Reply with quote  Mark this post and the followings unread

kijjaz wrote:
One thing we have to consider here..
is that rechucking (chucking a chucked pair of UGens)
like doing r1 => dac; then r1 => dac; later
.. would not do anything.


OOOOOOPS! my fault, thanks for pointing that out.

_________________
while(!machine.crash() ) <<<"all is well">>>;
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Inventor



Joined: Oct 13, 2007
Posts: 1157
Location: Florida, USA
Audio files: 50

PostPosted: Wed Oct 31, 2007 11:37 pm    Post subject: Re: Can someone explain... Reply with quote  Mark this post and the followings unread

chuckles wrote:
As I was looking through one of Inventor's files, I noticed that he had this construction

Code:
Impulse i1 => BPF f1 => JCRev r1 => dac;
i1 => BPF f2 => r1 => dac;
i1 => BPF f3 => r1 => dac;
i1 => BPF f4 => r1 => dac;
i1 => BPF f5 => r1 => dac;


I know I should experiment with this and try to figure out what it means in terms of sound, but I would like to ask a ChucK expert if they could explain this to me.


Hi chuckles, I'm sorry I slept through your post and everyone answered your question! In my own words, I was trying to create harmonics of a plucked bandpass filter. You will notice later in the file that the Q of the filters is very high and their frequency, if I recall correctly, is set to harmonic multiples. So I wanted a single pluck to drive all five filters and being so new to ChucK this is how I did it. Now I know to use arrays for the same thing. Looking back, I'm kind of pleased how the whole sound turned out with those plucked bandpass filters and I may use them again!

Cheers and happy halloween!
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kijjaz



Joined: Sep 20, 2004
Posts: 452
Location: bangkok, thailand
Audio files: 2

PostPosted: Thu Nov 01, 2007 12:40 am    Post subject: Reply with quote  Mark this post and the followings unread

Kassen: Cheers ^_^
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 6239
Location: The Hague, NL
G2 patch files: 3

PostPosted: Thu Nov 01, 2007 1:05 am    Post subject: Reply with quote  Mark this post and the followings unread

Inventor; I'm not sure if you're aware of this already but what you are doing is basically "modal synthesis" and is a known way of emulating struck or plucked objects. What you have is roughly a physical model of a string.

What you can also do is emulate the exact pluck-position by tweaking the relative volume of the BPF's. For example, if you would pluck the string at a third of it's length that would exite the second harmonic (three times the fundamental) more then the others. One of the fun things of the way this way of synthesis works is that it's not at all prone to aliasing.

_________________
while(!machine.crash() ) <<<"all is well">>>;
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Inventor



Joined: Oct 13, 2007
Posts: 1157
Location: Florida, USA
Audio files: 50

PostPosted: Thu Nov 01, 2007 3:44 am    Post subject: Reply with quote  Mark this post and the followings unread

Aha! So it's called modal synthesis, that is good to know. I had not thought of changing the harmonic content in that way either, I must give that a try.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [13 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » ChucK programming language
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
Top Selling Products! CLICK HERE!

Please support our site. If you click through and buy from
our affiliate partners, we earn a small commission.


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003, 2004, 2005, 2006 and 2007 by electro-music.com