ref: d29b1fa9119ef89090971376b6c4b5378813efd7
parent: 979c85f07738f2bb01f58074613b19996ffc7ee8
author: Sigrid Haflínudóttir <[email protected]>
date: Wed May 13 08:18:33 EDT 2020
provide numin and numout when reading instance ctl file
--- a/ay/ay.c
+++ b/ay/ay.c
@@ -179,7 +179,7 @@
extern File *uif;
static Auxdsp *
-dspnew(void)
+dspnew(int *numin, int *numout)
{
struct Auxdsp *dsp;
UI *ui;
@@ -192,6 +192,9 @@
.magnitude = 1.0,
};
int i;
+
+ *numin = 0;
+ *numout = 1;
if ((dsp = malloc(sizeof(*dsp))) == nil)
return nil;
--- a/dsp/main.c
+++ b/dsp/main.c
@@ -54,7 +54,7 @@
}
static Auxdsp *
-dspnew(void)
+dspnew(int *numin, int *numout)
{
Auxdsp *dsp;
@@ -61,6 +61,8 @@
dsp = dspwrap(dspf->new());
dspf->init(dsp->dsp, rate);
dspf->build_ui(dsp->dsp, &uiglue);
+ *numin = dspf->num_in(dsp->dsp);
+ *numout = dspf->num_out(dsp->dsp);
return dsp;
}
--- a/fs.c
+++ b/fs.c
@@ -62,7 +62,7 @@
uif = f;
o->state = uis = calloc(1, sizeof(State));
o->state->voice = calloc(1, sizeof(Auxdsp*));
- o->state->voice[o->state->nvoice++] = fs->dsp.new();
+ o->state->voice[o->state->nvoice++] = fs->dsp.new(&o->numin, &o->numout);
o->state->silent = 1;
closefile(f);
@@ -182,6 +182,12 @@
a = r->fid->file->aux;
switch (a->type) {
case Xctl:
+ respond(r, nil);
+ break;
+ case Xdspctl:
+ o = auxtype2obj(&a->type);
+ sprint(b, "numin\t%d\nnumout\t%d\n", o->numin, o->numout);
+ readstr(r, b);
respond(r, nil);
break;
case Xmetadata:
--- a/fs.h
+++ b/fs.h
@@ -26,6 +26,9 @@
int data;
int metadata;
+ int numin;
+ int numout;
+
struct UI *ui;
State *state;
};
@@ -35,7 +38,7 @@
char *metadata;
struct {
- Auxdsp *(*new)(void);
+ Auxdsp *(*new)(int *numin, int *numout);
void (*free)(Auxdsp *dsp);
void (*reset)(Auxdsp *dsp);