Bugs item #3299042, was opened at 2011-05-08 15:11 Message generated for change (Comment added) made by mcrodgers You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=564599&aid=3299042&group_id=81968 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Csound API Group: csound5 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Martin Rodgers (mcrodgers) Assigned to: Nobody/Anonymous (nobody) Summary: cscoreListExtractTime always returns an empty list Initial Comment: cscoreListExtractTime always returns an empty list. Fix: followed each call to cscoreCopyEvent with the statement: "b->nevents++;" This will reveal a range bug, which can be fixed by replacing the "(e->p[2] < to)" test with "((e->p[2] >= from) && (e->p[2] < to))". ---------------------------------------------------------------------- >Comment By: Martin Rodgers (mcrodgers) Date: 2011-08-22 19:25 Message: BTW, the only Csound version I can use right now is 5.10. I built and installed 12.1 but the installer got the permissions wrong, so I couldn't run that version. I couldn't build 13.0 at all. So I can only hope the version here isn't the problem. ---------------------------------------------------------------------- Comment By: Martin Rodgers (mcrodgers) Date: 2011-08-22 18:15 Message: Yes, my new version gives 2. Perhaps your version of the code still differs from mine? I may have missed something, so here's my complete working version: PUBLIC EVLIST * cscoreListExtractTime(CSOUND *csound, EVLIST *a, MYFLT from, MYFLT to) /* list extract by time */ { EVENT **p, **q, *e; EVLIST *b, *c; MYFLT maxp3; int n; int16 i; n = a->nevents; b = cscoreListCreate(csound,n); p = &a->e[1]; q = &b->e[1]; maxp3 = to - from; while ((n--) && (e = *p++) != NULL) switch (e->op) { case 'f': // printf("f %g\n", e->p[2]); if (e->p[2] < to) { *q++ = e = cscoreCopyEvent(csound,e); if (e->p[2] <= from) e->p[2] = FL(0.0); else e->p[2] -= from; } break; case 'i': if ((e->p[2] < from) && (e->p[2] + e->p[3] > from)) { // printf("b1\n"); *q++ = e = cscoreCopyEvent(csound,e); b->nevents++; // MCR e->p[3] -= from - e->p[2]; e->p[2] = FL(0.0); if (e->p[3] > maxp3) e->p[3] = maxp3; } else if ((e->p[2] >= from) && (e->p[2] < to)) { // MCR // printf("b2\n"); *q++ = e = cscoreCopyEvent(csound, e); b->nevents++; // MCR if (e->p[2] + e->p[3] > to) e->p[3] = to - e->p[2]; e->p[2] -= from; } break; default: *q++ = cscoreCopyEvent(csound,e); break; } c = cscoreListCopy(csound,b); cscoreListFree(csound, b); // csfree((CSHDR *) b); return(c); } Sorry, I really should've posted that sooner and explained the bug much better. ---------------------------------------------------------------------- Comment By: John ffitch (jpff) Date: 2011-08-22 17:51 Message: I think I understand now; you refer to calls in the function cscoreListExtractTime only. I have understood the changes and made them, but it still looks like wrng answer. I now get 1, but surely I should have 2? ---------------------------------------------------------------------- Comment By: John ffitch (jpff) Date: 2011-08-22 17:15 Message: Thank you, but I still do not understabd your fix. What is b? Every call or every call in some function? If every call then why is it not in the function? I am still not sure how to run your example ---------------------------------------------------------------------- Comment By: Martin Rodgers (mcrodgers) Date: 2011-08-21 19:14 Message: void cscore(CSOUND *cs) { EVLIST *a = cscoreListGetSection(cs); EVLIST *b = cscoreListExtractTime(cs, a, FL(1.0), FL(3.0)); printf("%d\n", cscoreListCount(cs, b)); // this always prints '0' } i1 0 1 1 i1 1 1 2 i1 2 1 3 i1 3 1 4 ---------------------------------------------------------------------- Comment By: John ffitch (jpff) Date: 2011-08-21 17:37 Message: Please can you supply either a test program, or a fixed source file, or both? I am having trouble understanding both the error and the fix ---------------------------------------------------------------------- Comment By: John ffitch (jpff) Date: 2011-07-05 18:04 Message: Can be have a test program? I am not sure how to use cscore ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=564599&aid=3299042&group_id=81968 ------------------------------------------------------------------------------ uberSVN's rich system and user administration capabilities and model configuration take the hassle out of deploying and managing Subversion and the tools developers use with it. Learn more about uberSVN and get a free download at: http://p.sf.net/sfu/wandisco-dev2dev _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net