[Csnd] Saving score lines to text file
Date | 2019-10-27 10:18 |
From | Bernard Geyer |
Subject | [Csnd] Saving score lines to text file |
I want to save some parameters of my Csound program as a list of score lines to a text file, so I can reset them later with the scoreline opcode. It's a kind of system of named presets, saving only the parameters that are relevant to the algorithm. So I did the following: instr save_params S_FileName strget p4 S_Msg sprintf "i \"set_audio_file\" 0 0 \"%s\"\n", gSAudioPath fprints S_FileName, S_Msg ;fprints doesn't support strings! fprints S_FileName, "i \"set_params\" 0 0 %g %g %g %g\n", \ gkPitchScale, gkTimeScale, gkGrainSize, gkOverlaps turnoff endin It works the first time, but when I call "save_params" again with the same file name, the score lines are appended to the actual file instead of creating a new file. When I stop Csound and restart it again, a new file is created, replacing the old one. I would like to have this behavior every time. Is there a solution with other opcodes (that accept to write score lines containing strings) ? -- Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here |
Date | 2019-10-27 11:16 |
From | Rory Walsh |
Subject | Re: [Csnd] Saving score lines to text file |
Is there a close file opcode you can call before trying to write to it again? On Sun 27 Oct 2019, 11:08 Bernard Geyer, <micamusic2@gmail.com> wrote: I want to save some parameters of my Csound program as a list of score lines |
Date | 2019-10-27 11:52 |
From | Bernard Geyer |
Subject | Re: [Csnd] Saving score lines to text file |
> Is there a close file opcode you can call before trying to write to it again? I tried to put iHandle fiopen S_FileName, 1 on the beginning, and ficlose S_FileName on the end. It doesn't work. fiopen / ficlose seems to work only with fouti but fouti doesn't accept string arguments -- Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here |
Date | 2019-10-27 11:55 |
From | Hlöðver Sigurðsson |
Subject | Re: [Csnd] Saving score lines to text file |
Not as far as I know, but you can always call system commands from csound with system_i i_ system_i "rm file.txt" ;; (if you're on mac/linux) On Sun, 27 Oct 2019 at 12:51, Bernard Geyer <micamusic2@gmail.com> wrote: And that does not work either: |
Date | 2019-10-27 12:02 |
From | Bernard Geyer |
Subject | Re: [Csnd] Saving score lines to text file |
And that does not work either: instr save_params S_FileName strget p4 iHandle fiopen S_FileName, 1 S_Msg sprintf "i \"set_audio_file\" 0 0 \"%s\"\n", gSAudioPath fprints iHandle, S_Msg ;fprints doesn't support strings! fprints iHandle, "i \"set_params\" 0 0 %g %g %g %g\n", \ gkPitchScale, gkTimeScale, gkGrainSize, gkOverlaps ficlose iHandle turnoff endin Is there an opcode to delete a file ? -- Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here |
Date | 2019-10-27 12:06 |
From | Bernard Geyer |
Subject | Re: [Csnd] Saving score lines to text file |
SORRY !!!!! ficlose works !!! I used the wrong version of save_params. ( I have one with gui, and one with text) -- Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here |