| Author |
Message |
fraukefroehlich
Joined: May 11, 2007 Posts: 22 Location: home
Audio files: 1
|
Posted: Wed Jun 04, 2008 10:41 pm Post subject:
annoying exception - associative array |
 |
|
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
|
|
 |
Frostburn

Joined: Dec 12, 2007 Posts: 255 Location: Finland
Audio files: 9
|
Posted: Thu Jun 05, 2008 1:06 am Post subject:
|
 |
|
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
|
|
 |
fraukefroehlich
Joined: May 11, 2007 Posts: 22 Location: home
Audio files: 1
|
Posted: Thu Jun 05, 2008 1:21 am Post subject:
|
 |
|
| Frostburn wrote: | ...but it seems that multidimensional arrays are broken at the moment...
|
... which means...? |
|
|
Back to top
|
|
 |
Frostburn

Joined: Dec 12, 2007 Posts: 255 Location: Finland
Audio files: 9
|
Posted: Thu Jun 05, 2008 2:13 am Post subject:
|
 |
|
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
|
|
 |
kijjaz

Joined: Sep 20, 2004 Posts: 765 Location: bangkok, thailand
Audio files: 4
|
Posted: Fri Jun 06, 2008 5:05 am Post subject:
|
 |
|
| 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
|
|
 |
fraukefroehlich
Joined: May 11, 2007 Posts: 22 Location: home
Audio files: 1
|
Posted: Sat Jun 07, 2008 5:24 am Post subject:
|
 |
|
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
however, thx for the clue! _________________ u said it man... nobody chucks with the jesus... |
|
|
Back to top
|
|
 |
|