Csound Csound-dev Csound-tekno Search About

[Csnd] Csound API - Passing a CSD as string?

Date2010-07-23 22:32
FromJacob Joaquin
Subject[Csnd] Csound API - Passing a CSD as string?
I'm using the Csound API with Java / Processing.  Is there anyway to
pass a CSD as a string to either an instance of Csound or CppSound and
use it in a performance thread without ever having to reference an
external Csd file?

Best,
Jake

Date2010-07-24 00:58
FromMichael Gogins
Subject[Csnd] Re: Csound API - Passing a CSD as string?

Yes, but.

CppSound.setCSD() will do, but you must call exportForPerformance() before compile() and perform(). There are examples.

MKG from cell phone

On Jul 23, 2010 5:33 PM, "Jacob Joaquin" <jacobjoaquin@gmail.com> wrote:

I'm using the Csound API with Java / Processing.  Is there anyway to
pass a CSD as a string to either an instance of Csound or CppSound and
use it in a performance thread without ever having to reference an
external Csd file?

Best,
Jake
--
The Csound Blog - http://csound.noisepages.com/
Slipmat - http://slipmat.noisepages.com/


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"


Date2010-07-24 01:21
FromJacob Joaquin
Subject[Csnd] Re: Re: Csound API - Passing a CSD as string?
On Fri, Jul 23, 2010 at 4:58 PM, Michael Gogins
 wrote:
> Yes, but.
>
> CppSound.setCSD() will do, but you must call exportForPerformance() before
> compile() and perform(). There are examples.

The problem I'm running into is that I get the error message


BEGAN CppSound::compile()...
No Csound command.


using this code:


csnd.csoundInitialize(null, null, csnd.CSOUNDINIT_NO_SIGNAL_HANDLER);
csound = new CppSound();
CsoundFile cf = csound.getCsoundFile();
cf.setCSD(csd);  // csd is my csd string
cf.exportForPerformance();
int did_compile = csound.compile();

if (did_compile == 0) {
    CsoundPerformanceThread thread =
            new CsoundPerformanceThread(csound);
    thread.Play();
}


I've this to work by including


cf.setCommand("csound -d -A -odevaudio null.csd");


just prior to exportForPerformance().  But then I'm back to where I
started, having to specify a file.  If anyone could point me to these
examples, I'd much appreciate it.

Best,
Jake

Date2010-07-24 01:21
FromSteven Yi
Subject[Csnd] Re: Csound API - Passing a CSD as string?
In blue I create a temp file (the file api in Java can create one for
you that will clean itself up when the program quits), write the csd
out to it, then run csound. Is there an issue with doing this in your
project or is it more of an api design question?

On 7/23/10, Jacob Joaquin  wrote:
> I'm using the Csound API with Java / Processing.  Is there anyway to
> pass a CSD as a string to either an instance of Csound or CppSound and
> use it in a performance thread without ever having to reference an
> external Csd file?
>
> Best,
> Jake
> --
> The Csound Blog - http://csound.noisepages.com/
> Slipmat - http://slipmat.noisepages.com/
>
>
> 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"
>
>

Date2010-07-24 01:49
FromMichael Gogins
Subject[Csnd] Re: Re: Re: Csound API - Passing a CSD as string?
Your CSD needs to have one line containing a complete Csound command
with filenames and all.

Regards,
Mike3

On Fri, Jul 23, 2010 at 8:21 PM, Jacob Joaquin  wrote:
> On Fri, Jul 23, 2010 at 4:58 PM, Michael Gogins
>  wrote:
>> Yes, but.
>>
>> CppSound.setCSD() will do, but you must call exportForPerformance() before
>> compile() and perform(). There are examples.
>
> The problem I'm running into is that I get the error message
>
>
> BEGAN CppSound::compile()...
> No Csound command.
>
>
> using this code:
>
>
> csnd.csoundInitialize(null, null, csnd.CSOUNDINIT_NO_SIGNAL_HANDLER);
> csound = new CppSound();
> CsoundFile cf = csound.getCsoundFile();
> cf.setCSD(csd);  // csd is my csd string
> cf.exportForPerformance();
> int did_compile = csound.compile();
>
> if (did_compile == 0) {
>    CsoundPerformanceThread thread =
>            new CsoundPerformanceThread(csound);
>    thread.Play();
> }
>
>
> I've this to work by including
>
>
> cf.setCommand("csound -d -A -odevaudio null.csd");
>
>
> just prior to exportForPerformance().  But then I'm back to where I
> started, having to specify a file.  If anyone could point me to these
> examples, I'd much appreciate it.
>
> Best,
> Jake
> --
> The Csound Blog - http://csound.noisepages.com/
> Slipmat - http://slipmat.noisepages.com/
>
>
> 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"
>
>



-- 
Michael Gogins
Irreducible Productions
http://www.michael-gogins.com
Michael dot Gogins at gmail dot com


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"


Date2010-07-24 01:52
FromJacob Joaquin
Subject[Csnd] Re: Re: Re: Re: Csound API - Passing a CSD as string?
On Fri, Jul 23, 2010 at 5:49 PM, Michael Gogins
 wrote:
> Your CSD needs to have one line containing a complete Csound command
> with filenames and all.

Why?

Best,
Jake

Date2010-07-24 02:00
FromMichael Gogins
Subject[Csnd] Re: Re: Re: Re: Re: Csound API - Passing a CSD as string?
The whole Csound API arose out of my efforts to create a more
efficient composing environment for myself. I wanted .orc and .sco
files to be left after each rendering so that I could construct pieces
even if I lost the score generating code. This actually happened
several times (I make lots of pieces and sometimes go back to ones I
did years and years ago).

If you do not care for this behavior, you can build the CSD file
programmatically, then just save the CSD to a temporary file and
render that, and Csound will run normally and the temporary files will
be deleted. You can then make your program delete the temporary .csd
file.

Regards,
Mike

On Fri, Jul 23, 2010 at 8:52 PM, Jacob Joaquin  wrote:
> On Fri, Jul 23, 2010 at 5:49 PM, Michael Gogins
>  wrote:
>> Your CSD needs to have one line containing a complete Csound command
>> with filenames and all.
>
> Why?
>
> Best,
> Jake
> --
> The Csound Blog - http://csound.noisepages.com/
> Slipmat - http://slipmat.noisepages.com/
>
>
> 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"
>
>



-- 
Michael Gogins
Irreducible Productions
http://www.michael-gogins.com
Michael dot Gogins at gmail dot com


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"


Date2010-07-24 02:01
FromJacob Joaquin
Subject[Csnd] Re: Re: Csound API - Passing a CSD as string?
> Is there an issue with doing this in your
> project or is it more of an api design question?

A combination of both. To make a long story short, I'm looking into
the practicality of using Processing as a platform for developing
little synth/music-machine front-ends for Csound. My problem is with
relative and absolute paths with Processing. There might be a way
around it, but I'm trying to side step the issue first by doing away
with having to specify a file.  So now it's a bit of a mental
exercise.  (What's the point of having the function CppSound.setCsd()
if I still have to specify a file anyways?)

I'll go into more detail later when I have time. I'm out the door.

Best,
Jake

Date2010-07-24 02:08
FromMichael Gogins
Subject[Csnd] Re: Re: Re: Csound API - Passing a CSD as string?
I agree with you actually. I couldn't find a way around it that
satisfied me. Let me know if you figure it out, or have a suggestion.

The whole problem would be solved if Csound could render from a CSD
file in memory -- a big string. I'm sure this is possible, I just
never took the trouble to figure it out since the current behavior is
not a big problem for me, more of an esthetic annoyance.

Regards,
Mike


On Fri, Jul 23, 2010 at 9:01 PM, Jacob Joaquin  wrote:
>> Is there an issue with doing this in your
>> project or is it more of an api design question?
>
> A combination of both. To make a long story short, I'm looking into
> the practicality of using Processing as a platform for developing
> little synth/music-machine front-ends for Csound. My problem is with
> relative and absolute paths with Processing. There might be a way
> around it, but I'm trying to side step the issue first by doing away
> with having to specify a file.  So now it's a bit of a mental
> exercise.  (What's the point of having the function CppSound.setCsd()
> if I still have to specify a file anyways?)
>
> I'll go into more detail later when I have time. I'm out the door.
>
> Best,
> Jake
> --
> The Csound Blog - http://csound.noisepages.com/
> Slipmat - http://slipmat.noisepages.com/
>
>
> 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"
>
>



-- 
Michael Gogins
Irreducible Productions
http://www.michael-gogins.com
Michael dot Gogins at gmail dot com


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"