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

# String arguments

To permit a quoted string input argument (float *ifilnam, say) in our defined structure (*p), assign it the argtype S in entry.c, include another member char *strarg in the structure, insert a line

    TSTRARG( "rampt", RMP) \

in the file oload.h, and include the following code in the init module:

    if (*p-ifilnam == sstrcod)
      strcpy(filename, unquote(p-strarg));

See the code for adset() in opcodes3.c, lprdset() in opcodes5.c, and pvset() in opcodes8.c.

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
File Sharing | Up | Pitch Conversion