/* sobjs.h */
#define MAXSOBJ 1024 /* These figures can easily be enlarged */
#define MAXSOBJTYPE 128
#define MAXSOBJNAMELENGHT 32
struct sobj { /* Sound objects (or other purposes */
int id; /* for now normally the same as array index */
int type; /* simple class id */
int funcid; /* function associated with object */
int dataid; /* index in data-array (easier than pointer */
int idata; /* one int of local data, for simple objs */
int nameid; /* ascii name of object (real time facils) */
int nextid; /* next object in prefered default schedule */
int step; /* what simu. step is the state updated to */
} SOBJS;
SOBJS sobj[MAXSOBJ];
int lastid, lasttype; /* globals assume on set of objs for now */
char sobj_names[MAXSOBJ][MAXSOBJNAMELENGHT];
/* just a parallel array, idem */
char sobj_type_names[MAXSOBJTYPE][MAXSOBJNAMELENGHT];
int current_sobj_id;
/**************************************************************************
* *
* sobjs.c *
* *
* Create and activate a set of lightweight objects, with as primary *
* purpose implementing sound synthesis algorithms in a fairly *
* efficient manner. Sort of a combination of an event driven simulator, *
* a (near) real time interpreter and object management, and lots of hooks *
* for more, for instance my intertread-socket-like channels. *
* The main idea is that everything is straightforward and pointers are *
* preferably indices, everything is run-time readable, and overhead *
* for various activation methods is minimal. Probably, a lot of this *
* would fit in nicely in a DSP (how about those $29 SHARCS?), and also *
* probably a lot of this already exists in some form, but not in this *
* combination, and not accessible for me. *
* *
* I'm progamming this under GNU C, with a rhide interface, and probably *
* continue under Cygwin (for some of the unix stuff, and since I'm pretty *
* much a unix adept. I hope the Win95 sockets will work soon, than I *
* will probably link this thing up with a tcl/tk user interface/inspector.*
* *
* *
* *
* *
* *
* *
* *
* ******* This source is not finished yet, it is version -1 ! *********** *
/**************************************************************************
/* Evidently: Copyright by T. Verelst, ask theover@yahoo.com */
#include
#include
#include
#include
#include
#include
/*
Assume object list starts empty, clear all fields to be sure
*/
int nametoind(name,array,start) /* get appearances of string in array */
char *name, *array[];
{
int s, i;
i = start;
while (array[i] != NULL && (strcmp(name,array[i]) != 0) )
i++;
}
int init_sobjs()
{
current_sobj_id = -1;
last_id = -1;
lasttype = -1;
return(0);
}
int newtype_sobj(name,proc)
char *name;
(void *) proc();
{
return(0);
}
int newobj_sobj(type,name) /* probably even pre-emptive safe */
char *type;
char *name;
{
if (last_id+1 > MAXSOBJ) {
printf("Error: no space for new sobj\n");
return(-1);
}
last_id++;
sobj[last_id].type = nametoind(type, sobj_type_names, 0);
sobj[last_id].id = lastid; /* all set: go, this activates the obj */
last_id++;
return(0);
}
/*
perform one update operation, assume at least on exists
(save time, this is going to be a real time thing
*/
int update_sobj(id)
id;
{
if (id < 0 )
id = 0;
int round_robin()
{
for (i=0; i= 0) {
ascii_status_sobj(id);
}
wrapup()
{
printf("End of simulation\n");
}
main(argc, argv)
int argc;
char *argv[];
{
init();
simulate();
wrapup();
}