[chuck-users] Problem with deleting item in array.

Spencer Salazar spencer at ccrma.stanford.edu
Sun Aug 21 17:04:13 EDT 2016


Yeah the problem is probably in removeSeq.

        for(int i; i < s.size(); i++) {
            if(i != num) {
                sequences[i] @=> s[i];
            } else {
                sequences[i + 1] @=> s[i];
            }
        }

Here you only hit the i+1 case when you find the seq you are removing
("num"). In the next loop around, you go back to copying sequences[i] to
s[i]; sequences[i] at this stage is the same as sequences[i+1] in the
previous loop around, so overall you've copied sequences[num+1] twice.

For simplicity I would refactor this into two loops, one to copy everything
before num (sequences[i] @=> s[i];) and one to copy everything after
(sequences[i+1] @=> s[i];), but there are a few different ways you could
structure it. If ChucK had a list class this would be a lot easier, but so
it goes.

spencer


On Sun, Aug 21, 2016 at 4:50 AM, dude <prosvirnin.arseniy at gmail.com> wrote:

> Hello, Chuck users!
>
> I work on chuck program for live performance.
> Main goal of program is play and delete sequences,
> made from pre-made text file.
>
> All sequences are separate shreds which running and
> stoping by SequenceController class; each
> sequence is instance of Sequence class.
>
> So my problem is:
>
> For example I have three sequences running.
> If I delete sequences in inverse order,
> all works fine; other way one of all sequences can not
> be deleted and lookup() function shows all
> sequences name as name of undeletable sequence.
>
> Here is a link on PasteBin - http://pastebin.com/5Kk8xVKV
>
> I guess problem is in removeSeq function on line 82.
>
> I've got number for sequence from midi controller
> and it is an 0 indexed integer.
>
> Thanks for yours assistance.
>
> Phlox.s
>
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>
>
>


-- 
Spencer Salazar
Doctoral Candidate
Center for Computer Research in Music and Acoustics
Stanford University

spencer at ccrma.stanford.edu
+1 831.277.4654
https://ccrma.stanford.edu/~spencer/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20160821/faf97c1b/attachment.html>


More information about the chuck-users mailing list