fprintks — Similar to printks but prints to a file.
"filename" -- name of the output file.
"string" -- the text string to be printed. Can be up to 8192 characters and must be in double quotes.
kval1, kval2, ... (optional) -- The k-rate values to be printed. These are specified in “string” with the standard C value specifier (%f, %d, etc.) in the order given.
fprintks is similar to the printks opcode except it outputs to a file and doesn't have a itime parameter. For more information about output formatting, please look at printks's documentation.
Here is an example of the fprintks opcode. It uses the file fprintks.csd.
Example 164. Example of the fprintks opcode.
See the sections Real-time Audio and Command Line Flags for more information on using command line flags.<CsoundSynthesizer> <CsOptions> ; Select audio/midi flags here according to platform ; Audio out Audio in -odac -iadc ;;;RT audio I/O ; For Non-realtime ouput leave only the line below: ; -o fprintks.wav -W ;;; for file output any platform </CsOptions> <CsInstruments> /* Written by Matt Ingalls, edited by Kevin Conder. */ ; Initialize the global variables. sr = 44100 kr = 4410 ksmps = 10 nchnls = 1 ; Instrument #1 - a score generator example. instr 1 ; K-rate stuff. kstart init 0 kdur linrand 10 kpitch linrand 8 ; Printing to to a file called "my.sco". fprintks "my.sco", "i1\\t%2.2f\\t%2.2f\\t%2.2f\\n", kstart, kdur, 4+kpitch knext linrand 1 kstart = kstart + knext endin </CsInstruments> <CsScore> /* Written by Matt Ingalls, edited by Kevin Conder. */ ; Play Instrument #1. i 1 0 0.001 </CsScore> </CsoundSynthesizer>
This example will generate a file called “my.sco”. It should contain lines like this:
i1 0.00 3.94 10.26 i1 0.20 3.35 6.22 i1 0.67 3.65 11.33 i1 1.31 1.42 4.13