The Alternative Csound Reference Manual
Previous | Adding your own Cmodules to Csound | Next

# File Sharing

When accessing an external file often, or doing it from multiple places, it is often efficient to read the entire file into memory. This is accomplished by including the line

    MEMFIL    *mfp;

in the defined structure (*p), then using the following style of code in the init module:

    if (p-mfp == NULL)
      p-mfp = ldmemfile(filname);

where char *filname is a string name of the file requested. The data read will be found between

    (char *)  p-mfp-beginp; and (char *) p-mfp-endp;

Loaded files do not belong to a particular instrument, but are automatically shared for multiple access. See the ADSYN structure in opcodes3.h and the code for adset() and adsyn() in opcodes3.c.

Previous | Home | Next
Additional Space | Up | String arguments