electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links
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 
go to the radio page Live at electro-music.com radio 1 Please visit the chat
poster
 Forum index » DIY Hardware and Software » ChucK programming language
annoying exception - associative array
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [6 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
fraukefroehlich



Joined: May 11, 2007
Posts: 22
Location: home
Audio files: 1

PostPosted: Wed Jun 04, 2008 10:41 pm    Post subject:  annoying exception - associative array Reply with quote  Mark this post and the followings unread

hi there...

since i've lost hours dealing with this issue and i didn't get any further, i decided ask for help...

i tried the following code:
Code:

//initializing lengths
"v" => string v; //quarter note
"a" => string a; //eighth note
"s" => string s; //sixteenth note

string noteDurations[]; //durations of a given music composition
int markov[][]; //the array holding the markov chain

[s,s,a,s,v/*....etc.*/] @=> noteDurations;

for(0 => int i; i < noteDurations.cap() - 2; i++){
   
    noteDurations[i] + noteDurations[i+1] => string pre;
    noteDurations[i+2] => string post;

    markov[pre][post] => int tmp;
    tmp + 1 @=> markov[pre][post];
   
}

now what i try to do is building a markov chain from the durations of a given music composition.

a markov chain (of second order in this case) determines which notelength comes next, regarding the two predecessors...
i. e.:

the array notedurations says: index 0 and index 1 are "ss" (predecessors) to which follows an "a" (successor). since this is the only successor for those predecessors in my music composition, the probability for this relation is 100%. that just means, if "ss" is recognized, an "a" has to be thrown next, etc.

ok, tried to solve this with an associative array, but it throws the following exception:
Code:
[chuck](VM): sporking incoming shred: 1 (exception.ck)...
[chuck]:(10:ALL!!): adding 'Chuck_Object' (0x189be370)...
[chuck]:(10:ALL!!): adding 'Chuck_String' (0x189be370)...
[chuck]:(10:ALL!!): adding 'Chuck_Object' (0x189d1190)...
[chuck]:(10:ALL!!): adding 'Chuck_String' (0x189d1190)...
[chuck]:(10:ALL!!): adding 'Chuck_Object' (0x189b7540)...
[chuck]:(10:ALL!!): adding 'Chuck_String' (0x189b7540)...
[chuck]:(10:ALL!!): adding 'Chuck_Object' (0x189b7840)...
[chuck]:(10:ALL!!): adding 'Chuck_Array4' (0x189b7840)...
[chuck]:(10:ALL!!): adding 'Chuck_Object' (0x189b78c0)...
[chuck]:(10:ALL!!): adding 'Chuck_Object' (0x189b7940)...
[chuck]:(10:ALL!!): adding 'Chuck_String' (0x189b7940)...
[chuck]:(10:ALL!!): adding 'Chuck_Object' (0x189b79b0)...
[chuck]:(10:ALL!!): adding 'Chuck_String' (0x189b79b0)...
[chuck](VM): NullPointerException: (array access) in shred[id=1:exception.ck], PC=[64]
[chuck](VM): (array dimension where exception occurred: 0)
[chuck]:(8:FINER!): dumping shred (id==1 | ptr==0x189b7770)
[chuck]:(8:FINER!): releasing dumped shreds...
[chuck]:(9:FINEST): freeing 'Chuck_VM_Shred' (0x189b7770)...

any ideas?
thx
Back to top
View user's profile Send private message
Frostburn



Joined: Dec 12, 2007
Posts: 255
Location: Finland
Audio files: 9

PostPosted: Thu Jun 05, 2008 1:06 am    Post subject: Reply with quote  Mark this post and the followings unread

First I thought the problem was that you didn't initialize the array properly but it seems that multidimensional arrays are broken at the moment...
Code:
int aa[0][0]; //Dimensions need to be specified
3 => aa["Chuck"]["Norris"]; //Crash & Burn...

_________________
To boldly go where no man has bothered to go before.
Back to top
View user's profile Send private message
fraukefroehlich



Joined: May 11, 2007
Posts: 22
Location: home
Audio files: 1

PostPosted: Thu Jun 05, 2008 1:21 am    Post subject: Reply with quote  Mark this post and the followings unread

Frostburn wrote:
...but it seems that multidimensional arrays are broken at the moment...

... which means...?
Back to top
View user's profile Send private message
Frostburn



Joined: Dec 12, 2007
Posts: 255
Location: Finland
Audio files: 9

PostPosted: Thu Jun 05, 2008 2:13 am    Post subject: Reply with quote  Mark this post and the followings unread

I'm afraid it's a bug and doesn't work.
_________________
To boldly go where no man has bothered to go before.
Back to top
View user's profile Send private message
kijjaz



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

PostPosted: Fri Jun 06, 2008 5:05 am    Post subject: Reply with quote  Mark this post and the followings unread

Code:
float noteDurations[0];

4.0/4 => noteDurations["v"]; // define quarter note
4.0/8 => noteDurations["a"]; // define eighth note
4.0/16 => noteDurations["s"]; // define sixteenth note


Can this kind of defining note durations help you access the durations the way you'd like to?

(for example, noteDuration[v] would be 1.0, when v is defined a string "v")
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
fraukefroehlich



Joined: May 11, 2007
Posts: 22
Location: home
Audio files: 1

PostPosted: Sat Jun 07, 2008 5:24 am    Post subject: Reply with quote  Mark this post and the followings unread

hmmm.. .quickly thinking about this option i guess it would allow a quite nice workaround, yes.

but i've already come up with a different workaround. i'll post the code after the 13th Wink

however, thx for the clue!

_________________
u said it man... nobody chucks with the jesus...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [6 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


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use