示例#1
0
文件: sched.c 项目: hlolli/csound
static void *wd_thread_routine(void *dummy)
{
    uint32_t t0, t1;
    double   p;

    (void) dummy;
    for ( ; ; ) {
      t0 = (uint32_t) clock();
      csoundSleep((size_t) (secs * 1000));
      t1 = (uint32_t) clock();
      p = (double) ((int32_t) (t1 - t0)) * (100.0 / (double) CLOCKS_PER_SEC);
      if ((p / (double) secs) > (double) cpuMax) {
        kill(getpid(), SIGTERM); csoundSleep(1500);
        kill(getpid(), SIGKILL); csoundSleep(1500);
        exit(-1);
      }
    }
}
示例#2
0
void test_server(void)
{
    const char  *instrument =
            "instr 1 \n"
            "k1 expon p4, p3, p4*0.001 \n"
            "a1 randi  k1, p5   \n"
            "out  a1   \n"
            "endin \n";

    Csound csound;
    csound.SetOption((char*)"-odac");
    csound.SetOption((char*)"--port=44100");
    csound.Start();
    CsoundPerformanceThread performanceThread(csound.GetCsound());
    performanceThread.Play();
    udp_send(instrument);
    udp_send("$i1 0 2 1000 1000");
    csoundSleep(3000);
    udp_send("##close##");
    performanceThread.Join();
    csound.Cleanup();
    csound.Reset();
}
示例#3
0
 void System::sleep(double milliseconds)
 {
   csoundSleep((int) (milliseconds + 0.999));
 }