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);
}
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);
}
Beispiel #3
0
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);
}
CsoundObject *CsoundObject_new(char *csdPath, size_t analysisSegmentFramesCount)
{
    CsoundObject *self = calloc(1, sizeof(CsoundObject));
    self->analysisSegmentFramesCount = analysisSegmentFramesCount;
    self->csound = csoundCreate(NULL);
    self->frameTimes = calloc(analysisSegmentFramesCount, sizeof(Float32));
    
    for (size_t i = 0; i < analysisSegmentFramesCount; ++i) {
        
        self->frameTimes[i] = ((1. / 44100) * 256) * i;
    }
    
    csoundPreCompile(self->csound);
    csoundSetHostImplementedAudioIO(self->csound, 1, 0);
    csoundSetHostData(self->csound, self);
    self->channelsCount = 2;
    char *parserFlag = "--new-parser";
    char *argv[3] = {
        "csound",
        parserFlag,
        csdPath
    };
    
    self->csoundResult = csoundCompile(self->csound, 3, argv);
    
    if (self->csoundResult == 0) {
        printf("success\n");
    }
    
    return self;
}
Beispiel #5
0
void test_control_channel_params(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);
    controlChannelHints_t hints;
    hints.behav = CSOUND_CONTROL_CHANNEL_INT;
    hints.dflt = 5;
    hints.min = 1;
    hints.max = 10;
    hints.attributes = NULL;
    csoundSetControlChannelHints(csound, "testing", hints);

    controlChannelHints_t hints2;
    csoundGetControlChannelHints(csound, "testing", &hints2);
    CU_ASSERT(hints2.behav == CSOUND_CONTROL_CHANNEL_INT);
    CU_ASSERT(hints2.dflt == 5);
    CU_ASSERT(hints2.min == 1);
    CU_ASSERT(hints2.max == 10);

    csoundCleanup(csound);
    csoundDestroyMessageBuffer(csound);
    csoundDestroy(csound);
}
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);
}
Beispiel #7
0
void test_string_channel(void)
{
    const char orcS[] = "chn_S \"strchan1\",1\n chn_S \"strchan2\",2\n chn_S \"strchan3\",3\n instr 1\n  endin\n";

    csoundSetGlobalEnv("OPCODE6DIR64", "../../");
    CSOUND *csound = csoundCreate(0);
    csoundCreateMessageBuffer(csound, 0);
    csoundSetOption(csound, "--logfile=NULL");
    csoundCompileOrc(csound, orcS);
    int err = csoundStart(csound);
    CU_ASSERT(err == CSOUND_SUCCESS);

    csoundSetStringChannel(csound, "testing", "ttt");
    int len = csoundGetChannelDatasize(csound, "testing");
    char string[len];
    csoundGetStringChannel(csound, "testing", string);
    CU_ASSERT_STRING_EQUAL(string, "ttt");

    csoundSetStringChannel(csound, "strchan1", "strchan1_val");
    csoundSetStringChannel(csound, "strchan2", "strchan2_val");
    csoundSetStringChannel(csound, "strchan3", "strchan3_val");

    csoundGetStringChannel(csound, "strchan1", string);
    CU_ASSERT_STRING_EQUAL(string, "strchan1_val");

    csoundGetStringChannel(csound, "strchan2", string);
    CU_ASSERT_STRING_EQUAL(string, "strchan2_val");

    csoundGetStringChannel(csound, "strchan3", string);
    CU_ASSERT_STRING_EQUAL(string, "strchan3_val");

    csoundCleanup(csound);
    csoundDestroyMessageBuffer(csound);
    csoundDestroy(csound);
}
Beispiel #8
0
void test_chn_hints(void)
{
    csoundSetGlobalEnv("OPCODE6DIR64", "../../");
    CSOUND *csound = csoundCreate(0);
    csoundCreateMessageBuffer(csound, 0);
    csoundSetOption(csound, "--logfile=null");
    csoundCompileOrc(csound, orc6);
    (void)csoundStart(csound);
//    err = csoundPerformKsmps(csound); //Need this to load instr 0
    controlChannelHints_t hints;
    hints.attributes = 0;
    CU_ASSERT_EQUAL(0, csoundGetControlChannelHints(csound, "chan", &hints));
    CU_ASSERT_EQUAL(hints.x, 10);
    CU_ASSERT_EQUAL(hints.y, 10);
    CU_ASSERT_EQUAL(hints.width, 50);
    CU_ASSERT_EQUAL(hints.height, 100);
    CU_ASSERT_EQUAL(hints.attributes, 0);
    CU_ASSERT_EQUAL(0, csoundGetControlChannelHints(csound, "chan2", &hints));
    CU_ASSERT_EQUAL(hints.x, 10);
    CU_ASSERT_EQUAL(hints.y, 10);
    CU_ASSERT_EQUAL(hints.width, 50);
    CU_ASSERT_EQUAL(hints.height, 100);
    CU_ASSERT_STRING_EQUAL(hints.attributes, "testattr");

    csoundCleanup(csound);
    csoundDestroyMessageBuffer(csound);
    csoundDestroy(csound);
}
    TamTamSound(log_t * ll, char * orc, int framerate )
        : ThreadID(NULL), PERF_STATUS(STOP), csound(NULL),
        music(),
        ticks_per_period(0.0),
        tick_adjustment(0.0), 
        tick_total(0.0),
        csound_frame_rate(framerate),           //must agree with the orchestra file
        ll( ll )
    {
        csound = csoundCreate(NULL);
        int argc=4;
        const char  **argv = (const char**)malloc(argc*sizeof(char*));
        argv[0] = "csound";
        argv[1] = "-m0";
        argv[2] = "-+rtaudio=alsa";
        argv[3] = orc;

        ll->printf(1,  "loading csound orchestra file %s\n", orc);
        //csoundInitialize(&argc, &argv, 0);
        csoundPreCompile(csound);
        int result = csoundCompile(csound, argc, (char**)argv);
        if (result)
        {
            csound = NULL;
            ll->printf( "ERROR: csoundCompile of orchestra %s failed with code %i\n", orc, result);
        }
        free(argv);
        csound_period_size = csoundGetOutputBufferSize(csound);
        csound_period_size /= 2; /* channels */
        setTickDuration(0.05);
    }
void test_debugger_init(void)
{
    CSOUND* csound = csoundCreate(NULL);
    csoundCreateMessageBuffer(csound, 0);
    csoundDebuggerInit(csound);
    csoundDebuggerClean(csound);
    csoundDestroy(csound);
}
Beispiel #11
0
CsoundObj *CsoundObj_new()
{
	CsoundObj *self = calloc(1, sizeof(CsoundObj));
	self->csound = csoundCreate(NULL);
	self->useAudioInput = 0;
	csoundSetHostImplementedAudioIO(self->csound, 1, 0);

	return self;
}
void test_add_callback(void)
{
    CSOUND* csound = csoundCreate(NULL);
    csoundCreateMessageBuffer(csound, 0);
    csoundDebuggerInit(csound);
    csoundSetBreakpointCallback(csound, brkpt_cb, NULL);
    csoundDebuggerClean(csound);
    csoundDestroy(csound);
}
Beispiel #13
0
CsoundObj *CsoundObj_new()
{
    CsoundObj *self = calloc(1, sizeof(CsoundObj));
    self->frameCount = 256;
    self->csound = csoundCreate(self);
    csoundSetHostImplementedAudioIO(self->csound, 1, 0);

    self->midiCallbackData = calloc(1, sizeof(MidiCallbackData));
    self->midiCallbackData->midiData = calloc(MIDI_QUEUE_SIZE, sizeof(MidiData));
    return self;
}
Beispiel #14
0
void ConfigLists::refreshModules()
{
	rtMidiNames.clear();
	rtAudioNames.clear();
#ifdef CSOUND6
	CSOUND *csound = csoundCreate(NULL);
	char *name, *type;
	int n = 0;
	while(!csoundGetModule(csound, n++, &name, &type)) {
		if (strcmp(type, "audio") == 0) {
			rtAudioNames << name;
//			printf("Module %d:  %s (%s) \n", n, name, type);
		}
	}
	rtAudioNames << "null"; // add also none (-+rtaudio=null)
	n = 0;
	while(!csoundGetModule(csound, n++, &name, &type)) {
		if (strcmp(type, "midi") == 0) {
			rtMidiNames << name;
//			printf("MIDI Module %d:  %s (%s) \n", n, name, type);
		}
	}
	rtMidiNames << "virtual" << "none";
#else
#ifdef Q_OS_LINUX
	rtAudioNames << "portaudio" << "alsa" << "jack" << "pulse" << "none";
#endif
#ifdef Q_OS_SOLARIS
	rtAudioNames << "portaudio" << "pulse" << "none";
#endif
#ifdef Q_OS_MAC
	rtAudioNames << "coreaudio" << "portaudio" << "auhal" << "jack" << "none";
#endif
#ifdef Q_OS_WIN32
	rtAudioNames << "portaudio" << "winmm" << "jack" <<  "none";
#endif
#ifdef Q_OS_HAIKU
	rtAudioNames << "haiku" << "none";
#endif
#ifdef Q_OS_LINUX
	rtMidiNames << "none" << "alsa" << "alsaseq" << "portmidi" << "virtual";
#endif
#ifdef Q_OS_SOLARIS
	rtMidiNames << "none" << "portmidi"<< "virtual";
#endif
#ifdef Q_OS_MAC
	rtMidiNames << "none" << "coremidi" << "portmidi" << "virtual";
#endif
#ifdef Q_OS_WIN32
	rtMidiNames << "none" << "winmm" << "portmidi" << "virtual";
#endif
#endif
    csoundDestroy(csound);
}
void test_find_opcode_new(void) {
    CSOUND* csound = csoundCreate(NULL);
    CU_ASSERT_PTR_NOT_NULL(find_opcode_new(csound, "##error", "i", "i"));
    CU_ASSERT_PTR_NULL(find_opcode_new(csound, "##error", NULL, "i"));
    CU_ASSERT_PTR_NOT_NULL(find_opcode_new(csound, "##xin64", "i", NULL));
    CU_ASSERT_PTR_NOT_NULL(find_opcode_new(csound, "##xin256", "i", NULL));
    CU_ASSERT_PTR_NOT_NULL(find_opcode_new(csound, "##userOpcode", NULL, NULL));
    CU_ASSERT_PTR_NOT_NULL(find_opcode_new(csound, "##array_set", NULL, "k[]k"));
    CU_ASSERT_PTR_NOT_NULL(find_opcode_new(csound, ">=", "B", "kc"));
    

}
void test_no_callback(void)
{
    CSOUND* csound = csoundCreate(NULL);
    csoundCreateMessageBuffer(csound, 0);
    csoundStart(csound);
    csoundDebuggerInit(csound);
    csoundSetInstrumentBreakpoint(csound, 1, 0);

    csoundPerformKsmps(csound);

    csoundDebuggerClean(csound);
    csoundDestroy(csound);
}
void test_add_bkpt(void)
{
    CSOUND* csound = csoundCreate(NULL);
    csoundCreateMessageBuffer(csound, 0);
    csoundDebuggerInit(csound);
    csoundSetBreakpoint(csound, 3, 0, 0);
    csoundSetBreakpoint(csound, 5, 1, 0);
    csoundSetInstrumentBreakpoint(csound, 3.4, 0);
    csoundSetInstrumentBreakpoint(csound, 1.1, 0);
    csoundClearBreakpoints(csound);
    csoundDebuggerClean(csound);
    csoundDestroy(csound);
}
void test_line_breakpoint_orc_file(void)
{
    FILE *f = fopen("debug.orc", "w");
    CU_ASSERT_PTR_NOT_NULL(f);

    const char *orc = "\n"
                      "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";
    fprintf(f, "%s", orc);
    fclose(f);
    f = fopen("debug.sco", "w");
    CU_ASSERT_PTR_NOT_NULL(f);

    const char *sco = "i 1 0 1\n";
    fprintf(f, "%s", sco);
    fclose(f);
    count = 0;
    CSOUND* csound = csoundCreate(NULL);

    csoundCreateMessageBuffer(csound, 0);
    const char* argv[] = {"csound", "debug.orc", "debug.sco"};
    csoundCompile(csound, 3, (char **) argv);

    csoundDebuggerInit(csound);
    int line = 5;
    csoundSetBreakpointCallback(csound, brkpt_cb7, &line);
    csoundSetBreakpoint(csound, line, 0, 0);
    csoundPerformKsmps(csound);
    csoundDebugContinue(csound);
    csoundRemoveBreakpoint(csound, line, 0);
    csoundPerformKsmps(csound);
    csoundDebugContinue(csound);
    csoundPerformKsmps(csound);
    csoundDebugContinue(csound);
    csoundPerformKsmps(csound);
    csoundDebugContinue(csound);

    line = 6;
    csoundSetBreakpoint(csound, line, 0, 0);
    csoundPerformKsmps(csound);
    csoundDebugContinue(csound);
//    csoundPerformKsmps(csound);

    csoundDebuggerClean(csound);
    CU_ASSERT_EQUAL(count, 2);
    csoundDestroy(csound);
}
void test_check_out_args(void) {
    CSOUND* csound = csoundCreate(NULL);

    CU_ASSERT_TRUE(check_out_args(csound, NULL, ""));
    CU_ASSERT_TRUE(check_out_args(csound, "", NULL));
    CU_ASSERT_TRUE(check_out_args(csound, NULL, NULL));
    CU_ASSERT_TRUE(check_out_args(csound, "", ""));
    
    CU_ASSERT_TRUE(check_out_args(csound, "akiSakiS", "N"));
    CU_ASSERT_TRUE(check_out_args(csound, "akiSakiS", "aN"));
    CU_ASSERT_FALSE(check_out_args(csound, "akiSakiS", "akiSakiSa"));
    
    CU_ASSERT_TRUE(check_out_args(csound, "a", "aX"));    
}
Beispiel #20
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;
}
void test_resolve_opcode(void) {
    CSOUND* csound = csoundCreate(NULL);
    
    OENTRIES* entries = find_opcode2(csound, "=");
//    CU_ASSERT_EQUAL(7, entries->count);
    
    OENTRY* opc = resolve_opcode(csound, entries, "k", "k");
    CU_ASSERT_PTR_NOT_NULL(opc);
    csound->Free(csound, entries);
    
    
    entries = find_opcode2(csound, "vco2");
    CU_ASSERT_EQUAL(1, entries->count);
    
    opc = resolve_opcode(csound, entries, "a", "cc");
    CU_ASSERT_PTR_NOT_NULL(opc);
    csound->Free(csound, entries);
    
    
    entries = find_opcode2(csound, "passign");
    CU_ASSERT_EQUAL(1, entries->count);
//    int i;
//    for (i = 0; i < entries->count; i++) {
//        printf("%d) %s\t%s\t%s\n", i,
//               entries->entries[i]->opname,
//               entries->entries[i]->outypes,
//               entries->entries[i]->intypes);
//    }
    
    opc = resolve_opcode(csound, entries, "iiiiS", NULL);
    CU_ASSERT_PTR_NOT_NULL(opc);
    csound->Free(csound, entries);

    
    entries = find_opcode2(csound, "pcauchy");
    
    opc = resolve_opcode(csound, entries, "i", "k");
    CU_ASSERT_PTR_NOT_NULL(opc->iopadr);
    
    opc = resolve_opcode(csound, entries, "k", "k");
    CU_ASSERT_PTR_NOT_NULL(opc->kopadr);
    
    opc = resolve_opcode(csound, entries, "a", "k");
    CU_ASSERT_PTR_NOT_NULL(opc->aopadr);
    
    
    csound->Free(csound, entries);
}
Beispiel #22
0
int main(void)                          /* stdio stub for standalone scsort */
{
    CSOUND *csound;
    int    err;

    csound = csoundCreate(NULL);
#if defined(LINUX) || defined(SGI) || defined(sol) || \
    defined(__MACH__) || defined(__EMX__)
    signal(SIGPIPE, SIG_DFL);
#endif
    csoundSetMessageCallback(csound, msg_callback);
    err = csoundScoreSort(csound, stdin, stdout);
    csoundDestroy(csound);

    return err;
}
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);
}
Beispiel #24
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);
}
Beispiel #25
0
int main(int argc, char** argv) {
    CSOUND* csound;

    header();

    if(argc != 2) {
        usage();
        return 1;
    }

    printf("Input File: %s", argv[1]);

    csound = csoundCreate(NULL);

    printf("csound=%p\n", csound);
    return 0;
}
void test_check_in_args(void) {
    CSOUND* csound = csoundCreate(NULL);
    
    CU_ASSERT_TRUE(check_in_args(csound, NULL, ""));
    CU_ASSERT_TRUE(check_in_args(csound, "", NULL));
    CU_ASSERT_TRUE(check_in_args(csound, NULL, NULL));
    CU_ASSERT_TRUE(check_in_args(csound, "", ""));
    
    CU_ASSERT_TRUE(check_in_args(csound, "akiSakiS", "N"));
    CU_ASSERT_TRUE(check_in_args(csound, "akiSakiS", "aN"));
    CU_ASSERT_FALSE(check_in_args(csound, "akiSakiS", "akiSakiSa"));
    
    CU_ASSERT_TRUE(check_in_args(csound, "cc", "kkoM"));
    CU_ASSERT_TRUE(check_in_args(csound, "k[]kk", ".[].M"));
    CU_ASSERT_TRUE(check_in_args(csound, "a", "az"));
    
}
Beispiel #27
0
void test_invalid_channel(void)
{
    csoundSetGlobalEnv("OPCODE6DIR64", "../../");
    CSOUND *csound = csoundCreate(0);
    csoundCreateMessageBuffer(csound, 0);
    csoundSetOption(csound, "--logfile=null");
    csoundCompileOrc(csound, orc5);

    int err;
    CU_ASSERT_EQUAL(0.0, csoundGetControlChannel(csound, "nonexistent_channel", &err));
    CU_ASSERT_EQUAL(err, CSOUND_SUCCESS);

    csoundCleanup(csound);
    csoundDestroyMessageBuffer(csound);
    csoundDestroy(csound);

}
Beispiel #28
0
int main(int argc, char **argv)
{
    CSOUND  *csound;
    char    *fname = NULL;
    int     k, result;
    PVSDATEXT dataout, datain;

    /* initialise PVSATEXT data */
    datain.N = 1024;
    datain.format = 0;
    datain.overlap = 256;
    datain.winsize = 1024;
    datain.frame = (float *) calloc(sizeof(float),(datain.N+2));

    dataout.N = 1024;
    dataout.format = 0;
    dataout.overlap = 256;
    dataout.winsize = 1024;
    dataout.frame = (float *) calloc(sizeof(float),(dataout.N+2));

    /*  Create Csound. */
    csound = csoundCreate(NULL);

    /*  One complete performance cycle. */
    result = csoundCompile(csound, argc, argv);
    while (!result){

      /* copy data from pvs out to pvs in bus */
      for(k=0; k < 1026; k++)
          datain.frame[k] = dataout.frame[k];
      datain.framecount = dataout.framecount;
      /* send in the pvs in bus data */
      csoundSetPvsChannel(csound, &datain, "0");
      /* one ksmps pass */
      result = csoundPerformKsmps(csound);
      /* receive the pvs out bus data */
      csoundGetPvsChannel(csound, &dataout, "0");
    }
    /* delete Csound instance */
    csoundDestroy(csound);
    free(datain.frame);
    free(dataout.frame);
    return (result >= 0 ? 0 : result);
}
Beispiel #29
0
QList<QPair<QString, QString> > ConfigLists::getAudioInputDevices(QString module)
{
	//  qDebug("CsoundQt::getAudioInputDevices()");
	QList<QPair<QString, QString> > deviceList;
#ifdef CSOUND6
	CSOUND *cs = csoundCreate(NULL);
	csoundSetRTAudioModule(cs, module.toLatin1().data());
	int i,newn, n = csoundGetAudioDevList(cs,NULL,0);
	CS_AUDIODEVICE *devs = (CS_AUDIODEVICE *) malloc(n*sizeof(CS_AUDIODEVICE));
	newn = csoundGetAudioDevList(cs,devs,0);
	if (newn != n) {
		qDebug() << "ConfigLists::getAudioInputDevices Device number changed";
		return deviceList;
	}
	for (i = 0; i < n; i++) {
//		qDebug() << devs[i].device_name;
		deviceList.append(QPair<QString,QString>(devs[i].device_name,  QString(devs[i].device_id)));
	}
	free(devs);
    csoundDestroy(cs);
#else
	if (module == "none") {
		return deviceList;
	}
	if (module == "alsa") {
		QFile f("/proc/asound/pcm");
		f.open(QIODevice::ReadOnly | QIODevice::Text);
		QString values = QString(f.readAll());
		QStringList st = values.split("\n");
		foreach (QString line, st) {
			if (line.indexOf("capture") >= 0) {
				QStringList parts = line.split(":");

				QStringList cardId = parts[0].split("-");
				QString buffer = "";
				buffer.append(parts[1]).append(" : ").append(parts[2]);

				QPair<QString, QString> device;
				device.first = buffer;
				device.second = "adc:hw:" + QString::number(cardId[0].toInt()) + "," + QString::number(cardId[1].toInt());
				deviceList.append(device);
			}
		}
	}
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);
}