Csound Csound-dev Csound-tekno Search About

[Csnd] Printing to File

Date2013-02-11 08:12
FromAlex Weiss
Subject[Csnd] Printing to File
Hi list

I'm trying to do some fairly easy (I think) printing to file, but for some reason I can't figure out how to do it. Here's what I'm trying to accomplish: I want an instrument to write a custom string to a text file once for every invocation. I would like the file to stay open through the course of the performance so that the instrument appends to the text file instead of reopening and overwriting it on every new invocation. Is that possible? fprints doesn't seem to do the job.

Thanks,
Alex

Date2013-02-11 09:51
FromTarmo Johannes
SubjectRe: [Csnd] Printing to File

Hi,

 

If there is something you cannot do with csound, do it in python!

Would

http://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files

and

http://www.csounds.com/manual/html/py.html

http://www.csounds.com/journal/issue6/pythonOpcodes.html

 

help you?

 

greetings,

tarmo

 

On Monday, February 11, 2013 12:12:49 AM Alex Weiss wrote:

Hi list


I'm trying to do some fairly easy (I think) printing to file, but for some reason I can't figure out how to do it. Here's what I'm trying to accomplish: I want an instrument to write a custom string to a text file once for every invocation. I would like the file to stay open through the course of the performance so that the instrument appends to the text file instead of reopening and overwriting it on every new invocation. Is that possible? fprints doesn't seem to do the job.


Thanks,

Alex




Date2013-02-11 18:08
Fromjoachim heintz
SubjectRe: [Csnd] Printing to File
hi alex -

of course this is possible. one solution:



instr Print
kPrint metro 1
kCycle init 1
if kPrint == 1 then
fprintks "write_out.txt", "kCycle = %d\n", kCycle
kCycle = kCycle + 1
endif
endin


i "Print" 0 10



if you need to write at init-time instead of during the performance, you 
can have a look in the csoundqt example "ImitativeAdditive" (Examples > 
Synths).

best -

	joachim


Am 11.02.2013 09:12, schrieb Alex Weiss:
> Hi list
>
> I'm trying to do some fairly easy (I think) printing to file, but for
> some reason I can't figure out how to do it. Here's what I'm trying to
> accomplish: I want an instrument to write a custom string to a text file
> once for every invocation. I would like the file to stay open through
> the course of the performance so that the instrument appends to the text
> file instead of reopening and overwriting it on every new invocation. Is
> that possible? fprints doesn't seem to do the job.
>
> Thanks,
> Alex

Date2013-02-12 03:27
FromAlex Weiss
SubjectRe: [Csnd] Printing to File
Hi Joachim,

Thanks for your answer. I do indeed need i-time output, but your csd made me give fprints another try. I could have sworn that the last time I tried it it created a new file on every new invocation, but it worked this time!

Alex

On Mon, Feb 11, 2013 at 10:08 AM, joachim heintz <jh@joachimheintz.de> wrote:
hi alex -

of course this is possible. one solution:

<CsoundSynthesizer>
<CsInstruments>
instr Print
kPrint metro 1
kCycle init 1
if kPrint == 1 then
fprintks "write_out.txt", "kCycle = %d\n", kCycle
kCycle = kCycle + 1
endif
endin
</CsInstruments>
<CsScore>
i "Print" 0 10
</CsScore>
</CsoundSynthesizer>

if you need to write at init-time instead of during the performance, you can have a look in the csoundqt example "ImitativeAdditive" (Examples > Synths).

best -

        joachim


Am 11.02.2013 09:12, schrieb Alex Weiss:

Hi list

I'm trying to do some fairly easy (I think) printing to file, but for
some reason I can't figure out how to do it. Here's what I'm trying to
accomplish: I want an instrument to write a custom string to a text file
once for every invocation. I would like the file to stay open through
the course of the performance so that the instrument appends to the text
file instead of reopening and overwriting it on every new invocation. Is
that possible? fprints doesn't seem to do the job.

Thanks,
Alex


Send bugs reports to the Sourceforge bug tracker
           https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"