void test_pvs_opcodes(void) { csoundSetGlobalEnv("OPCODE6DIR64", "../../"); CSOUND *csound = csoundCreate(0); csoundCreateMessageBuffer(csound, 0); csoundSetOption(csound, "--logfile=null"); int err = csoundCompileOrc(csound, orc5); CU_ASSERT(err == CSOUND_SUCCESS); err = csoundStart(csound); PVSDATEXT pvs_data, pvs_data2; memset(&pvs_data,0,sizeof(PVSDATEXT)); memset(&pvs_data2,0,sizeof(PVSDATEXT)); pvs_data.N = 16; pvs_data.winsize = 32; err = csoundSetPvsChannel(csound, &pvs_data, "1"); err = csoundGetPvsChannel(csound, &pvs_data2, "1"); CU_ASSERT_EQUAL(pvs_data.N, pvs_data2.N); MYFLT pFields[] = {1.0, 0.0, 1.0}; err = csoundScoreEvent(csound, 'i', pFields, 3); err = csoundPerformKsmps(csound); CU_ASSERT_EQUAL(32.0, csoundGetControlChannel(csound, "winsize", NULL)); csoundCleanup(csound); csoundDestroyMessageBuffer(csound); csoundDestroy(csound); }
void CsoundObject_turnOnPhasor(CsoundObject *self) { self->csoundScore[0] = 3; self->csoundScore[1] = 0; self->csoundScore[2] = -1; csoundScoreEvent(self->csound, 'i', self->csoundScore, 3); }
void CsoundObject_turnOnPhaseVocoder(CsoundObject *self, size_t phaseVocoderInstances) { self->csoundScore[0] = 1; self->csoundScore[1] = 0; self->csoundScore[2] = -1; self->csoundScore[3] = phaseVocoderInstances; self->csoundScore[4] = self->analysisSegmentFramesCount; csoundScoreEvent(self->csound, 'i', self->csoundScore, 5); csoundPerformKsmps(self->csound); }
void test_channel_callbacks(void) { csoundSetGlobalEnv("OPCODE6DIR64", "../../"); CSOUND *csound = csoundCreate(0); csoundCreateMessageBuffer(csound, 0); csoundSetOption(csound, "--logfile=null"); csoundCompileOrc(csound, orc3); csoundSetInputChannelCallback(csound, (channelCallback_t) inputCallback); csoundSetOutputChannelCallback(csound, (channelCallback_t) outputCallback); int err = csoundStart(csound); CU_ASSERT(err == CSOUND_SUCCESS); MYFLT pFields[] = {1.0, 0.0, 1.0}; err = csoundScoreEvent(csound, 'i', pFields, 3); MYFLT pFields2[] = {2.0, 0.0, 1.0}; err += csoundScoreEvent(csound, 'i', pFields2, 3); CU_ASSERT(err == CSOUND_SUCCESS); err = csoundPerformKsmps(csound); CU_ASSERT(err == CSOUND_SUCCESS); csoundCleanup(csound); csoundDestroyMessageBuffer(csound); csoundDestroy(csound); }
/** * Iff this instance is active, this call generates a csound event. * Parameters are passed directly as a buffer of floats. If secs_per_tick * != prev_secs_per_tick (possibly because prev_secs_per_tick was set to -1 * by update() ) then this call will do some floating point ops to * recalculate the parameter buffer. */ void event(CSOUND * csound, MYFLT secs_per_tick) { if (!active) return; if (time_in_ticks && (secs_per_tick != prev_secs_per_tick)) { param[2] = duration * secs_per_tick; if (param.size() > 8) param[8] = std::max(0.002f, attack * param[2]); if (param.size() > 9) param[9] = std::max(0.002f, decay * param[2]); prev_secs_per_tick = secs_per_tick; if (_debug && (VERBOSE > 2)) fprintf(_debug, "setting duration to %f\n", param[5]); } csoundScoreEvent(csound, type, ¶m[0], param.size()); }
void test_channel_opcodes(void) { csoundSetGlobalEnv("OPCODE6DIR64", "../../"); CSOUND *csound = csoundCreate(0); csoundCreateMessageBuffer(csound, 0); csoundSetOption(csound, "--logfile=null"); csoundCompileOrc(csound, orc4); csoundSetInputChannelCallback(csound, (channelCallback_t) inputCallback2); csoundSetOutputChannelCallback(csound, (channelCallback_t) outputCallback2); int err = csoundStart(csound); CU_ASSERT(err == CSOUND_SUCCESS); csoundGetControlChannel(csound, "1", &err); CU_ASSERT(err == CSOUND_SUCCESS) csoundSetControlChannel(csound, "1", 5.0); MYFLT pFields[] = {1.0, 0.0, 1.0}; err = csoundScoreEvent(csound, 'i', pFields, 3); err = csoundPerformKsmps(csound); CU_ASSERT(err == CSOUND_SUCCESS); CU_ASSERT_EQUAL(5.0, csoundGetControlChannel(csound, "2", NULL)); MYFLT pFields2[] = {2.0, 0.0, 1.0}; err = csoundScoreEvent(csound, 'i', pFields2, 3); CU_ASSERT(err == CSOUND_SUCCESS); err = csoundPerformKsmps(csound); CU_ASSERT(err == CSOUND_SUCCESS); CU_ASSERT_EQUAL(6.0, csoundGetControlChannel(csound, "3", NULL)); MYFLT pFields3[] = {3.0, 0.0, 1.0}; err = csoundScoreEvent(csound, 'i', pFields3, 3); CU_ASSERT(err == CSOUND_SUCCESS); err = csoundPerformKsmps(csound); CU_ASSERT(err == CSOUND_SUCCESS); CU_ASSERT_EQUAL(7.0, csoundGetControlChannel(csound, "4", NULL)); csoundCleanup(csound); csoundDestroyMessageBuffer(csound); csoundDestroy(csound); }
void CsoundObject_writeDataToTable(CsoundObject *self, UInt32 tableNumber, Float32 *data, UInt32 dataCount) { self->csoundScore[0] = tableNumber; self->csoundScore[1] = 0; self->csoundScore[2] = -((Float32)dataCount); self->csoundScore[3] = 2; self->csoundScore[4] = 0; csoundScoreEvent(self->csound, 'f', self->csoundScore, 5); csoundPerformKsmps(self->csound); Float32 *tablePointer; csoundGetTable(self->csound, &tablePointer, tableNumber); cblas_scopy((UInt32)dataCount, data, 1, tablePointer, 1); }
/** pass an array event straight through to csound. only works if perf. thread is running */ void scoreEvent(char type, MYFLT * p, int np) { 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 > 2)) { fprintf(_debug, "INFO: scoreEvent %c ", type); for (int i = 0; i < np; ++i) fprintf(_debug, "%lf ", p[i]); fprintf(_debug, "\n"); } csoundScoreEvent(csound, type, p, np); }
int run() { CSOUND *csound = pt_->GetCsound(); if (absp2mode && pcnt > 1) { double p2 = (double) pp[1] - csoundGetScoreTime(csound); if (p2 < 0.0) { if (pcnt > 2 && pp[2] >= (MYFLT) 0 && (opcod == 'a' || opcod == 'i')) { pp[2] = (MYFLT) ((double) pp[2] + p2); if (pp[2] <= (MYFLT) 0) return 0; } p2 = 0.0; } pp[1] = (MYFLT) p2; } if (csoundScoreEvent(csound, opcod, pp, (long) pcnt) != 0) csoundMessageS(csound, CSOUNDMSG_WARNING, "WARNING: could not create score event\n"); return 0; }