Csound Csound-dev Csound-tekno Search About

feature request: ficlose

Date2006-05-29 18:43
FromAndres Cabrera
Subjectfeature request: ficlose
Hi,
I'm writing to request the addition of an ficlose opcode to complement
fiopen.
Currently, a csd like (run in realtime):




sr=44100
ksmps=1
nchnls=2

	instr 1	;untitled
ipreset = p4

Sfilename sprintf "test-%2i.preset", ipreset
ifile fiopen Sfilename, 0
;ifile fiopen "test", 0

foutir ifile, 0, 0, 1, 2, 3, ipreset
;flashtxt 1, "Instr 1 live"
printf "Stored preset :%i in file %s\n",1, ipreset, Sfilename
	endin



i1 0 1 10
i1 2 1 20
i1 3 1 30
i1 4 1 40

f 0 3000
e




Will produce valid files only when csound closes. It would be very nice
if something like ficlose could be added.
I think this would be very useful (among other things) for things like
preset storing, to be able to store a preset and recall it, without
having to exit csound.

Thanks,
Andrés


Date2006-05-30 07:21
FromIstvan Varga
SubjectRe: feature request: ficlose
AttachmentsNone  

Date2006-05-30 13:36
FromIstvan Varga
SubjectRe: [Cs-dev] [Csnd] feature request: ficlose
AttachmentsNone  

Date2006-05-30 13:50
FromAndres Cabrera
SubjectRe: [Cs-dev] [Csnd] feature request: ficlose
Hi Istvan,
That's what I thought...
However, I see there is currently a check for the validity of the file
handle in all the init functions of the opcodes (fout.c):

      n = (int) MYFLT2LRND(*p->fname);
      if (n < 0 || n > pp->file_num ||
          (p->fp = pp->file_opened[n].file) == NULL)
        csound->Die(csound, Str("fink: invalid file handle"));

except for fioutr (which does this check only in the performance fuction
ioutfile_r, line 413):

if (rfil == NULL)
      csound->Die(csound, Str("fouti: invalid file handle"));

Is this check prone for errors still?
Would it be problematic, or seriously affect performance to make this
check also on the performance functions? (I think maybe on the a-rate
ones...)

Maybe even if my proposal is not accepted it would be good to have these
init functions give an init error instead of dying altogether? I think
csound should die when the functions are performance rate and the file
has been closed, since that would generate an error, and are probably
due to a user error (or the user can make an additional check within
csound for these cases).

Cheers,
Andrés

PS There is a typo in line 319. It should be "fiopen: cannot open file %
s" instead of "fout: cannot open outfile %s"

On Tue, 2006-05-30 at 08:21 +0200, Istvan Varga wrote:
> It may be possible, although the existing fout opcodes would need
> code changes to be aware of the possiblity of file handles being
> removed. Closing a file while another instrument is using it is also
> tricky.
> 
> On Monday 29 May 2006 19:43, Andres Cabrera wrote:
> 
> > I'm writing to request the addition of an ficlose opcode to complement
> > fiopen.
> > Currently, a csd like (run in realtime):



_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https:/

Date2006-05-30 15:23
FromAndres Cabrera
SubjectRe: [Cs-dev] [Csnd] feature request: ficlose
Thanks very much Istvan, it's a very helpful addition for a project I'm
working on which I'll release soon.

Thanks!

Andrés

On Tue, 2006-05-30 at 14:36 +0200, Istvan Varga wrote:
> I am working on implementing ficlose now, and will add it to CVS soon.
> 
> 
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
> 
> 



_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.so