Logo Search packages:      
Sourcecode: csound version File versions  Download package

PUBLIC int csoundPreCompile ( CSOUND p )

Reset and prepare an instance of Csound for compilation. Returns CSOUND_SUCCESS on success, and CSOUND_ERROR or CSOUND_MEMORY if an error occured.

Definition at line 986 of file csound.c.

References csoundPreCompile(), and CSOUND_::strVarMaxLen.

Referenced by csoundCompile(), and csoundPreCompile().

    {
        char    *s;
        int     i, max_len;
        int     n;

        if ((n = setjmp(p->exitjmp)) != 0) {
            return ((n - CSOUND_EXITJMP_SUCCESS) | CSOUND_EXITJMP_SUCCESS);
        }
        /* reset instance */
        csoundReset(p);
        /* copy system environment variables */
        i = csoundInitEnv(p);
        if (UNLIKELY(i != CSOUND_SUCCESS)) {
            p->engineState |= CS_STATE_JMP;
            return i;
        }
        csound_init_rand(p);
        /* allow selecting real time audio module */
        max_len = 21;
        csoundCreateGlobalVariable(p, "_RTAUDIO", (size_t) max_len);
        s = csoundQueryGlobalVariable(p, "_RTAUDIO");
#ifdef OLPC
        strcpy(s, "alsa");
#else
        strcpy(s, "PortAudio");
#endif
        csoundCreateConfigurationVariable(p, "rtaudio", s, CSOUNDCFG_STRING,
                0, NULL, &max_len,
                "Real time audio module name", NULL);

        /* initialise real time MIDI */
        p->midiGlobals = (MGLOBAL*) mcalloc(p, sizeof(MGLOBAL));
        p->midiGlobals->Midevtblk = (MEVENT*) NULL;
        p->midiGlobals->MidiInOpenCallback = DummyMidiInOpen;
        p->midiGlobals->MidiReadCallback = DummyMidiRead;
        p->midiGlobals->MidiInCloseCallback = (int (*)(CSOUND *, void *)) NULL;
        p->midiGlobals->MidiOutOpenCallback = DummyMidiOutOpen;
        p->midiGlobals->MidiWriteCallback = DummyMidiWrite;
        p->midiGlobals->MidiOutCloseCallback = (int (*)(CSOUND *, void *)) NULL;
        p->midiGlobals->MidiErrorStringCallback = (const char *(*)(int)) NULL;
        p->midiGlobals->midiInUserData = NULL;
        p->midiGlobals->midiOutUserData = NULL;
        p->midiGlobals->midiFileData = NULL;
        p->midiGlobals->midiOutFileData = NULL;
        p->midiGlobals->bufp = &(p->midiGlobals->mbuf[0]);
        p->midiGlobals->endatp = p->midiGlobals->bufp;
        csoundCreateGlobalVariable(p, "_RTMIDI", (size_t) max_len);
        s = csoundQueryGlobalVariable(p, "_RTMIDI");
#ifdef OLPC
        strcpy(s, "alsa");
#else
        strcpy(s, "portmidi");
#endif
        csoundCreateConfigurationVariable(p, "rtmidi", s, CSOUNDCFG_STRING,
                0, NULL, &max_len,
                "Real time MIDI module name", NULL);
        max_len = 256;  /* should be the same as in csoundCore.h */
        csoundCreateConfigurationVariable( p, "mute_tracks",
                &(p->midiGlobals->muteTrackList[0]),
                CSOUNDCFG_STRING, 0, NULL, &max_len,
                "Ignore events (other than tempo changes)"
                " in tracks defined by pattern",
                NULL);
        csoundCreateConfigurationVariable(p, "raw_controller_mode",
                &(p->midiGlobals->rawControllerMode),
                CSOUNDCFG_BOOLEAN, 0, NULL, NULL,
                "Do not handle special MIDI controllers"
                " (sustain pedal etc.)", NULL);
        /* sound file tag options */
        max_len = 201;
        i = (max_len + 7) & (~7);
        p->SF_id_title = (char*) mcalloc(p, (size_t) i * (size_t) 6);
        csoundCreateConfigurationVariable(p, "id_title", p->SF_id_title,
                CSOUNDCFG_STRING, 0, NULL, &max_len,
                "Title tag in output soundfile "
                "(no spaces)", NULL);
        p->SF_id_copyright = (char*) p->SF_id_title + (int) i;
        csoundCreateConfigurationVariable(p, "id_copyright", p->SF_id_copyright,
                CSOUNDCFG_STRING, 0, NULL, &max_len,
                "Copyright tag in output soundfile"
                " (no spaces)", NULL);
        p->SF_id_software = (char*) p->SF_id_copyright + (int) i;
        csoundCreateConfigurationVariable(p, "id_software", p->SF_id_software,
                CSOUNDCFG_STRING, 0, NULL, &max_len,
                "Software tag in output soundfile"
                " (no spaces)", NULL);
        p->SF_id_artist = (char*) p->SF_id_software + (int) i;
        csoundCreateConfigurationVariable(p, "id_artist", p->SF_id_artist,
                CSOUNDCFG_STRING, 0, NULL, &max_len,
                "Artist tag in output soundfile (no spaces)",
                NULL);
        p->SF_id_comment = (char*) p->SF_id_artist + (int) i;
        csoundCreateConfigurationVariable(p, "id_comment", p->SF_id_comment,
                CSOUNDCFG_STRING, 0, NULL, &max_len,
                "Comment tag in output soundfile"
                " (no spaces)", NULL);
        p->SF_id_date = (char*) p->SF_id_comment + (int) i;
        csoundCreateConfigurationVariable(p, "id_date", p->SF_id_date,
                CSOUNDCFG_STRING, 0, NULL, &max_len,
                "Date tag in output soundfile (no spaces)",
                NULL);
        {
            int   minVal = 10;
            int   maxVal = 10000;
            MYFLT minValF = FL(0.0);
            /* max. length of string variables */
            csoundCreateConfigurationVariable(p, "max_str_len", &(p->strVarMaxLen),
                    CSOUNDCFG_INTEGER, 0, &minVal, &maxVal,
                    "Maximum length of string variables + 1",
                    NULL);
            csoundCreateConfigurationVariable(p, "msg_color", &(p->enableMsgAttr),
                    CSOUNDCFG_BOOLEAN, 0, NULL, NULL,
                    "Enable message attributes (colors etc.)",
                    NULL);
            csoundCreateConfigurationVariable(p, "skip_seconds",
                    &(p->csoundScoreOffsetSeconds_),
                    CSOUNDCFG_MYFLT, 0, &minValF, NULL,
                    "Start score playback at the specified"
                    " time, skipping earlier events",
                    NULL);
        }
        csoundCreateConfigurationVariable(p, "ignore_csopts",
                &(p->disable_csd_options),
                CSOUNDCFG_BOOLEAN, 0, NULL, NULL,
                "Ignore <CsOptions> in CSD files"
                " (default: no)", NULL);
        p->opcode_list = (int*) mcalloc(p, sizeof(int) * 256);
        p->engineState |= CS_STATE_PRE;
        /* now load and pre-initialise external modules for this instance */
        /* this function returns an error value that may be worth checking */
        {
            int err = csoundLoadModules(p);
            /* #ifdef BETA */
            if (p->delayederrormessages && p->printerrormessagesflag==NULL) {
                p->Warning(p, p->delayederrormessages);
                free(p->delayederrormessages);
                p->delayederrormessages = NULL;
            }
            /* #endif */
            return err;
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index