Пример #1
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;
}
Пример #2
0
void PyQcsObject::setCsChannel(QString channel, double value, int index)
{
	CsoundEngine *e = m_qcs->getEngine(index);
	MYFLT *p;
	if (e != NULL) {
		CSOUND *cs = e->getCsound();
#ifndef CSOUND6
        if (cs != NULL && !(csoundGetChannelPtr(cs, &p, channel.toLocal8Bit(), CSOUND_CONTROL_CHANNEL | CSOUND_INPUT_CHANNEL))) {
            *p = (MYFLT) value;
            return;
        }
#else
        if (cs) {
            controlChannelHints_t hints;  // this does not work with csound5
			int ret = csoundGetControlChannelHints(cs, channel.toLocal8Bit(), &hints);
			if (ret == 0) {
				csoundSetControlChannel(cs, channel.toLocal8Bit(), (MYFLT) value);
				return;
			}
		}
#endif
    }

	QString message="Channel '" + channel + "' does not exist or is not exposed with chn_k.";
	PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule();
	mainContext.evalScript("print \'"+message+"\'");
}
Пример #3
0
void outputCallback2(CSOUND *csound,
                   const char *channelName,
                   void *channelValuePtr,
                   void *channelType)
{
    MYFLT *valPtr = (MYFLT *) channelValuePtr;
    csoundSetControlChannel(csound, channelName, *valPtr);
}
Пример #4
0
void test_control_channel(void)
{
    csoundSetGlobalEnv("OPCODE6DIR64", "../../");
    CSOUND *csound = csoundCreate(0);
    csoundCreateMessageBuffer(csound, 0);
    csoundSetOption(csound, "--logfile=null");
    //int argc = 2;
    csoundCompileOrc(csound, orc1);
    CU_ASSERT(csoundStart(csound) == CSOUND_SUCCESS);
    csoundSetControlChannel(csound, "testing", 5.0);
    CU_ASSERT_EQUAL(5.0, csoundGetControlChannel(csound, "testing", NULL));

    csoundCleanup(csound);
    csoundDestroyMessageBuffer(csound);
    csoundDestroy(csound);
}
Пример #5
0
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);
}
Пример #6
0
void CsoundObj_setControlChannel(CsoundObj *self, const char *channelName, float value) {

    csoundSetControlChannel(self->csound, channelName, value);
}
Пример #7
0
void CsoundObj_setControlChannel(CsoundObj *self,
		const char *name,
		double value)
{
	csoundSetControlChannel(self->csound, name, value);
}