예제 #1
0
void test_breakpoint_remove(void)
{
    int i;
    int break_count = 0;
    CSOUND* csound = csoundCreate(NULL);
    csoundCreateMessageBuffer(csound, 0);
    csoundCompileOrc(csound, "instr 1\nasig oscil 1, p4\nendin\n");
    csoundInputMessage(csound, "i 1.1 0   1 440");
    csoundInputMessage(csound, "i 1.2 0   1 880");
    csoundInputMessage(csound, "i 1.1 0.1 1 440");
    csoundStart(csound);
    csoundDebuggerInit(csound);
    csoundSetBreakpointCallback(csound, brkpt_cb2, (void *) &break_count);
    csoundSetInstrumentBreakpoint(csound, 1.1, 0);

    for (i = 0; i < 10; i++) {
        csoundPerformKsmps(csound);
        csoundDebugContinue(csound);
    }

    csoundRemoveInstrumentBreakpoint(csound, 1.1);
    for (i = 0; i < 10; i++) {
        csoundPerformKsmps(csound);
        csoundDebugContinue(csound);
    }
    CU_ASSERT(break_count == 1);

    csoundDebuggerClean(csound);
    csoundDestroy(csound);
}
예제 #2
0
void test_line_breakpoint_add_remove(void)
{
    CSOUND* csound = csoundCreate(NULL);
    csoundCreateMessageBuffer(csound, 0);
    count = 0;
    csoundCompileOrc(csound, "instr 1\n"
                     "Svar init \"hello\"\n"
                     "ksig line 0, p3, 1\n"
                     "ksig2 line 1, p3, 0\n"
                     "asig3 oscils 0.5, 440, 0.5\n"
                     "endin\n");

    csoundInputMessage(csound, "i 1 0  1.1 440");
    csoundStart(csound);
    csoundDebuggerInit(csound);
    csoundSetBreakpointCallback(csound, brkpt_cb5, NULL);
    csoundSetBreakpoint(csound, 5, 1, 0);
    csoundPerformKsmps(csound);
    csoundDebugContinue(csound);
    csoundPerformKsmps(csound); // This block performs
    csoundPerformKsmps(csound); // This block breaks

    csoundRemoveBreakpoint(csound, 5, 1);
    csoundPerformKsmps(csound);
    csoundPerformKsmps(csound);
    csoundPerformKsmps(csound);
    csoundPerformKsmps(csound);
    csoundPerformKsmps(csound);

    csoundDebuggerClean(csound);
    csoundDestroy(csound);
    CU_ASSERT_EQUAL(count, 2);
}
예제 #3
0
 /** pass a string event straight through to csound.  only works if perf. thread is running */
 void inputMessage(const char * msg)
 {
     if (!csound) {
         ll->printf(1, "skipping %s, csound==NULL\n", __FUNCTION__);
         return;
     }
     if (!ThreadID)
     {
         if (_debug && (VERBOSE > 1)) fprintf(_debug, "skipping %s, ThreadID==NULL\n", __FUNCTION__);
         return ;
     }
     if (_debug &&(VERBOSE > 3)) fprintf(_debug, "%s\n", msg);
     csoundInputMessage(csound, msg);
 }
예제 #4
0
void test_bkpt_instrument(void)
{
    CSOUND* csound = csoundCreate(NULL);
    csoundCreateMessageBuffer(csound, 0);
    csoundCompileOrc(csound, "instr 1\n Svar init \"hello\"\n endin\n");
    csoundInputMessage(csound, "i 1 0  1.1 440");
    csoundStart(csound);
    csoundDebuggerInit(csound);
    csoundSetBreakpointCallback(csound, brkpt_cb4, NULL);
    csoundSetInstrumentBreakpoint(csound, 1, 0);

    csoundPerformKsmps(csound);

    csoundDebuggerClean(csound);
    csoundDestroy(csound);
}
예제 #5
0
void test_line_breakpoint(void)
{
    CSOUND* csound = csoundCreate(NULL);
    csoundCreateMessageBuffer(csound, 0);
    count = 0;
    csoundCompileOrc(csound, "instr 1\n"
                     "Svar init \"hello\"\n"
                     "ksig line 0, p3, 1\n"
                     "ksig2 line 1, p3, 0\n"
                     "asig3 oscils 0.5, 440, 0.5\n"
                     "endin\n");

    csoundInputMessage(csound, "i 1 0  1.1 440");
    csoundStart(csound);
    csoundDebuggerInit(csound);
    csoundSetBreakpointCallback(csound, brkpt_cb6, NULL);
    csoundSetBreakpoint(csound, 5, 1, 0);
    csoundPerformKsmps(csound);

    csoundDebugContinue(csound);
    csoundPerformKsmps(csound);
    csoundSetBreakpoint(csound, 4, 1, 0);
    csoundPerformKsmps(csound);

    csoundDebugContinue(csound);
    csoundPerformKsmps(csound);
    csoundRemoveBreakpoint(csound, 4, 1);
    csoundPerformKsmps(csound);

    csoundDebugContinue(csound);
    csoundSetBreakpoint(csound, 1, 1, 0); // This breakpoint shouldn't be triggered as it's an init opcode
    csoundPerformKsmps(csound);

    csoundDebugContinue(csound);
    csoundSetBreakpoint(csound, 2, 2, 0); // This breakpoint shouldn't be triggered as instr 2 is not defined
    csoundPerformKsmps(csound);

    csoundDebuggerClean(csound);

    csoundDestroy(csound);

    CU_ASSERT_EQUAL(count, 2);
}
예제 #6
0
void test_next(void)
{
    CSOUND* csound = csoundCreate(NULL);
    csoundCreateMessageBuffer(csound, 0);
    count = 0;
    csoundCompileOrc(csound, "instr 1\n"
                             "Svar init \"hello\"\n"
                             "ksig line 0, p3, 1\n"
                             "ksig2 line 1, p3, 0\n"
                             "asig3 oscils 0.5, 440, 0.5\n"
                             "endin\n"
                             "instr 30\n"
                             "kvar init 10\n"
                             "kvar = kvar + 1\n"
                             "ksig2 line 1, p3, 0\n"
                             "kvar = kvar + 1\n"
                             "endin\n");

    csoundInputMessage(csound, "i 1 0  0.1");
    csoundInputMessage(csound, "i 1.2 0  0.1");
    csoundInputMessage(csound, "i 30.1 0  0.01");
    csoundInputMessage(csound, "i 30 0  0.01");
    csoundInputMessage(csound, "i 30 1  0.11");
    csoundInputMessage(csound, "i 1.3 0  0.1");

    csoundStart(csound);
    csoundDebuggerInit(csound);
    csoundSetBreakpointCallback(csound, brkpt_cb8, NULL);
    csoundSetInstrumentBreakpoint(csound, 1.2, 0);
    csoundPerformKsmps(csound);
    csoundPerformKsmps(csound);
    csoundPerformKsmps(csound);  // Only the first call should have effect as we have already stopped

    csoundDebugNext(csound);
    csoundPerformKsmps(csound);
    csoundPerformKsmps(csound); // Ignored
    csoundDebugNext(csound);
    csoundPerformKsmps(csound);
    csoundPerformKsmps(csound); // Ignored
    csoundDebugNext(csound);
    csoundPerformKsmps(csound);
    csoundPerformKsmps(csound); // Ignored
    csoundDebugNext(csound);
    csoundPerformKsmps(csound);
    csoundPerformKsmps(csound); // Ignored
    csoundRemoveInstrumentBreakpoint(csound, 1.2);
    csoundDebugContinue(csound);

    int i;
    for (i = 0; i < 200; i++) {
        csoundPerformKsmps(csound);
    }

    csoundSetBreakpointCallback(csound, brkpt_cb9, NULL);
    csoundSetInstrumentBreakpoint(csound, 30.1, 0);
    for (i = 0; i < 1000; i++) {
        csoundPerformKsmps(csound);
    }

    /* step to next line */
    csoundDebugNext(csound);
    csoundPerformKsmps(csound);
    /* step to next line */
    csoundDebugNext(csound);
    csoundPerformKsmps(csound);
    /* step to next line */
    csoundDebugNext(csound);
    csoundPerformKsmps(csound);

    csoundDebuggerClean(csound);
    csoundDestroy(csound);
    CU_ASSERT_EQUAL(count, 5);
}
예제 #7
0
 int run()
 {
   csoundInputMessage(pt_->GetCsound(), sp);
   return 0;
 }