示例#1
0
void InitOSCAddrSpace(SynthState *v1, SynthState *v2) {
    Boolean result;
    OSCcontainer OSCTopLevelContainer, sine1, sine2;
    struct OSCAddressSpaceMemoryTuner t;
    struct OSCContainerQueryResponseInfoStruct cqinfo;
    struct OSCMethodQueryResponseInfoStruct QueryResponseInfo;

    /* Address space */

    t.initNumContainers = 20;
    t.initNumMethods = 20;
    t.InitTimeMemoryAllocator = MyInitTimeMalloc;
    t.RealTimeMemoryAllocator = MyRealTimeMalloc;

    OSCTopLevelContainer = OSCInitAddressSpace(&t);

    OSCInitContainerQueryResponseInfo(&cqinfo);
    sine1 = OSCNewContainer("sine1", OSCTopLevelContainer, &cqinfo);
    sine2 = OSCNewContainer("sine2", OSCTopLevelContainer, &cqinfo);

    OSCInitMethodQueryResponseInfo(&QueryResponseInfo);
    OSCNewMethod("f", sine1, FreqMethod, v1, &QueryResponseInfo);
    OSCNewMethod("f", sine2, FreqMethod, v2, &QueryResponseInfo);
    OSCNewMethod("a", sine1, GainMethod, v1, &QueryResponseInfo);
    OSCNewMethod("a", sine2, GainMethod, v2, &QueryResponseInfo);
    OSCNewMethod("g", sine1, GainMethod, v1, &QueryResponseInfo);
    OSCNewMethod("g", sine2, GainMethod, v2, &QueryResponseInfo);
    OSCNewMethod("quit", OSCTopLevelContainer, QuitMethod, 0, &QueryResponseInfo);
    OSCNewMethod("echo", OSCTopLevelContainer, EchoMethod, 0, &QueryResponseInfo);
    OSCNewMethod("scale", OSCTopLevelContainer, ScaleMethod, 0, &QueryResponseInfo);
    OSCNewMethod("allmystrings", OSCTopLevelContainer, AllMyStringsMethod, 0, &QueryResponseInfo);
}
示例#2
0
void SetUpAddrSpace(void) {
    OSCcontainer foo, goo, hunkydory;
    char addr[100];
    struct OSCContainerQueryResponseInfoStruct cqinfo;
    struct OSCMethodQueryResponseInfoStruct QueryResponseInfo;

    printf("Getting address of top-level container\n");
    if (OSCGetAddressString(addr, 100, OSCTopLevelContainer) == FALSE) {
	printf("OSCGetAddressString returned FALSE!\n");
    }
    printf("It's \"%s\"\n", addr);

    printf("Printing whole address space before we put anything in it\n");
    OSCPrintWholeAddressSpace();

    OSCInitContainerQueryResponseInfo(&cqinfo);
    cqinfo.comment = "Foo!";

    if ((foo = OSCNewContainer("foo", OSCTopLevelContainer, &cqinfo)) == 0) {
	printf("OSCNewContainer returned FALSE!\n");
	return;
    }

    printf("Printing whole address space after we register /foo/\n");
    OSCPrintWholeAddressSpace();

    printf("Trying to get address of /foo/ in a 4 char array\n");
    if (OSCGetAddressString(addr, 4, foo) == FALSE) {
	printf("Good---OSCGetAddressString returned FALSE\n");
    } else {
	printf("OSCGetAddressString returned TRUE!!!\n");
    }

    printf("Trying to get address of /foo/ in a 5 char array\n");
    if (OSCGetAddressString(addr, 5, foo) == FALSE) {
	printf("Good---OSCGetAddressString returned FALSE\n");
    } else {
	printf("OSCGetAddressString returned TRUE!!!\n");
    }

    printf("Trying to get address of /foo/ in a 6 char array\n");
    if (OSCGetAddressString(addr, 6, foo) == FALSE) {
	printf("OSCGetAddressString returned FALSE!!!\n");
    } else {
	printf("Good---OSCGetAddressString returned TRUE.  Addr is %s\n", addr);
    }

    printf("Trying to get address of /foo/ in a 100 char array\n");
    if (OSCGetAddressString(addr, 100, foo) == FALSE) {    
        printf("OSCGetAddressString returned FALSE!\n");
    }
    printf("It's \"%s\"\n", addr);

    OSCInitContainerQueryResponseInfo(&cqinfo);
    cqinfo.comment = "Everything's just Hunky-Dory!";

    if ((hunkydory = OSCNewContainer("hunkydory", foo, &cqinfo)) == 0) {
        printf("OSCNewContainer returned 0!\n");
        return;
    }

    printf("Trying to get address of /foo/hunkydory/ in a 100 char array\n");
    if (OSCGetAddressString(addr, 100, hunkydory) == FALSE) {
        printf("OSCGetAddressString returned FALSE!\n");
    }
    printf("It's \"%s\"\n", addr);

    OSCInitContainerQueryResponseInfo(&cqinfo);
    cqinfo.comment = "Goo is goopy.";

    if ((goo = OSCNewContainer("goo", OSCTopLevelContainer, &cqinfo)) == 0) {
	printf("OSCNewContainer returned 0!\n");
	return;
    }


    OSCInitMethodQueryResponseInfo(&QueryResponseInfo);
    QueryResponseInfo.description = "Get drunk in a bar";

    if (OSCNewMethod("bar", foo, BarCallback, (void *) 100, &QueryResponseInfo) == 0) {
	printf("OSCNewMethod returned 0!\n");
        return;
    }

    QueryResponseInfo.description = "Latvia is very far";

    if (OSCNewMethod("far", goo, FarCallback, (void *) 7, &QueryResponseInfo) == 0) {
	printf("OSCAddMethod returned 0!\n");
        return;
    }

    printf("Printing whole address space after we register everything\n");
    OSCPrintWholeAddressSpace();

    printf("Now register some aliases\n");

    if (OSCAddContainerAlias(goo, "slime") == FALSE) {
	printf("OSCAddContainerAlias returned FALSE!\n");
    }

    if (OSCAddContainerAlias(goo, "schmutz") == FALSE) {
	printf("OSCAddContainerAlias returned FALSE!\n");
    }

    if (OSCAddContainerAlias(goo, "spooge") == FALSE) {
	printf("OSCAddContainerAlias returned FALSE!\n");
    }

    if (OSCAddContainerAlias(goo, "glurpies") == FALSE) {
	printf("OSCAddContainerAlias returned FALSE!\n");
    }

    printf("Printing whole address space after registering aliases\n");
    OSCPrintWholeAddressSpace();

    printf("Finished registering the address space!\n\n\n");
}