ficlose — Closes a previously opened file.
ihandle -- a number which identifies this file (generated by a previous fiopen).
Sfilename -- A string in double quotes or string variable with the filename. The full path must be given if the file directory is not in the system PATH and is not present in the current directory.
ficlose closes a file which was previously opened with fiopen. ficlose is only needed if you need to read a file written to during the same csound performance, since only when csound ends a performance does it close and save data in all open files. The opcode ficlose is useful for instance if you want to save presets within files which you want to be accesible without having to terminate csound.
Note | |
---|---|
If you do not need this functionality it is safer not to call ficlose, and just let csound close the files when it exits. |
If a files closed with ficlose is being accessed by another opcode (like fout or foutk), it will be closed later when it is no longer being used.
Warning | |
---|---|
This opcode should be used with care, as the file handle will become invalid, and will cause an init error when an opcode tries to access the closed file. |
Here is an example of the ficlose opcode. It uses the file ficlose.csd.
Example 294. Example of the ficlose 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 -odac ;;;realtime audio out ;-iadc ;;;uncomment -iadc if realtime audio input is needed too ; For Non-realtime ouput leave only the line below: ; -o ficlose.wav -W ;;; for file output any platform </CsOptions> <CsInstruments> sr = 44100 ksmps = 32 nchnls = 2 0dbfs = 1 gihand fiopen "test1.txt", 0 instr 1 ires random 0, 100 fouti gihand, 0, 1, ires ficlose gihand endin </CsInstruments> <CsScore> i 1 0 1 e </CsScore> </CsoundSynthesizer>