static char *fpnum(CSOUND *csound, char *p, int lincnt, int pcnt, CORFIL *sco) /* moves ascii string */ /* to SCOREOUT file with fpnum format chk */ /* CONSIDER USING SIMPLER CODE */ { char *q; int dcnt = 0; //printf(">>>>%20s\n", p); q = p; if (*p == '+') p++; if (*p == '-') corfile_putc(csound, *p++, sco); if (*p=='0' && *(p+1)=='x') { while (!isspace(*p)) { corfile_putc(csound, *p++, sco); //dcnt++; /* Not used so delete? */ } return p; } while (isdigit(*p)) { // printf("*p=%c\n", *p); corfile_putc(csound, *p++, sco); dcnt++; } // printf("%d:output: %s<<\n", __LINE__, sco); if (*p == '.') corfile_putc(csound, *p++, sco); while (isdigit(*p)) { corfile_putc(csound, *p++, sco); dcnt++; } // printf("%d:output: %s<<\n", __LINE__, sco); if (*p == 'E' || *p == 'e') { /* Allow exponential notation */ corfile_putc(csound, *p++, sco); dcnt++; if (*p == '+' || *p == '-') { corfile_putc(csound, *p++, sco); dcnt++; } while (isdigit(*p)) { corfile_putc(csound, *p++, sco); dcnt++; } } // printf("%d:output: %s<<\n", __LINE__, sco); if (UNLIKELY((*p != SP && *p != LF) || !dcnt)) { csound->Message(csound,Str("swrite: output, sect%d line%d p%d has " "illegal number "), csound->sectcnt,lincnt,pcnt); while (q < p) csound->Message(csound,"%c", *q++); while (*p != SP && *p != LF) csound->Message(csound,"%c", *p++); csound->Message(csound,Str(" String truncated\n")); if (!dcnt) corfile_putc(csound, '0', sco); } return(p); }
static void fltout(CSOUND *csound, MYFLT n, CORFIL *sco) { char *c, buffer[1024]; CS_SPRINTF(buffer, "%a", (double)n); /* corfile_puts(buffer, sco); */ for (c = buffer; *c != '\0'; c++) corfile_putc(csound, *c, sco); }
static char *pfStr(CSOUND *csound, char *p, int lincnt, int pcnt, CORFIL *sco) { /* moves quoted ascii string to SCOREOUT file */ char *q = p; /* with no internal format chk */ corfile_putc(csound, *p++, sco); while (*p != '"') { corfile_putc(csound, *p++, sco); if (*(p-1)=='\\') corfile_putc(csound, *p++, sco); } corfile_putc(csound, *p++, sco); if (UNLIKELY(*p != SP && *p != LF)) { csound->Message(csound, Str("swrite: output, sect%d line%d p%d " "has illegally terminated string "), csound->sectcnt, lincnt, pcnt); while (q < p) csound->Message(csound,"%c", *q++); while (*p != SP && *p != LF) csound->Message(csound,"%c", *p++); csound->Message(csound,"\n"); } return(p); }
static int scope(CSOUND *csound, int argc, char **argv) { #if 0 PRS_PARM qq; int len=100, p=0, n; char buff[1024]; FILE *ff; /* Pre-process */ memset(&qq, '\0', sizeof(PRS_PARM)); csound->scorestr = corfile_create_w(); csound_prslex_init(&qq.yyscanner); csound_prsset_extra(&qq, qq.yyscanner); csound->scorename = argv[1]; ff = fopen(csound->scorename, "r"); memset(buff, '\0', 1024); while ((n = fread(buff, 1, 1023, ff))) { corfile_puts(buff, csound->scorestr); memset(buff, '\0', 1024); } corfile_putc('\0', csound->scorestr); /* For use in bison/flex */ corfile_putc('\0', csound->scorestr); /* For use in bison/flex */ csound->expanded_sco = corfile_create_w(); snprintf(buff, 1024, "#source %d\n", qq.lstack[0] = file_to_int(csound, csound->scorename)); corfile_puts(buff, csound->expanded_sco); snprintf(buff, "#line %d\n", csound->orcLineOffset); corfile_puts(buff, csound->expanded_sco); qq.line = 1; csound_prslex(csound, qq.yyscanner); csound->DebugMsg(csound, "yielding >>%s<<\n", corfile_body(csound->expanded_sco)); csound_prslex_destroy(&qq.yyscanner); #endif return 0; }
static char *prevp(CSOUND *csound, SRTBLK *bp, char *p, int lincnt, int pcnt, CORFIL *sco) { char *q; int n; q = p; p++; /* 1st char */ if (UNLIKELY(*p++ != 'p')) /* 2nd char */ goto error; n = 999; if (isdigit(*p)) n = *p++ - '0'; if (isdigit(*p)) /* n is np subscript no */ n = 10*n + (*p++ - '0'); if (UNLIKELY(*p != SP && *p != LF)) goto error; if (LIKELY((bp = prvins(bp)) != NULL /* for prvins, same p1, */ && n <= bp->pcnt)) { q = bp->text; while (n--) while (*q++ != SP) /* go find the pfield */ ; pfout(csound,bp,q,lincnt,pcnt, sco); /* and put it out */ } else { error: csound->Message(csound, Str("swrite: output, sect%d line%d p%d makes illegal reference to "), csound->sectcnt,lincnt,pcnt); while (q < p) csound->Message(csound,"%c", *q++); while (*p != SP && *p != LF) csound->Message(csound,"%c", *p++); csound->Message(csound,Str(" Zero substituted\n")); corfile_putc(csound, '0', sco); } return(p); }
void swritestr(CSOUND *csound, CORFIL *sco, int first) { SRTBLK *bp; char *p, c, isntAfunc; int lincnt, pcnt=0; if (UNLIKELY((bp = csound->frstbp) == NULL)) return; lincnt = 0; if ((c = bp->text[0]) != 'w' && c != 's' && c != 'e') { /* if no warp stmnt but real data, */ /* create warp-format indicator */ if (first) corfile_puts(csound, "w 0 60\n", sco); lincnt++; } nxtlin: lincnt++; /* now for each line: */ p = bp->text; c = *p++; isntAfunc = 1; switch ((int) c) { case 'z': printf("skip z\n"); //corfile_putc('\n', sco); break; case 'f': isntAfunc = 0; /* fall through */ case 'q': case 'i': case 'd': case 'a': corfile_putc(csound, c, sco); corfile_putc(csound, *p++, sco); while ((c = *p++) != SP && c != LF) corfile_putc(csound, c, sco); /* put p1 */ corfile_putc(csound, c, sco); if (c == LF) break; fltout(csound, bp->p2val, sco); /* put p2val, */ corfile_putc(csound, SP, sco); if (first) fltout(csound, bp->newp2, sco); /* newp2, */ while ((c = *p++) != SP && c != LF) ; corfile_putc(csound, c, sco); /* and delim */ if (c == LF) break; if (isntAfunc) { fltout(csound, bp->p3val, sco); /* put p3val, */ corfile_putc(csound, SP, sco); if (first) fltout(csound, bp->newp3, sco); /* newp3, */ while ((c = *p++) != SP && c != LF) ; } else { /*make sure p3s (table length) are ints */ char temp[256]; snprintf(temp,256,"%d ",(int32)bp->p3val); /* put p3val */ fpnum(csound,temp, lincnt, pcnt, sco); corfile_putc(csound, SP, sco); if (first) { snprintf(temp,256,"%d ",(int32)bp->newp3); /* put newp3 */ fpnum(csound,temp, lincnt, pcnt, sco); } while ((c = *p++) != SP && c != LF) ; } pcnt = 3; while (c != LF) { pcnt++; corfile_putc(csound, SP, sco); p = pfout(csound,bp,p,lincnt,pcnt, sco); /* now put each pfield */ c = *p++; } corfile_putc(csound, '\n', sco); break; case 's': case 'e': if (bp->pcnt > 0) { char buffer[80]; CS_SPRINTF(buffer, "f 0 %f %f\n", bp->p2val, bp->newp2); corfile_puts(csound, buffer, sco); } corfile_putc(csound, c, sco); corfile_putc(csound, LF, sco); break; case 'w': case 't': corfile_putc(csound, c, sco); while ((c = *p++) != LF) /* put entire line */ corfile_putc(csound, c, sco); corfile_putc(csound, LF, sco); break; case 'x': case 'y': case -1: break; default: csound->Message(csound, Str("swrite: unexpected opcode %c, section %d line %d\n"), c, csound->sectcnt, lincnt); break; } if ((bp = bp->nxtblk) != NULL) goto nxtlin; }
static char *randramp(CSOUND *csound, SRTBLK *bp, char *p, int lincnt, int pcnt, CORFIL *sco) /* NB np's may reference a ramp but ramps must terminate in valid nums */ { char *q; char *psav; SRTBLK *prvbp, *nxtbp; MYFLT pval, qval, rval; extern MYFLT stof(CSOUND *, char *); int pnum, n; psav = ++p; if (UNLIKELY(*psav != SP && *psav != LF)) goto error1; pnum = 0; q = bp->text; while (q < p) if (*q++ == SP) pnum++; prvbp = bp; backup: if (LIKELY((prvbp = prvins(prvbp)) != NULL)) { p = prvbp->text; n = pnum; while (n--) while (*p++ != SP) ; if (UNLIKELY(*p == '~')) goto backup; } else goto error2; nxtbp = bp; forwrd: if (LIKELY((nxtbp = nxtins(nxtbp)) != NULL)) { q = nxtbp->text; n = pnum; while (n--) while (*q++ != SP) ; if (*q == '~') goto forwrd; } else goto error2; pval = stof(csound, p); /* the error msgs generated by stof */ qval = stof(csound, q); /* are misleading */ rval = (MYFLT) (((double) (csound->Rand31(&(csound->randSeed1)) - 1) / 2147483645.0) * ((double) qval - (double) pval) + (double) pval); fltout(csound, rval, sco); return(psav); error1: csound->Message(csound,Str("swrite: output, sect%d line%d p%d has illegal" " expramp symbol\n"), csound->sectcnt,lincnt,pcnt); goto put0; error2: csound->Message(csound,Str("swrite: output, sect%d line%d p%d expramp has" " illegal forward or backward ref\n"), csound->sectcnt,lincnt,pcnt); put0: corfile_putc(csound, '0', sco); return(psav); }
static char *expramp(CSOUND *csound, SRTBLK *bp, char *p, int lincnt, int pcnt, CORFIL *sco) /* NB np's may reference a ramp but ramps must terminate in valid nums */ { char *q; char *psav; SRTBLK *prvbp, *nxtbp; MYFLT pval, qval, rval; double p2span; extern MYFLT stof(CSOUND *, char *); int pnum, n; psav = ++p; if (UNLIKELY(*psav != SP && *psav != LF)) goto error1; pnum = 0; q = bp->text; while (q < p) if (*q++ == SP) pnum++; prvbp = bp; backup: if (LIKELY((prvbp = prvins(prvbp)) != NULL)) { p = prvbp->text; n = pnum; while (n--) while (*p++ != SP) ; if (*p == '}' || *p == '{' || *p == '(' || *p == ')') goto backup; } else goto error2; nxtbp = bp; forwrd: if (LIKELY((nxtbp = nxtins(nxtbp)) != NULL)) { q = nxtbp->text; n = pnum; while (n--) while (*q++ != SP) ; if (*q == '}' || *q == '{' || *q == '(' || *q == ')') goto forwrd; } else goto error2; pval = stof(csound, p); /* the error msgs generated by stof */ qval = stof(csound, q); /* are misleading */ p2span = (double)(nxtbp->newp2 - prvbp->newp2); /* printf("pval=%f qval=%f span = %f\n", pval, qval, p2span); */ rval = pval * (MYFLT)pow((double)(qval/pval), (double)(bp->newp2 - prvbp->newp2) / p2span); /* printf("rval=%f bp->newp2=%f prvbp->newp2-%f\n", rval, bp->newp2, prvbp->newp2); */ fltout(csound, rval, sco); return(psav); error1: csound->Message(csound,Str("swrite: output, sect%d line%d p%d has illegal" " expramp symbol\n"), csound->sectcnt,lincnt,pcnt); goto put0; error2: csound->Message(csound, Str("swrite: output, sect%d line%d p%d expramp " "has illegal forward or backward ref\n"), csound->sectcnt, lincnt, pcnt); put0: corfile_putc(csound, '0', sco); return(psav); }
TREE *csoundParseOrc(CSOUND *csound, const char *str) { int err; OPARMS *O = csound->oparms; csound->parserNamedInstrFlag = 2; { PRE_PARM qq; /* Preprocess */ memset(&qq, 0, sizeof(PRE_PARM)); //csp_orc_sa_print_list(csound); csound_prelex_init(&qq.yyscanner); csound_preset_extra(&qq, qq.yyscanner); qq.line = csound->orcLineOffset; csound->expanded_orc = corfile_create_w(); file_to_int(csound, "**unknown**"); if (str == NULL) { char bb[80]; if (csound->orchstr==NULL && !csound->oparms->daemon) csound->Die(csound, Str("Failed to open input file %s\n"), csound->orchname); else if(csound->orchstr==NULL && csound->oparms->daemon) return NULL; add_include_udo_dir(csound->orchstr); if (csound->orchname==NULL || csound->orchname[0]=='\0') csound->orchname = csound->csdname; /* We know this is the start so stack is empty so far */ snprintf(bb, 80, "#source %d\n", qq.lstack[0] = file_to_int(csound, csound->orchname)); corfile_puts(bb, csound->expanded_orc); snprintf(bb, 80, "#line %d\n", csound->orcLineOffset); corfile_puts(bb, csound->expanded_orc); } else { if (csound->orchstr == NULL || corfile_body(csound->orchstr) == NULL) csound->orchstr = corfile_create_w(); else corfile_reset(csound->orchstr); corfile_puts(str, csound->orchstr); corfile_puts("\n#exit\n", csound->orchstr); corfile_putc('\0', csound->orchstr); corfile_putc('\0', csound->orchstr); } csound->DebugMsg(csound, "Calling preprocess on >>%s<<\n", corfile_body(csound->orchstr)); //csound->DebugMsg(csound,"FILE: %s \n", csound->orchstr->body); // csound_print_preextra(&qq); cs_init_math_constants_macros(csound, &qq); cs_init_omacros(csound, &qq, csound->omacros); // csound_print_preextra(&qq); csound_prelex(csound, qq.yyscanner); if (UNLIKELY(qq.ifdefStack != NULL)) { csound->Message(csound, Str("Unmatched #ifdef\n")); csound->LongJmp(csound, 1); } csound_prelex_destroy(qq.yyscanner); csound->DebugMsg(csound, "yielding >>%s<<\n", corfile_body(csound->expanded_orc)); corfile_rm(&csound->orchstr); } { /* VL 15.3.2015 allocating memory here will cause unwanted growth. We just pass a pointer, which will be allocated by make leaf */ TREE* astTree = NULL;// = (TREE *)csound->Calloc(csound, sizeof(TREE)); TREE* newRoot; PARSE_PARM pp; TYPE_TABLE* typeTable = NULL; /* Parse */ memset(&pp, '\0', sizeof(PARSE_PARM)); init_symbtab(csound); csound_orcdebug = O->odebug; csound_orclex_init(&pp.yyscanner); csound_orcset_extra(&pp, pp.yyscanner); csound_orc_scan_buffer(corfile_body(csound->expanded_orc), corfile_tell(csound->expanded_orc), pp.yyscanner); //csound_orcset_lineno(csound->orcLineOffset, pp.yyscanner); //printf("%p \n", astTree); err = csound_orcparse(&pp, pp.yyscanner, csound, &astTree); //printf("%p \n", astTree); // print_tree(csound, "AST - AFTER csound_orcparse()\n", astTree); //csp_orc_sa_cleanup(csound); corfile_rm(&csound->expanded_orc); if (csound->synterrcnt) err = 3; if (LIKELY(err == 0)) { if(csound->oparms->odebug) csound->Message(csound, Str("Parsing successful!\n")); } else { if (err == 1){ csound->Message(csound, Str("Parsing failed due to invalid input!\n")); } else if (err == 2){ csound->Message(csound, Str("Parsing failed due to memory exhaustion!\n")); } else if (err == 3){ csound->Message(csound, Str("Parsing failed due to %d syntax error%s!\n"), csound->synterrcnt, csound->synterrcnt==1?"":"s"); } goto ending; } if (UNLIKELY(PARSER_DEBUG)) { print_tree(csound, "AST - INITIAL\n", astTree); } //print_tree(csound, "AST - INITIAL\n", astTree); typeTable = csound->Malloc(csound, sizeof(TYPE_TABLE)); typeTable->udos = NULL; typeTable->globalPool = csoundCreateVarPool(csound); typeTable->instr0LocalPool = csoundCreateVarPool(csound); typeTable->localPool = typeTable->instr0LocalPool; typeTable->labelList = NULL; /**** THIS NEXT LINE IS WRONG AS err IS int WHILE FN RETURNS TREE* ****/ astTree = verify_tree(csound, astTree, typeTable); // csound->Free(csound, typeTable->instr0LocalPool); // csound->Free(csound, typeTable->globalPool); // csound->Free(csound, typeTable); //print_tree(csound, "AST - FOLDED\n", astTree); //FIXME - synterrcnt should not be global if (astTree == NULL || csound->synterrcnt){ err = 3; if (astTree) csound->Message(csound, Str("Parsing failed due to %d semantic error%s!\n"), csound->synterrcnt, csound->synterrcnt==1?"":"s"); else if (csound->synterrcnt) csound->Message(csound, Str("Parsing failed to syntax errors\n")); else csound->Message(csound, Str("Parsing failed due no input!\n")); goto ending; } err = 0; //csp_orc_analyze_tree(csound, astTree); // astTree = csound_orc_expand_expressions(csound, astTree); // if (UNLIKELY(PARSER_DEBUG)) { print_tree(csound, "AST - AFTER VERIFICATION/EXPANSION\n", astTree); } ending: csound_orclex_destroy(pp.yyscanner); if (err) { csound->ErrorMsg(csound, Str("Stopping on parser failure")); csoundDeleteTree(csound, astTree); if (typeTable != NULL) { csoundFreeVarPool(csound, typeTable->globalPool); if(typeTable->instr0LocalPool != NULL) { csoundFreeVarPool(csound, typeTable->instr0LocalPool); } if(typeTable->localPool != typeTable->instr0LocalPool) { csoundFreeVarPool(csound, typeTable->localPool); } csound->Free(csound, typeTable); } return NULL; } astTree = csound_orc_optimize(csound, astTree); // small hack: use an extra node as head of tree list to hold the // typeTable, to be used during compilation newRoot = make_leaf(csound, 0, 0, 0, NULL); newRoot->markup = typeTable; newRoot->next = astTree; /* if(str!=NULL){ */ /* if (typeTable != NULL) { */ /* csoundFreeVarPool(csound, typeTable->globalPool); */ /* if(typeTable->instr0LocalPool != NULL) { */ /* csoundFreeVarPool(csound, typeTable->instr0LocalPool); */ /* } */ /* if(typeTable->localPool != typeTable->instr0LocalPool) { */ /* csoundFreeVarPool(csound, typeTable->localPool); */ /* } */ /* csound->Free(csound, typeTable); */ /* } */ /* } */ return newRoot; } }
PUBLIC int csoundCompileArgs(CSOUND *csound, int argc, char **argv) { OPARMS *O = csound->oparms; char *s; FILE *xfile = NULL; int n; int csdFound = 0; char *fileDir; if ((n = setjmp(csound->exitjmp)) != 0) { return ((n - CSOUND_EXITJMP_SUCCESS) | CSOUND_EXITJMP_SUCCESS); } if(csound->engineStatus & CS_STATE_COMP){ csound->Message(csound, Str("Csound is already started, call csoundReset()\n" "before starting again \n")); return CSOUND_ERROR; } if (--argc <= 0) { dieu(csound, Str("insufficient arguments")); } /* command line: allow orc/sco/csd name */ csound->orcname_mode = 0; /* 0: normal, 1: ignore, 2: fail */ if (argdecode(csound, argc, argv) == 0) csound->LongJmp(csound, 1); /* do not allow orc/sco/csd name in .csound6rc */ csound->orcname_mode = 2; checkOptions(csound); if (csound->delayederrormessages) { if (O->msglevel>8) csound->Warning(csound, csound->delayederrormessages); free(csound->delayederrormessages); csound->delayederrormessages = NULL; } /* check for CSD file */ if (csound->orchname == NULL) { if(csound->info_message_request) { csound->info_message_request = 0; csound->LongJmp(csound, 1); } else if(csound->oparms->daemon == 0) dieu(csound, Str("no orchestra name")); } else if (csound->use_only_orchfile == 0 && (csound->scorename == NULL || csound->scorename[0] == (char) 0) && csound->orchname[0] != '\0') { /* FIXME: allow orc/sco/csd name in CSD file: does this work ? */ csound->orcname_mode = 0; csound->Message(csound, "UnifiedCSD: %s\n", csound->orchname); /* Add directory of CSD file to search paths before orchname gets * replaced with temp orch name if default paths is enabled */ if (!O->noDefaultPaths) { fileDir = csoundGetDirectoryForPath(csound, csound->orchname); csoundAppendEnv(csound, "SADIR", fileDir); csoundAppendEnv(csound, "SSDIR", fileDir); csoundAppendEnv(csound, "INCDIR", fileDir); csoundAppendEnv(csound, "MFDIR", fileDir); csound->Free(csound, fileDir); } if(csound->orchname != NULL) { csound->csdname = csound->orchname; /* save original CSD name */ if (!read_unified_file(csound, &(csound->orchname), &(csound->scorename))) { csound->Die(csound, Str("Reading CSD failed ... stopping")); } csdFound = 1; } } /* IV - Feb 19 2005: run a second pass of argdecode so that */ /* command line options override CSD options */ /* this assumes that argdecode is safe to run multiple times */ csound->orcname_mode = 1; /* ignore orc/sco name */ argdecode(csound, argc, argv); /* should not fail this time */ /* some error checking */ if (csound->stdin_assign_flg && (csound->stdin_assign_flg & (csound->stdin_assign_flg - 1)) != 0) { csound->Die(csound, Str("error: multiple uses of stdin")); } if (csound->stdout_assign_flg && (csound->stdout_assign_flg & (csound->stdout_assign_flg - 1)) != 0) { csound->Die(csound, Str("error: multiple uses of stdout")); } /* done parsing csound6rc, CSD, and command line options */ if (csound->scorename == NULL && csound->scorestr==NULL) { /* No scorename yet */ csound->scorestr = corfile_create_r("f0 800000000000.0\n"); corfile_flush(csound->scorestr); if (O->RTevents) csound->Message(csound, Str("realtime performance using dummy " "numeric scorefile\n")); } else if (!csdFound && !O->noDefaultPaths){ /* Add directory of SCO file to search paths*/ fileDir = csoundGetDirectoryForPath(csound, csound->scorename); csoundAppendEnv(csound, "SADIR", fileDir); csoundAppendEnv(csound, "SSDIR", fileDir); csoundAppendEnv(csound, "MFDIR", fileDir); csound->Free(csound, fileDir); } /* Add directory of ORC file to search paths*/ if (!csdFound && !O->noDefaultPaths) { fileDir = csoundGetDirectoryForPath(csound, csound->orchname); csoundAppendEnv(csound, "SADIR", fileDir); csoundAppendEnv(csound, "SSDIR", fileDir); csoundAppendEnv(csound, "MFDIR", fileDir); csound->Free(csound, fileDir); } if (csound->orchstr==NULL && csound->orchname) { /* does not deal with search paths */ csound->Message(csound, Str("orchname: %s\n"), csound->orchname); csound->orchstr = copy_to_corefile(csound, csound->orchname, NULL, 0); if (csound->orchstr==NULL) csound->Die(csound, Str("Failed to open input file - %s\n"), csound->orchname); corfile_puts("\n#exit\n", csound->orchstr); corfile_putc('\0', csound->orchstr); corfile_putc('\0', csound->orchstr); //csound->orchname = NULL; } if (csound->xfilename != NULL) csound->Message(csound, "xfilename: %s\n", csound->xfilename); csoundLoadExternals(csound); /* load plugin opcodes */ /* VL: added this also to csoundReset() in csound.c */ if (csoundInitModules(csound) != 0) csound->LongJmp(csound, 1); if(csoundCompileOrc(csound, NULL) != 0){ if(csound->oparms->daemon == 0) csoundDie(csound, Str("cannot compile orchestra")); else { /* VL -- 21-10-13 Csound does not need to die on failure to compile. It can carry on, because new instruments can be compiled again */ csound->Warning(csound, Str("cannot compile orchestra.")); csound->Warning(csound, Str("Csound will start with no instruments")); } } csound->modules_loaded = 1; s = csoundQueryGlobalVariable(csound, "_RTMIDI"); if (csound->enableHostImplementedMIDIIO == 1) { if (s == NULL) { s = "hostbased"; } else { strcpy(s, "hostbased"); } csoundSetConfigurationVariable(csound,"rtmidi", s); } /* IV - Jan 28 2005 */ print_benchmark_info(csound, Str("end of orchestra compile")); if (!csoundYield(csound)) return -1; /* IV - Oct 31 2002: now we can read and sort the score */ if (csound->scorename != NULL && (n = strlen(csound->scorename)) > 4 && /* if score ?.srt or ?.xtr */ (!strcmp(csound->scorename + (n - 4), ".srt") || !strcmp(csound->scorename + (n - 4), ".xtr"))) { csound->Message(csound, Str("using previous %s\n"), csound->scorename); //playscore = sortedscore = csound->scorename; /* use that one */ csound->scorestr = NULL; csound->scorestr = copy_to_corefile(csound, csound->scorename, NULL, 1); } else { //sortedscore = NULL; if (csound->scorestr==NULL) { csound->scorestr = copy_to_corefile(csound, csound->scorename, NULL, 1); if (csound->scorestr==NULL) csoundDie(csound, Str("cannot open scorefile %s"), csound->scorename); } csound->Message(csound, Str("sorting score ...\n")); scsortstr(csound, csound->scorestr); if (csound->keep_tmp) { FILE *ff = fopen("score.srt", "w"); fputs(corfile_body(csound->scstr), ff); fclose(ff); } } if (csound->xfilename != NULL) { /* optionally extract */ if (!(xfile = fopen(csound->xfilename, "r"))) csoundDie(csound, Str("cannot open extract file %s"),csound->xfilename); csoundNotifyFileOpened(csound, csound->xfilename, CSFTYPE_EXTRACT_PARMS, 0, 0); csound->Message(csound, Str(" ... extracting ...\n")); scxtract(csound, csound->scstr, xfile); fclose(xfile); csound->tempStatus &= ~csPlayScoMask; } csound->Message(csound, Str("\t... done\n")); /* copy sorted score name */ O->playscore = csound->scstr; /* IV - Jan 28 2005 */ print_benchmark_info(csound, Str("end of score sort")); if (O->syntaxCheckOnly) { csound->Message(csound, Str("Syntax check completed.\n")); return CSOUND_EXITJMP_SUCCESS; } /* open MIDI output (moved here from argdecode) */ if (O->Midioutname != NULL && O->Midioutname[0] == (char) '\0') O->Midioutname = NULL; if (O->FMidioutname != NULL && O->FMidioutname[0] == (char) '\0') O->FMidioutname = NULL; if (O->Midioutname != NULL || O->FMidioutname != NULL) openMIDIout(csound); return CSOUND_SUCCESS; }