Csound Csound-dev Csound-tekno Search About

Re: [Cs-dev] scsort and scxtract

Date2005-10-27 20:45
FromMichael Gogins
SubjectRe: [Cs-dev] scsort and scxtract
This type of comment is exactly what I meant, yes, and that is the appropriate level of detail.

As for the CScore API, if you will give me a little story about how people will use it, I can think better how to wrap it.

I.e., does the Cscore function itself create an instance of Csound, or do you first create an instance of Csound and then call the CScore functions off that?

Regards,
Mike

-----Original Message-----
From: Anthony Kozar 
Sent: Oct 27, 2005 2:47 PM
To: New Csound Developer list 
Subject: Re: [Cs-dev] scsort and scxtract

Is something like this sufficient for each function, or is it more involved?
(Sorry, do not know anything about Doxygen).

  /**
   * Initialise Csound library; should be called once before creating
   * any Csound instances.
   * Returns zero on success.
   */
  PUBLIC int csoundInitialize(int *argc, char ***argv, int flags);


While we are on the subject, can we include the Cscore API in the language
wrappers as well?  Will the EVENT and EVLIST data structures be usuable from
those languages?

Anthony


Michael Gogins wrote on 10/27/05 1:10 PM:

> It would be helpful if the new CScore calls in the API had Doxygen-style
> comments. Just a hint what they are for would be nice.



-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel





-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2005-10-28 19:08
FromAnthony Kozar
SubjectRe: [Cs-dev] scsort and scxtract
Michael Gogins wrote on 10/27/05 3:45 PM:

> This type of comment is exactly what I meant, yes, and that is the appropriate
> level of detail.

Ok.  I will get around to this eventually.

> As for the CScore API, if you will give me a little story about how people
> will use it, I can think better how to wrap it.
> 
> I.e., does the Cscore function itself create an instance of Csound, or do you
> first create an instance of Csound and then call the CScore functions off
> that?

The cscore() function that the user writes has always essentially been a
callback.  Whether it was compiled into csound or into a standalone cscore
application, main() was always provided by the Csound code and would take
care of setting up the system and opening files, etc. before calling the
user cscore() routine.

With Csound 5, cscore() now takes a CSOUND* argument but that instance is
provided by Csound.  cscore() then can use this pointer to call all of the
Cscore API functions.

This is all still the "traditional" way of using Cscore, and continues to
work with Csound 5.  However, I have also made it possible now to do things
a little bit differently.

A host application can now also create an instance of Csound and prepare it
for Cscore processing by calling csoundInitializeCscore().  Then it can call
any part of the Cscore API and the need to write a cscore() function and
link it to either Csound or a main() stub is no longer there.

So you could do this, for example:

CSOUND*  cs;
int      err;
FILE*    in, out;
EVENT*   e;
EVLIST*  a;

cs = csoundCreate(NULL);

// open input and output scores here

err = csoundInitializeCscore(cs, in, out);
if (err)  return;

// make a score in memory
a = cscoreCreateList(cs, 11);  // 11 event slots

for (int i = 0; i < 10; i++) {
  e = cscoreCreateEvent(cs, 4);  // 4 p-fields
  e->op = 'i';
  e->p[1] = 1;            // instrument 1
  e->p[2] = i * 0.25;     // start every quarter beat
  e->p[3] = 0.10          // 0.10 beats long
  e->p[4] = 64.0 * (i+1)  // play harmonic series on 64Hz
  a = cscoreListAppend(cs, a, e);
}

a = cscoreListAppendStringEvent(cs, a, "e"); // add e-card

cscoreListPut(cs, a);        // write notes to output score
cscoreFreeListEvents(cs, a); // reclaim memory

// close the score files here
// could now call csoundReset(cs) and then use the
// same instance for rendering the score we created


Of course, Cscore is also very good for reading in existing scores and
modifying them.  (In fact, it always requires an input score to run -- maybe
I should find a way to change that).

Anyways, let me know if I can explain this any better.

Anthony Kozar
anthonykozar AT sbcglobal DOT net
http://akozar.spymac.net/



-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net