[chuck-users] Array documentation, such as .cap(), .size, etc.

Michael Heuer heuermh at gmail.com
Tue Apr 28 15:11:55 EDT 2009


Andrew C. Smith:

> Where is the documentation for this stuff?  I spent a ton of time just
> guessing and looking at other examples until I found out how to make an OSC
> event add a note to the end of an arpeggiating chord (very Glass-like).  I
> got it working, although I might ask for help later on something related,
> but is there any comprehensive array documentation?  I found .cap() used in
> the examples, but never explained.  Thanks,
> Andrew

Hello Andrew,

If you are familar with the java collections API, you may find the
ArrayList class in LiCK easier to use than ChucK arrays.  A bit more
verbose though.

http://github.com/heuermh/lick/tree/master

ArrayList notes;
for (0 => int i; i < 32; i++)
{
  Note note;
  Math.rand2(440, 880) => note.freq;
  notes.add(note);
}

// sample notes randomly
while (true)
{
  notes.sample() $ Note @=> Note note;
  play(note);
}

// for loop
for (0 => int i; i < notes.size(); i++)
{
  notes.get(i) $ Note @=> Note note;
  play(note);
}

// iterator style
notes.iterator() @=> Iterator iterator;
while (iterator.hasNext())
{
  iterator.next() $ Note @=> Note note;
  play(note);
}

// functor style
PlayNote playNote;
notes.forEach(playNote);

class PlayNote extends UnaryProcedure
{
  fun void run(Object value)
  {
    value $ Note @=> Note note;
    play(note);
  }
}

etc.

   michael


More information about the chuck-users mailing list