electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links  |  Store
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
Live streaming at radio.electro-music.com

  host / artist show at your time
  Jez Adventures in Sound
Please visit the chat
 Forum index » DIY Hardware and Software » ChucK programming language
Playing with Dynamic Array
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [10 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
kijjaz



Joined: Sep 20, 2004
Posts: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Tue Jul 22, 2008 4:17 pm    Post subject: Playing with Dynamic Array Reply with quote  Mark this post and the followings unread

As I'm getting very interested in using the new ChucK 1.2.1.2's dynamic array feature especially for building more complex data structures,
I've started this topic so we can share about this feature.

Today, I'm try adding array members:

Code:
int a[0][0]; // start with a blank a[][]
<<< "int a[0][0];", "" >>>;

a << [1] << [2, 3]; // add [1] and [2, 3] to a
<<< "a << [1] << [2];", "" >>>;

a[1] << 4; // add 4 to a[1][1]
<<< "a[1][1] << 4;", "" >>>;

<<< "a.size(): ", a.size() >>>;
<<< "a[0].size(): ", a[0].size(), " a[1].size(): ", a[1].size() >>>;
<<< "a[0][0]:", a[0][0] >>>;
<<< "a[1][0]:", a[1][0] >>>;
<<< "a[1][1]:", a[1][1] >>>;
<<< "a[1][2]:", a[1][2] >>>;


From the code, we start with a[0][0]
and after adding [1] and [2, 3] to a
we have a[0] and a[1] that each has different size,
so actually we have just grown a tree with different number of leaves between different branches.

This is such a nice thing we can do in ChucK!
. . .

Feel free to share more about arrays.
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
ilSignorCarlo



Joined: Sep 17, 2007
Posts: 28
Location: Bologna

PostPosted: Thu Jul 24, 2008 6:07 am    Post subject: Re: Playing with Dynamic Array Reply with quote  Mark this post and the followings unread

kijjaz wrote:

Code:
int a[0][0]; // start with a blank a[][]
<<< "int a[0][0];", "" >>>;

a << [1] << [2, 3]; // add [1] and [2, 3] to a
<<< "a << [1] << [2];", "" >>>;

a[1] << 4; // add 4 to a[1][1]
<<< "a[1][1] << 4;", "" >>>;

<<< "a.size(): ", a.size() >>>;
<<< "a[0].size(): ", a[0].size(), " a[1].size(): ", a[1].size() >>>;
<<< "a[0][0]:", a[0][0] >>>;
<<< "a[1][0]:", a[1][0] >>>;
<<< "a[1][1]:", a[1][1] >>>;
<<< "a[1][2]:", a[1][2] >>>;


I don't know if it is normal, but on Windows I can't run this code inside MiniAudicle. I get this error:

[unnamed1]:line(4): cannot resolve operator '<<' on types 'int[][]' and 'int[]'

Anyway, it works fine from the shell.

_________________
Self-referential phrases, like this one, are not so funny or good for a forum signature.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
kijjaz



Joined: Sep 20, 2004
Posts: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Thu Jul 24, 2008 9:49 am    Post subject: Reply with quote  Mark this post and the followings unread

Oh.. the operator << (add new member to the array, thus increase that array size by 1) ..
is a new feature in ChucK 1.2.1.2..
but current miniAudicle on the website has ChucK 1.2.1.1.

I was compiling miniAudicle but replacing the whole chuck source code with 1.2.1.2 so I can run 1.2.1.2-compatible code in miniAudicle.

So I guess, for you, if you still don't compile miniAudicle for windows,
you might have to try this with command-line 1.2.1.2 ChucK for now.
I hope we'll have the new miniAudicle executable up at ChucK's web soon.
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: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Thu Jul 24, 2008 5:08 pm    Post subject: Reply with quote  Mark this post and the followings unread

kijjaz wrote:

I was compiling miniAudicle but replacing the whole chuck source code with 1.2.1.2 so I can run 1.2.1.2-compatible code in miniAudicle.


Does that work like that?

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kijjaz



Joined: Sep 20, 2004
Posts: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Thu Jul 24, 2008 7:02 pm    Post subject: Reply with quote  Mark this post and the followings unread

Yes. It simply works right away. I was compiling in Linux.
First, I extracted miniAudicle source,
then delete all files in chuck-1.2.1.1,
and repleace with ones from chuck-1.2.1.2's sourcecode package,
then compile.

THe Help -> About also shows the correct ChucK version.
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
kijjaz



Joined: Sep 20, 2004
Posts: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Thu Jul 24, 2008 7:27 pm    Post subject: Reply with quote  Mark this post and the followings unread

This is one thing I tried with dynamic array:
It might become quite useful and easy.
It's adding members to 2D array,
and the good thing is that...

for example if we have int A[4][0];
each A[i] is independently sizable.
so by this, we can create more flexible tree structure array.

an easy example:
Code:
int melody[0][0]; // new melody buffer

for(int i; i < 10; i++)
{
    melody << [0];
    // increase melody size for a set of new members

    // add more members
    for(int j; j < Std.rand2(3, 12); j++)
    {
        melody[i] << Std.rand2(0, 12); // add new note
    }
}

Flute s => dac;
for(int i; i < 10; i++)
{
    for(1 => int j; j < melody[i].size(); j++) // skip the first member '0'
    {
        melody[i][j] + 60 => Std.mtof => s.freq;
        .2 => s.noteOn;
        150::ms => now;
        .2 => s.noteOff;
    }
    second => now;
}
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
waldemaR



Joined: Feb 08, 2009
Posts: 14
Location: düsseldorf, germany

PostPosted: Thu Feb 26, 2009 1:11 pm    Post subject: Reply with quote  Mark this post and the followings unread

dear all,

i have same problem but with the command line.
error message:
[jogi_ClComboBox.ck]:line(87): cannot resolve operator '<<' on types 'ComboBoxEntry[]' and 'ComboBoxEntry'
i have download the file from the thread:
http://electro-music.com/forum/viewtopic.php?highlight=jogi&t=29736
and the jogi_ClComboBox.ck make the error.

any idea or help is appreciate, thank you.

waldemaR
Back to top
View user's profile Send private message Visit poster's website
waldemaR



Joined: Feb 08, 2009
Posts: 14
Location: düsseldorf, germany

PostPosted: Fri Feb 27, 2009 1:21 pm    Post subject: operator '<<'
Subject description: chuck binary
Reply with quote  Mark this post and the followings unread

i wonder why it works on my laptop and not on my pc.
we are talking about two different binaries, one is the latest and the other is from here. i used them because my rme fireface 400 soundcard don't work with the original. but the new one don't know the operator. i attach both binaries.

the chuck_no_function.exe is the latest original from chuck, rme don't work operator work.

the chuck_function.exe is from:
http://electro-music.com/forum/topic-18931.html
rme work, operator not.

please can anyone check this problem, thank you.

waldemaR


chuck_function.rar
 Description:

Download
 Filename:  chuck_function.rar
 Filesize:  984.99 KB
 Downloaded:  120 Time(s)

Back to top
View user's profile Send private message Visit poster's website
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 5978
Location: San Antonio, Tx, USA
Audio files: 258

PostPosted: Fri Feb 27, 2009 9:50 pm    Post subject: Reply with quote  Mark this post and the followings unread

I have not yet found a need for this feature but I like the fact that we can make tree structures out of arrays. I'm sure there are fascinating things that we can do now that were not possible or practical before.
_________________
"Let's make noise for peace." - Kijjaz
Back to top
View user's profile Send private message Send e-mail
waldemaR



Joined: Feb 08, 2009
Posts: 14
Location: düsseldorf, germany

PostPosted: Sat Feb 28, 2009 4:19 am    Post subject: jogi Reply with quote  Mark this post and the followings unread

jogi is for me helpful to learn chuck that's my reason, why.

waldemaR
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [10 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
AmbiphonicDSP

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 through 2009 by electro-music.com - Conditions Of Use