Csound Csound-dev Csound-tekno Search About

[Csnd] Csound API ref manual?

Date2011-12-19 00:26
FromIain Duncan
Subject[Csnd] Csound API ref manual?
Hey folks, I've been away from Csound for some while and now want to embed it in a jack app. Is there a Csound API ref manual somewhere yet? googling for one didn't turn anything finished up but maybe it's not getting a high hit?

thanks
Iain

Date2011-12-19 01:10
FromMichael Gogins
SubjectRe: [Csnd] Csound API ref manual?
There is an API reference which is complete as to function signatures,
and a basic set of examples in the csound/examples directory.

Csound already has Jack facilities: Jack I/O from the command line,
and the Jacko opcode suite, which can receive and send Jack audio and
MIDI from other Jack clients within the Csound performance.

What exactly do you mean, "embed it in a Jack app?" If you already
have a Jack application and want to use Csound inside this app for
synthesis and processing, you can use the Csound API for access to the
spin (audio input) and spout (audio output) buffers. You could also
send and receive MIDI although this would be somewhat more involved,
either by installing a custom Csound MIDI driver or by creating new
opcodes.

Again, what is your envisioned use?

Hope this helps,
Mike

On Sun, Dec 18, 2011 at 7:26 PM, Iain Duncan  wrote:
> Hey folks, I've been away from Csound for some while and now want to embed
> it in a jack app. Is there a Csound API ref manual somewhere yet? googling
> for one didn't turn anything finished up but maybe it's not getting a high
> hit?
>
> thanks
> Iain


Date2011-12-19 01:15
FromIain Duncan
SubjectRe: [Csnd] Csound API ref manual?
On Sun, Dec 18, 2011 at 5:10 PM, Michael Gogins <michael.gogins@gmail.com> wrote:
There is an API reference which is complete as to function signatures,
and a basic set of examples in the csound/examples directory.

Thanks for the pointer. Is there any reason this is not included in the manual or on some other kind of online manual? It seems a bit strange to me that googling "csound API reference manual" turns up nothing.  


Csound already has Jack facilities: Jack I/O from the command line,
and the Jacko opcode suite, which can receive and send Jack audio and
MIDI from other Jack clients within the Csound performance.

What exactly do you mean, "embed it in a Jack app?" If you already
have a Jack application and want to use Csound inside this app for
synthesis and processing, you can use the Csound API for access to the
spin (audio input) and spout (audio output) buffers.

That's what I want yes, I want all I/O, gui, audio, midi, osc, handled by my app.  I just want to send csound events over the api and get back blocks of audio. Final mixing and audio will be calculated in my app and then sent out from there over jack outputs.

Thanks!
Iain


Date2011-12-19 01:20
FromIain Duncan
SubjectRe: [Csnd] Csound API ref manual?
On Sun, Dec 18, 2011 at 5:15 PM, Iain Duncan <iainduncanlists@gmail.com> wrote:
On Sun, Dec 18, 2011 at 5:10 PM, Michael Gogins <michael.gogins@gmail.com> wrote:
There is an API reference which is complete as to function signatures,

Sorry, where is this API reference?
 
and a basic set of examples in the csound/examples directory.

Those don't appear to work the way I'm intending so if anyone else has examples of using the Csound api within an application structure where the host app has an audio callback that calculates a buffer of samples ( either RtAudio, PortAudio, or Jack ), I'd love to see it!

thanks
Iain


Date2011-12-19 01:34
FromSteven Yi
SubjectRe: [Csnd] Csound API ref manual?
The file H/csound.h that comes with the Csound source documents all of the public functions.  Rory's intro the API is still relevant:


Otherwise, the basics of what you'll be doing is:

1. csoundCreate
2. csoundPreCompile
3. csoundSetHostImplementedAudioIO(cs, 1, 0);
4. csoundCompile

that'll get the Csound object compiled.  If all is well, store your Csound* in a place that can be accessed by your audio callback.  Also, be sure to turn off any audio callback within Csound itself by passing -+rtaudio=null, though step 3 above should do it too. Then in your audio callback, call either csoundPerformKsmps or csoundPerformBuffer, and afterwards you get the spout (the pointer to the audio output samples) using code like:

    MYFLT *spout = csoundGetSpout(cs);

then with a for-loop, you could read each sample, taking into account nchnls and the audio being interleaved.

Hope that helps!
steven

On Sun, Dec 18, 2011 at 8:20 PM, Iain Duncan <iainduncanlists@gmail.com> wrote:
On Sun, Dec 18, 2011 at 5:15 PM, Iain Duncan <iainduncanlists@gmail.com> wrote:
On Sun, Dec 18, 2011 at 5:10 PM, Michael Gogins <michael.gogins@gmail.com> wrote:
There is an API reference which is complete as to function signatures,

Sorry, where is this API reference?
 
and a basic set of examples in the csound/examples directory.

Those don't appear to work the way I'm intending so if anyone else has examples of using the Csound api within an application structure where the host app has an audio callback that calculates a buffer of samples ( either RtAudio, PortAudio, or Jack ), I'd love to see it!

thanks
Iain



Date2011-12-19 01:56
FromMichael Gogins
SubjectRe: [Csnd] Csound API ref manual?
csound.h only documents C functions. csound.hpp documents a C++
wrapper of those functions. CppSound.hpp documents additional
functions. This is explained at the beginning of the Csound API
Reference. If this does not google it is because the maintainers of
the Web site have not linked it, I suppose. It is included in the
Windows installer, and you can also generate the reference simply by
running doxygen in the Csound source directory.

CsoundVST, the sources for which are in Csound GIT, uses the API
exactly as you wish, but it uses the CppSound.hpp header as that is
more usable in a context where the application needs to embed the
Csound sco and orc in an internal patch format.

In case it is not obvious what is going on, the CsoundVST plugin class
inherents from both CppSound and from AudioEffectX, the VST plugin
base class. Therefore the CsoundVST class "mixes in" all the
functionality of Csound and all the functionality of the VST plugin,
and has to add only a small amount of additional functionality.

There are C++ wrappers to the Jack API that may (I haven't tried it,
myself, but a superficial and hasty glimpse looks good) enable you to
do much the same thing as I did with the AudioEffectX wrapper for the
VST API: http://trac.jackaudio.org/wiki/WalkThrough/Dev/Cpp.

Hope this helps,
Mike

On Sun, Dec 18, 2011 at 8:34 PM, Steven Yi  wrote:
> The file H/csound.h that comes with the Csound source documents all of the
> public functions.  Rory's intro the API is still relevant:
>
> http://www.csounds.com/articles/RoryWalsh_CsoundAPI.pdf
>
> Otherwise, the basics of what you'll be doing is:
>
> 1. csoundCreate
> 2. csoundPreCompile
> 3. csoundSetHostImplementedAudioIO(cs, 1, 0);
> 4. csoundCompile
>
> that'll get the Csound object compiled.  If all is well, store your Csound*
> in a place that can be accessed by your audio callback.  Also, be sure to
> turn off any audio callback within Csound itself by passing -+rtaudio=null,
> though step 3 above should do it too. Then in your audio callback, call
> either csoundPerformKsmps or csoundPerformBuffer, and afterwards you get the
> spout (the pointer to the audio output samples) using code like:
>
>     MYFLT *spout = csoundGetSpout(cs);
>
> then with a for-loop, you could read each sample, taking into account nchnls
> and the audio being interleaved.
>
> Hope that helps!
> steven
>
> On Sun, Dec 18, 2011 at 8:20 PM, Iain Duncan 
> wrote:
>>
>> On Sun, Dec 18, 2011 at 5:15 PM, Iain Duncan 
>> wrote:
>>>
>>> On Sun, Dec 18, 2011 at 5:10 PM, Michael Gogins
>>>  wrote:
>>>>
>>>> There is an API reference which is complete as to function signatures,
>>
>>
>> Sorry, where is this API reference?
>>
>>>>
>>>> and a basic set of examples in the csound/examples directory.
>>
>>
>> Those don't appear to work the way I'm intending so if anyone else has
>> examples of using the Csound api within an application structure where the
>> host app has an audio callback that calculates a buffer of samples ( either
>> RtAudio, PortAudio, or Jack ), I'd love to see it!
>>
>> thanks
>> Iain
>>
>



-- 
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"


Date2011-12-19 02:46
FromIain Duncan
SubjectRe: [Csnd] Csound API ref manual?
On Sun, Dec 18, 2011 at 5:56 PM, Michael Gogins <michael.gogins@gmail.com> wrote:
csound.h only documents C functions. csound.hpp documents a C++
wrapper of those functions. CppSound.hpp documents additional
functions. This is explained at the beginning of the Csound API
Reference. If this does not google it is because the maintainers of
the Web site have not linked it, I suppose. It is included in the
Windows installer, and you can also generate the reference simply by
running doxygen in the Csound source directory.

Thanks for that tip.
 

CsoundVST, the sources for which are in Csound GIT, uses the API
exactly as you wish, but it uses the CppSound.hpp header as that is
more usable in a context where the application needs to embed the
Csound sco and orc in an internal patch format.

In case it is not obvious what is going on, the CsoundVST plugin class
inherents from both CppSound and from AudioEffectX, the VST plugin
base class. Therefore the CsoundVST class "mixes in" all the
functionality of Csound and all the functionality of the VST plugin,
and has to add only a small amount of additional functionality.

There are C++ wrappers to the Jack API that may (I haven't tried it,
myself, but a superficial and hasty glimpse looks good) enable you to
do much the same thing as I did with the AudioEffectX wrapper for the
VST API: http://trac.jackaudio.org/wiki/WalkThrough/Dev/Cpp.

thanks, I will look at those sources.

Iain
 

Date2011-12-19 11:53
FromRory Walsh
SubjectRe: [Csnd] Csound API ref manual?
Hi Iain. You might also want to check out the source for csLADSPA

http://csound.git.sourceforge.net/git/gitweb.cgi?p=csound/csound5.git;a=blob;f=frontends/csladspa/csladspa.cpp;h=91cf0938a7d715d6e639f2f6899c236990c3de1b;hb=b1a38b26b6fe4afba05ea10f4e908d315120946f

My Cabbage project using a similar processing routine. You can view it here

http://code.google.com/p/cabbage/source/browse/#svn%2Ftrunk%2FSource

Look at CabbagePluginProcesser.cpp.

Rory.


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"

Date2011-12-19 20:55
FromIain Duncan
SubjectRe: [Csnd] Csound API ref manual?
On Mon, Dec 19, 2011 at 3:53 AM, Rory Walsh <rorywalsh@ear.ie> wrote:
Hi Iain. You might also want to check out the source for csLADSPA

http://csound.git.sourceforge.net/git/gitweb.cgi?p=csound/csound5.git;a=blob;f=frontends/csladspa/csladspa.cpp;h=91cf0938a7d715d6e639f2f6899c236990c3de1b;hb=b1a38b26b6fe4afba05ea10f4e908d315120946f

My Cabbage project using a similar processing routine. You can view it here

http://code.google.com/p/cabbage/source/browse/#svn%2Ftrunk%2FSource

Look at CabbagePluginProcesser.cpp.

Thanks! That sounds like exactly what I need. =)

Iain