void readxfil(CSOUND *csound, EXTRACT_STATICS* extractStatics, FILE *xfp) /* read the extract control file */ { int flag, all; char s[82]; alloc_globals(csound, extractStatics); all = 1; flag = 'i'; /* default -i flag supplied */ STA(onsect) = 1; STA(onbeat) = FL(0.0); /* other default vals */ STA(offsect) = 999; STA(offbeat) = FL(0.0); // while (fscanf(xfp, s) != EOF) { while (fgets(s, 82, xfp) != NULL) { char *c = s; int i; switch (*c) { case 'i': all = 0; // intended no break here case 'f': case 't': flag = *c++; break; default: switch (flag) { case 'i': sscanf(s, "%d", &i); if (i>=0 && i < INSMAX) STA(inslst)[i] = 1; else csound->Die(csound, Str("instrument number out of range")); all = 0; break; case 'f': #if defined(USE_DOUBLE) CS_SSCANF(s, "%d:%lf", &STA(onsect), &STA(onbeat)); #else CS_SSCANF(s, "%d:%f", &STA(onsect), &STA(onbeat)); #endif break; case 't': STA(offsect) = STA(onsect); /* default offsect */ #if defined(USE_DOUBLE) CS_SSCANF(s, "%d:%lf", &STA(offsect), &STA(offbeat)); #else CS_SSCANF(s, "%d:%f", &STA(offsect), &STA(offbeat)); #endif } } } if (all) { char *ip; for (ip = &STA(inslst)[0]; ip < &STA(inslst)[INSMAX]; *ip++ = 1); } STA(ontime) = STA(a0).newp3 = STA(a0).p3val = STA(onbeat); STA(offtime) = STA(f0).newp2 = STA(f0).p2val = STA(offbeat); }
static void nkread(CSOUND *csound, MYFLT *kp, FILE *ifd, int32_t format, int32_t nk) { int32_t len; char inbuf[256]; switch(format) { /* place formatted kvals into outbuf */ case 1: { int8_t *bp = (int8_t*)inbuf; len = nk; len = fread(inbuf, 1, len, ifd); /* now read the buffer */ while (nk--) *kp++ = (MYFLT)*bp++; break; } case 4: { int16_t *bp = (int16_t*)inbuf; len = nk * 2; len = fread(inbuf, 1, len, ifd); /* now read the buffer */ while (nk--) *kp++ = (MYFLT)*bp++; break; } case 5: { int32_t *bp = (int32_t*)inbuf; len = nk * 4; len = fread(inbuf, 1, len, ifd); /* now read the buffer */ while (nk--) *kp++ = (MYFLT)*bp++; break; } case 6: { float *bp = (float*)inbuf; len = nk * sizeof(float); len = fread(inbuf, 1, len, ifd); /* now read the buffer */ while (nk--) *kp++ = (MYFLT)*bp++; break; } case 7: while (nk--) { char *bp = inbuf; do { /* Skip whitespace */ *bp = (char)getc(ifd); } while (isspace(*bp)); do { /* Absorb digits */ *(++bp) = (char)getc(ifd); } while (isdigit(*bp) || *bp=='-' || *bp=='+' || *bp=='.' || *bp=='e' ||*bp=='E'); ungetc(*bp, ifd); //fseek(ifd, -1L, SEEK_CUR); *bp = '\0'; #ifndef USE_DOUBLE CS_SSCANF(inbuf,"%f", kp); #else CS_SSCANF(inbuf,"%lf", kp); #endif kp++; } break; case 8: while (nk--) { char *bp = inbuf; do { /* Skip whitespace */ *bp = (char)getc(ifd); } while (isspace(*bp)); do { /* Absorb digits and such*/ *(++bp) = (char)getc(ifd); } while (!isspace(*bp)); (void)ungetc(*bp, ifd); //fseek(ifd, -1L, SEEK_CUR); *bp = '\0'; #ifndef USE_DOUBLE CS_SSCANF(inbuf,"%f", kp); #else CS_SSCANF(inbuf,"%lf", kp); #endif kp++; } break; default: csound->Warning(csound,Str("unknown kdump format")); } }
void readxfil(CSOUND *csound, EXTRACT_STATICS* extractStatics, FILE *xfp) /* read the extract control file */ { int flag, all; char s[128]; alloc_globals(extractStatics); all = 1; flag = 'i'; /* default -i flag supplied */ extractStatics->onsect = 1; extractStatics->onbeat = FL(0.0); /* other default vals */ extractStatics->offsect = 999; extractStatics->offbeat = FL(0.0); while (fscanf(xfp, "%100s", s) > 0) { char *c = s; int i; //printf("string: %s\n", s); switch (*c) { case 'i': all = 0; // intended no break here /* FALLTHRU */ case 'f': case 't': flag = *c++; break; default: switch (flag) { case 'i': sscanf(s, "%d", &i); //printf("i: %d\n", i); if (LIKELY(i>=0 && i < INSMAX)) extractStatics->inslst[i] = 1; else csound->Message(csound, Str("instrument number out of range")); all = 0; break; case 'f': //printf("f: %s\n", s); #if defined(USE_DOUBLE) CS_SSCANF(s, "%d:%lf", &extractStatics->onsect, &extractStatics->onbeat); #else CS_SSCANF(s, "%d:%f", &extractStatics->onsect, &extractStatics->onbeat); #endif break; case 't': //printf("t: %s\n"); extractStatics->offsect = extractStatics->onsect; /* default offsect */ #if defined(USE_DOUBLE) CS_SSCANF(s, "%d:%lf", &extractStatics->offsect,&extractStatics->offbeat); #else CS_SSCANF(s, "%d:%f", &extractStatics->offsect, &extractStatics->offbeat); #endif } } } //printf("extract read\n"); if (all) { char *ip; for (ip = &extractStatics->inslst[0]; ip < &extractStatics->inslst[INSMAX]; *ip++ = 1); } extractStatics->ontime = extractStatics->a0.newp3 = extractStatics->a0.p3val = extractStatics->onbeat; extractStatics->offtime = extractStatics->f0.newp2 = extractStatics->f0.p2val = extractStatics->offbeat; }