void test_buffer_run(void)
{
    csoundSetGlobalEnv("OPCODE6DIR64", "../../");
    CSOUND *csound = csoundCreate(0);
    csoundCreateMessageBuffer(csound, 0);
    int result = csoundCompileOrc(csound, "instr 1\n"
                                  "asig oscil 0.1, 440\n"
                                  "out asig\n"
                                  "endin\n");
    csoundReadScore(csound, "i 1 0 0.1\n");
    csoundStart(csound);

    csoundPerform(csound);

    while (csoundGetMessageCnt(csound)) {
        const char * msg = csoundGetFirstMessage(csound);
        CU_ASSERT_PTR_NOT_NULL(msg);
        csoundPopFirstMessage(csound);
        printf("CSOUND MESSAGE: %s", msg);
    }

    csoundCleanup(csound);
    csoundDestroyMessageBuffer(csound);
    csoundDestroy(csound);
}
Ejemplo n.º 2
0
int main(int arg, char** argv) {
    random_line *amp, *freq;

    /* initialize random seed: */
    srand (time(NULL));

    csoundInitialize(CSOUNDINIT_NO_ATEXIT);

    CSOUND* csound = csoundCreate(NULL);

    /* Using SetOption() to configure Csound 
    Note: use only one commandline flag at a time */
    csoundSetOption(csound, "-odac");

    /* Compile the Csound Orchestra string */
    csoundCompileOrc(csound, orc);

    /* Read in the Score from loop-generated String */
    csoundReadScore(csound, "i1 0 60");

    /* When compiling from strings, this call is necessary 
    * before doing any performing */
    csoundStart(csound);

    /* Create a random_line for use with Amplitude */
    amp = random_line_create(0.4, 0.2);

    /* Create a random_line for use with Frequency */
    freq = random_line_create(400.0, 80.0);

    
    /* Initialize channel values before running Csound */
    csoundSetControlChannel(csound, "amp", random_line_tick(amp));
    csoundSetControlChannel(csound, "freq", random_line_tick(freq));

    /* The following is our main performance loop. We will perform one 
    * block of sound at a time and continue to do so while it returns 0, 
    * which signifies to keep processing.  
    */
    while (csoundPerformKsmps(csound) == 0) {
        /* Update Channel Values */
        csoundSetControlChannel(csound, "amp", random_line_tick(amp));
        csoundSetControlChannel(csound, "freq", random_line_tick(freq));
    }

    csoundStop(csound);
    return 0;
}
Ejemplo n.º 3
0
int main(int arg, char** argv) {

    /* initialize random seed: */
    srand (time(NULL));

    csoundInitialize(CSOUNDINIT_NO_ATEXIT);

    CSOUND* csound = csoundCreate(NULL);

    /* Using SetOption() to configure Csound 
    Note: use only one commandline flag at a time */
    csoundSetOption(csound, "-odac");

    /* Compile the Csound Orchestra string */
    csoundCompileOrc(csound, orc);

    /* Read in the Score from pre-written String */
    /*csoundReadScore(csound, (char*)sco);*/

    /* Read in the Score from loop-generated String */
    /*csoundReadScore(csound, generate_example2());*/

    /* Read in the Score from loop-generated String */
    csoundReadScore(csound, generate_example3());

    /* When compiling from strings, this call is necessary 
    * before doing any performing */
    csoundStart(csound);

    /* The following is our main performance loop. We will perform one 
    * block of sound at a time and continue to do so while it returns 0, 
    * which signifies to keep processing.  We will explore this loop 
    * technique in further examples. 
    */

    while (csoundPerformKsmps(csound) == 0) {
      /* pass for now */
    }

    csoundStop(csound);

    return 0;
}
Ejemplo n.º 4
0
int main(int arg, char** argv) {
  void* thread;

  csoundInitialize(CSOUNDINIT_NO_ATEXIT);

  CSOUND* csound = csoundCreate(NULL);

  /* Using SetOption() to configure Csound 
  Note: use only one commandline flag at a time */
  csoundSetOption(csound, "-odac");

  /* Compile the Csound Orchestra string */
  csoundCompileOrc(csound, orc);

  /* Compile the Csound SCO String */
  csoundReadScore(csound, (char*)sco);

  /* When compiling from strings, this call is necessary 
   * before doing any performing */
  csoundStart(csound);

  /* Create a new thread that will use our performance function and 
   * pass in our CSOUND structure. This call is asynchronous and 
   * will immediately return back here to continue code execution
   */
  thread = csoundCreateThread(&performance_function, (void*)csound);
 
  /* Join will wait for the other thread to complete. If we did not 
   * call csoundJoinThread(), after csoundCreateThread() returns we 
   * would immediately move to the next line, csoundStop().  That 
   * would stop Csound without really giving it time to run.
   */
  csoundJoinThread(thread);

  csoundStop(csound);

  /* clean up Csound; this is useful if you're going to reuse a Csound 
   * instance 
   */
  csoundCleanup(csound);

  return 0;
}
Ejemplo n.º 5
0
int CsoundObj_readScore(CsoundObj *self, const char *scoreString)
{
    return csoundReadScore(self->csound, scoreString);
}
Ejemplo n.º 6
0
uint32_t CsoundObj_readScore(CsoundObj *self, const char *string)
{
	return csoundReadScore(self->csound, (char *)string);
}
Ejemplo n.º 7
0
int read_score_i(CSOUND *csound, COMPILE *p){
    *p->res = (MYFLT)(csoundReadScore(csound, ((STRINGDAT *)p->str)->data));
    return OK;
}