Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 7 commits
  • 14 files changed
  • 0 comments
  • 1 contributor
Jan 30, 2012
Werner Almesberger experimental/T.fnp: Tornado Rain Dance variant for new MIDI control s…
…election

This is only temporary to better track changes.
1dd1b1c
Werner Almesberger controls: removed indirection via cvar array
MIDI input now changes the register array directly. Note that this
means that writing to a control variable changes its value until
the next time it is updated by MIDI. Not sure if this is more
feature or bug.
b4458bc
Werner Almesberger renderer: keep patch_lock around and clear current_patch when stopped
This commit makes renderer_lock_patch, renderer_unlock_patch, and
renderer_get_patch produce meaningful resuls also when the renderer
is not running.
23b34a3
Werner Almesberger sampler.c: only enter patch-specific stimulus processing if we have a…
… patch

Not checking for this crashed FN when running the sampler without
rendering, e.g., in the audio dialog.
f5721eb
Werner Almesberger compiler/stimuli: refuse to assign out of range channel/controller nu…
…mbers
9b64d06
Werner Almesberger compiler: move retrieval of stimuli pointer from parser into compiler.c
A bit cleaner this way.
bcb404d
Werner Almesberger stimuli: rename stim_add to stim_add_midi_ctrl
It's not generic.
e6fa3f6
77  experimental/T.fnp
... ...
@@ -0,0 +1,77 @@
  1
+/*
  2
+ * Highly experimental variant of Tornado (Rain Dance MIDI RMX)
  3
+ */
  4
+fDecay=0.9950000
  5
+fVideoEchoZoom=2.000000
  6
+fVideoEchoAlpha=0.000000
  7
+nVideoEchoOrientation=0
  8
+nWaveMode=2
  9
+bAdditiveWaves=0
  10
+bWaveDots=0
  11
+bMaximizeWaveColor=1
  12
+bTexWrap=1
  13
+mv_a=0
  14
+nMotionVectorsX=12
  15
+nMotionVectorsY=9
  16
+fWaveAlpha=3.000000
  17
+fWaveScale=3.020000
  18
+fWarpAnimSpeed=1.000000
  19
+fWarpScale=2.853000
  20
+zoom=1.031000
  21
+rot=0.000000
  22
+cx=0.500000
  23
+cy=0.500000
  24
+dx=0.000000
  25
+dy=0.000000
  26
+warp=0.309000
  27
+sx=1.000000
  28
+sy=1.000000
  29
+wave_r=0.600000
  30
+wave_g=0.600000
  31
+wave_b=0.600000
  32
+wave_x=0.500000
  33
+wave_y=0.500000
  34
+
  35
+/* MIDI settings for Faderfox LV3 */
  36
+
  37
+whirl = midi(0, 7);			// fader 1
  38
+growth = midi(1, 7);			// fader 2
  39
+radius = midi(2, 7);			// fader 3
  40
+sensitivity = midi(3, 7);		// fader 4
  41
+
  42
+twist = midi(0, 24, accel_linear);	// encoder 1
  43
+theta = midi(0, 25, accel_cyclic);	// encoder 2
  44
+
  45
+red = midi(4, 7);			// fader 5
  46
+green = midi(5, 7);			// fader 6
  47
+blue = midi(6, 7);			// fader 7
  48
+change = midi(7, 7);			// fader 8
  49
+
  50
+offcenter = midi(8, 4);			// FX1
  51
+xoff = midi(8, 1);
  52
+yoff = midi(8, 2);
  53
+shift = midi(9, 4);			// FX2
  54
+xshift = midi(9, 1);
  55
+yshift = midi(9, 2);
  56
+
  57
+per_frame:
  58
+	wave_scale = sensitivity*20;
  59
+	t = time*change*5;
  60
+	wave_r = red*( 0.60*sin(0.933*t) + 0.40*sin(1.045*t) );
  61
+	wave_g = green*( 0.60*sin(0.900*t) + 0.40*sin(0.956*t) );
  62
+	wave_b = blue*( 0.60*sin(0.910*t) + 0.40*sin(0.920*t) );
  63
+	rot = whirl*2+twist/10;
  64
+	dist = radius/5;
  65
+//	cx = offcenter ? 0.5+(xoff-0.5)*0.3 : 0.5;
  66
+//	cy = offcenter ? 0.5+(0.5-yoff)*0.3 : 0.5;
  67
+	sx = offcenter ? 0.2*(xoff-0.5)+1 : 1;
  68
+	sy = offcenter ? 0.2*(yoff-0.5)+1 : 1;
  69
+	tmp = theta*6.2832;
  70
+	wave_x = cx+cos(tmp)*dist;
  71
+	wave_y = cy-sin(tmp)*dist;
  72
+	dx = shift ? (xshift-0.5)*0.2 : 0;
  73
+	dy = shift ? (yshift-0.5)*0.2 : 0;
  74
+	zoom = 0.9+growth/5;
  75
+
  76
+per_vertex:
  77
+	rot = rot + (rad-0.4)*1.7*max(0,min((bass_att-1.1)*1.5,5));
37  src/compiler/compiler.c
@@ -195,8 +195,8 @@ static void pfv_bind_callback(void *_sc, struct fpvm_sym *sym, int reg)
195 195
 		pfv_update_patch_requires(sc, pfv);
196 196
 		sc->p->pfv_allocation[pfv] = reg;
197 197
 	}
198  
-	if(s->cvar != -1)
199  
-		sc->p->cvars[s->cvar].pfv_reg = reg;
  198
+	if(s->stim_regs)
  199
+		s->stim_regs->pfv = sc->p->perframe_regs+reg;
200 200
 }
201 201
 
202 202
 static bool init_pfv(struct compiler_sc *sc)
@@ -276,8 +276,8 @@ static void pvv_bind_callback(void *_sc, struct fpvm_sym *sym, int reg)
276 276
 		pvv_update_patch_requires(sc, pvv);
277 277
 		sc->p->pvv_allocation[pvv] = reg;
278 278
 	}
279  
-	if(s->cvar != -1)
280  
-		sc->p->cvars[s->cvar].pvv_reg = reg;
  279
+	if(s->stim_regs)
  280
+		s->stim_regs->pvv = sc->p->pervertex_regs+reg;
281 281
 }
282 282
 
283 283
 static bool init_pvv(struct compiler_sc *sc)
@@ -490,8 +490,6 @@ struct patch *patch_compile(const char *basedir, const char *patch_code,
490 490
 	sc->p->original = NULL;
491 491
 	sc->p->next = NULL;
492 492
 	sc->p->stim = NULL;
493  
-	sc->p->ncvars = 0;
494  
-	sc->p->cvars = NULL;
495 493
 
496 494
 	sc->basedir = basedir;
497 495
 	sc->rmc = rmc;
@@ -543,19 +541,11 @@ struct patch *patch_compile_filename(const char *filename,
543 541
 	return p;
544 542
 }
545 543
 
546  
-struct cvar *patch_add_cvar(struct patch *p)
  544
+struct stimuli *compiler_get_stimulus(struct compiler_sc *sc)
547 545
 {
548  
-	struct cvar *old = p->cvars;
549  
-	struct cvar *cv;
550  
-
551  
-	p->ncvars++;
552  
-	p->cvars = realloc(old, sizeof(struct cvar)*p->ncvars);
553  
-	if(old)
554  
-		stim_redirect(p->stim, &old->val, &p->cvars->val);
555  
-	cv = p->cvars+p->ncvars-1;
556  
-	cv->val = 0;
557  
-	cv->pfv_reg = cv->pvv_reg = -1;
558  
-	return cv;
  546
+	if(!sc->p->stim)
  547
+                sc->p->stim = stim_new();
  548
+	return sc->p->stim;
559 549
 }
560 550
 
561 551
 #ifndef STANDALONE
@@ -578,13 +568,7 @@ struct patch *patch_copy(struct patch *p)
578 568
 		pixbuf_inc_ref(img->pixbuf);
579 569
 	}
580 570
 	new_patch->stim = stim_get(p->stim);
581  
-	if(p->ncvars) {
582  
-		size_t size = p->ncvars*sizeof(struct cvar);
583  
-
584  
-		new_patch->cvars = malloc(size);
585  
-		memcpy(new_patch->cvars, p->cvars, size);
586  
-	}
587  
-	stim_redirect(p->stim, &p->cvars->val, &new_patch->cvars->val);
  571
+	stim_redirect(p->stim, p, new_patch);
588 572
 	return new_patch;
589 573
 }
590 574
 
@@ -600,7 +584,6 @@ void patch_free(struct patch *p)
600 584
 		free((void *) img->filename);
601 585
 	}
602 586
 	stim_put(p->stim);
603  
-	free(p->cvars);
604 587
 	free(p);
605 588
 }
606 589
 
@@ -622,4 +605,4 @@ struct patch *patch_refresh(struct patch *p)
622 605
 	return p;
623 606
 }
624 607
 
625  
-#endif
  608
+#endif /* !STANDALONE */
11  src/compiler/compiler.h
@@ -226,12 +226,6 @@ struct image {
226 226
 	struct stat st;
227 227
 };
228 228
 
229  
-struct cvar {
230  
-	float val;	/* current value */
231  
-	int pfv_reg;	/* per-frame register */
232  
-	int pvv_reg;	/* per-vertex register */
233  
-};
234  
-
235 229
 struct patch {
236 230
 	/* per-frame */
237 231
 	struct image images[IMAGE_COUNT];	/* images used in this patch */
@@ -264,18 +258,17 @@ struct patch {
264 258
 
265 259
 	/* unified input events */
266 260
 	struct stimuli *stim;	/* control variable hierarchy */
267  
-	int ncvars;		/* number of control variables */
268  
-	struct cvar *cvars;	/* control variables */
269 261
 };
270 262
 
271 263
 typedef void (*report_message)(const char *);
  264
+struct compiler_sc;
272 265
 
273 266
 void init_fpvm(struct fpvm_fragment *fragment, int vector_mode);
274 267
 struct patch *patch_compile(const char *basedir, const char *patch_code,
275 268
     report_message rmc);
276 269
 struct patch *patch_compile_filename(const char *filename,
277 270
     const char *patch_code, report_message rmc);
278  
-struct cvar *patch_add_cvar(struct patch *p);
  271
+struct stimuli *compiler_get_stimulus(struct compiler_sc *sc);
279 272
 struct patch *patch_copy(struct patch *p);
280 273
 void patch_free(struct patch *p);
281 274
 struct patch *patch_refresh(struct patch *p);
2  src/compiler/idgen
@@ -51,7 +51,7 @@ sed 's/#.*//;/^ *$/d' $1 | LANG=C sort | {
51 51
 	.pfv_idx = $2,
52 52
 	.pvv_idx = $3,
53 53
 	.flags = SF_SYSTEM,
54  
-	.cvar = -1,
  54
+	.stim_regs = NULL,
55 55
 },
56 56
 EOF
57 57
 		i=`expr $i + 1`
28  src/compiler/parser.y
@@ -28,6 +28,7 @@
28 28
 #include <fpvm/fpvm.h>
29 29
 
30 30
 #include "symtab.h"
  31
+#include "compiler.h"
31 32
 #include "parser.h"
32 33
 #include "parser_itf.h"
33 34
 #include "parser_helper.h"
@@ -40,10 +41,10 @@ typedef const char *(*assign_callback)(struct parser_comm *comm,
40 41
 	    struct sym *sym, struct ast_node *node);
41 42
 typedef void (*midi_proc)(struct s_midi_ctrl *ct, int value);
42 43
 
43  
-#define	FAIL(msg)				\
44  
-	do {					\
45  
-		error(state, msg);		\
46  
-		yy_parse_failed(yypParser);	\
  44
+#define	FAIL(msg, ...)					\
  45
+	do {						\
  46
+		error(state, msg, ##__VA_ARGS__);	\
  47
+		yy_parse_failed(yypParser);		\
47 48
 	} while (0)
48 49
 
49 50
 #define	OTHER_STYLE_new_style	old_style
@@ -299,13 +300,11 @@ assignment ::= ident(I) TOK_ASSIGN expr(N) opt_semi. {
299 300
 
300 301
 assignment ::= ident(I) TOK_ASSIGN TOK_MIDI TOK_LPAREN expr(A) TOK_COMMA
301 302
     expr(B) midi_proc(P) TOK_RPAREN opt_semi. {
302  
-	/* @@@ clean up this mess later */
303  
-	struct patch *p = *(struct patch **) state->comm->u.sc;
304 303
 	struct sym *sym = I->sym;
305  
-	struct cvar *cvar;
  304
+	struct stimuli *stim = compiler_get_stimulus(state->comm->u.sc);
306 305
 
307 306
 	free(I);
308  
-	if(sym->cvar != -1) {
  307
+	if(sym->stim_regs) {
309 308
 		FAIL("duplicate control variable");
310 309
 		return;
311 310
 	}
@@ -313,14 +312,11 @@ assignment ::= ident(I) TOK_ASSIGN TOK_MIDI TOK_LPAREN expr(A) TOK_COMMA
313 312
 		FAIL("midi(chan, ctrl) arguments must be constants");
314 313
 		return;
315 314
 	}
316  
-	cvar = patch_add_cvar(p);
317  
-	sym->cvar = cvar-p->cvars;
318  
-	if(!p->stim)
319  
-		p->stim = stim_new();
320  
-	/* @@@ check range ! */
321  
-	if(!stim_add(p->stim, A->contents.constant, B->contents.constant,
322  
-	    &cvar->val, P)) {
323  
-		FAIL("stim_add failed\n");
  315
+	sym->stim_regs = stim_add_midi_ctrl(stim,
  316
+	    A->contents.constant, B->contents.constant, P);
  317
+	if(!sym->stim_regs) {
  318
+		FAIL("cannot add stimulus for MIDI channel %d control %d\n",
  319
+		    (int) A->contents.constant, (int) B->contents.constant);
324 320
 		return;
325 321
 	}
326 322
 	parse_free(A);
4  src/compiler/symtab.c
@@ -107,7 +107,7 @@ struct sym *unique(const char *s)
107 107
 	new->fpvm_sym.name = strdup(s);
108 108
 	new->pfv_idx = new->pvv_idx = -1;
109 109
 	new->flags = 0;
110  
-	new->cvar = -1;
  110
+	new->stim_regs = NULL;
111 111
 	return new;
112 112
 }
113 113
 
@@ -133,7 +133,7 @@ struct sym *unique_n(const char *s, int n)
133 133
 	new->fpvm_sym.name = strdup_n(s, n);
134 134
 	new->pfv_idx = new->pvv_idx = -1;
135 135
 	new->flags = 0;
136  
-	new->cvar = -1;
  136
+	new->stim_regs = NULL;
137 137
 	return new;
138 138
 }
139 139
 
5  src/compiler/symtab.h
@@ -12,7 +12,7 @@
12 12
 #define	SYMTAB_H
13 13
 
14 14
 #include <fpvm/symbol.h>
15  
-#include "compiler.h"
  15
+#include "../renderer/stimuli.h"
16 16
 
17 17
 
18 18
 #define	SF_SYSTEM	(1 << 0)
@@ -22,7 +22,8 @@
22 22
 struct sym {
23 23
 	struct fpvm_sym fpvm_sym;
24 24
 	int pfv_idx, pvv_idx;	/* index; -1 if not a variable known to FN */
25  
-	int cvar;		/* -1 if not a control variable */
  25
+	struct stim_regs *stim_regs;
  26
+				/* NULL if not a control variable */
26 27
 	int flags;
27 28
 };
28 29
 
2  src/main.c
@@ -52,6 +52,7 @@
52 52
 #include "yaffs.h"
53 53
 #include "version.h"
54 54
 #include "renderer/videoinreconf.h"
  55
+#include "renderer/renderer.h"
55 56
 #include "shellext.h"
56 57
 #include "sysconfig.h"
57 58
 #include "fb.h"
@@ -95,6 +96,7 @@ static rtems_task gui_task(rtems_task_argument argument)
95 96
 	init_osc();
96 97
 	init_messagebox();
97 98
 	init_performance();
  99
+	init_renderer();
98 100
 	init_cp();
99 101
 	init_keyboard();
100 102
 	init_ir();
12  src/renderer/eval.c
@@ -58,8 +58,6 @@ static void write_pvv(struct patch *p, int pvv, float x)
58 58
 
59 59
 static void transfer_pvv_regs(struct patch *p)
60 60
 {
61  
-	const struct cvar *cv;
62  
-
63 61
 	write_pvv(p, pvv_texsize, renderer_texsize << TMU_FIXEDPOINT_SHIFT);
64 62
 	write_pvv(p, pvv_hmeshsize, 1.0/(float)renderer_hmeshlast);
65 63
 	write_pvv(p, pvv_vmeshsize, 1.0/(float)renderer_vmeshlast);
@@ -117,10 +115,6 @@ static void transfer_pvv_regs(struct patch *p)
117 115
 	write_pvv(p, pvv_midi6, read_pfv(p, pfv_midi6));
118 116
 	write_pvv(p, pvv_midi7, read_pfv(p, pfv_midi7));
119 117
 	write_pvv(p, pvv_midi8, read_pfv(p, pfv_midi8));
120  
-
121  
-	for(cv = p->cvars; cv != p->cvars+p->ncvars; cv++)
122  
-		if(cv->pvv_reg >= 0)
123  
-			p->pervertex_regs[cv->pvv_reg] = cv->val;
124 118
 }
125 119
 
126 120
 static void reinit_pfv(struct patch *p, int pfv)
@@ -142,8 +136,6 @@ static void reinit_all_pfv(struct patch *p)
142 136
 
143 137
 static void set_pfv_from_frd(struct patch *p, struct frame_descriptor *frd)
144 138
 {
145  
-	const struct cvar *cv;
146  
-
147 139
 	write_pfv(p, pfv_time, frd->time);
148 140
 	write_pfv(p, pfv_frame, frd->frame);
149 141
 	write_pfv(p, pfv_bass, frd->bass);
@@ -175,10 +167,6 @@ static void set_pfv_from_frd(struct patch *p, struct frame_descriptor *frd)
175 167
 	write_pfv(p, pfv_midi6, frd->midi[5]);
176 168
 	write_pfv(p, pfv_midi7, frd->midi[6]);
177 169
 	write_pfv(p, pfv_midi8, frd->midi[7]);
178  
-
179  
-	for(cv = p->cvars; cv != p->cvars+p->ncvars; cv++)
180  
-		if(cv->pfv_reg >= 0)
181  
-			p->perframe_regs[cv->pfv_reg] = cv->val;
182 170
 }
183 171
 
184 172
 static void set_frd_from_pfv(struct patch *p, struct frame_descriptor *frd)
7  src/renderer/renderer.c
@@ -144,7 +144,7 @@ struct patch *renderer_get_patch(int spin)
144 144
 	return current_patch;
145 145
 }
146 146
 
147  
-void renderer_start(int framebuffer_fd, struct patch *p)
  147
+void init_renderer(void)
148 148
 {
149 149
 	rtems_status_code sc;
150 150
 
@@ -156,7 +156,10 @@ void renderer_start(int framebuffer_fd, struct patch *p)
156 156
 		&patch_lock
157 157
 	);
158 158
 	assert(sc == RTEMS_SUCCESSFUL);
  159
+}
159 160
 
  161
+void renderer_start(int framebuffer_fd, struct patch *p)
  162
+{
160 163
 	assert(mashup_head == NULL);
161 164
 	mashup_head = patch_copy(p);
162 165
 	current_patch = mashup_head;
@@ -189,5 +192,5 @@ void renderer_stop(void)
189 192
 		patch_free(mashup_head);
190 193
 		mashup_head = p;
191 194
 	}
192  
-	rtems_semaphore_delete(patch_lock);
  195
+	current_patch = NULL;
193 196
 }
1  src/renderer/renderer.h
@@ -42,6 +42,7 @@ void renderer_add_patch(struct patch *p);
42 42
 void renderer_del_patch(struct patch *p);
43 43
 struct patch *renderer_get_patch(int spin);
44 44
 
  45
+void init_renderer(void);
45 46
 void renderer_start(int framebuffer_fd, struct patch *p);
46 47
 void renderer_stop(void);
47 48
 
3  src/renderer/sampler.c
@@ -273,7 +273,8 @@ static void midi_ctrl_event(struct patch *p, mtk_event *e)
273 273
 
274 274
 	if(chan == midi_channel)
275 275
 		midi_controllers[ctrl] = value;
276  
-	stim_midi_ctrl(p->stim, chan, ctrl, value);
  276
+	if(p)
  277
+		stim_midi_ctrl(p->stim, chan, ctrl, value);
277 278
 }
278 279
 
279 280
 /*
50  src/renderer/stimuli.c
@@ -16,9 +16,14 @@
16 16
 
17 17
 void midi_proc_linear(struct s_midi_ctrl *ct, int value)
18 18
 {
19  
-	*ct->var = (float) value/127.0;
20  
-}
  19
+	float f;
21 20
 
  21
+	f = (float) value/127.0;
  22
+	if(ct->regs.pfv)
  23
+		*ct->regs.pfv = f;
  24
+	if(ct->regs.pvv)
  25
+		*ct->regs.pvv = f;
  26
+}
22 27
 
23 28
 void midi_proc_accel_cyclic(struct s_midi_ctrl *ct, int value)
24 29
 {
@@ -26,7 +31,7 @@ void midi_proc_accel_cyclic(struct s_midi_ctrl *ct, int value)
26 31
 		ct->last += value;
27 32
 	else
28 33
 		ct->last -= 128-value;
29  
-	*ct->var = (float) (ct->last & 0x7f)/127.0;
  34
+	midi_proc_linear(ct, ct->last & 0x7f);
30 35
 }
31 36
 
32 37
 void midi_proc_accel_linear(struct s_midi_ctrl *ct, int value)
@@ -40,7 +45,7 @@ void midi_proc_accel_linear(struct s_midi_ctrl *ct, int value)
40 45
 		if(ct->last & 0x80)
41 46
 			ct->last = 0;
42 47
 	}
43  
-	*ct->var = (float) ct->last/127.0;
  48
+	midi_proc_linear(ct, ct->last);
44 49
 }
45 50
 
46 51
 
@@ -55,34 +60,34 @@ void stim_midi_ctrl(struct stimuli *s, int chan, int ctrl, int value)
55 60
 	}
56 61
 }
57 62
 
58  
-
59  
-int stim_add(struct stimuli *s, int chan, int ctrl, float *var,
  63
+struct stim_regs *stim_add_midi_ctrl(struct stimuli *s, int chan, int ctrl,
60 64
     void (*proc)(struct s_midi_ctrl *ct, int value))
61 65
 {
62 66
 	struct s_midi_chan *ch;
63 67
 	struct s_midi_ctrl *ct;
64 68
 
  69
+	if(chan < 0 || chan > 15 || ctrl < 0 || ctrl > 127)
  70
+		return NULL;
65 71
 	if(!s->midi[chan]) {
66 72
 		s->midi[chan] = calloc(1, sizeof(struct s_midi_chan));
67 73
 		if(!s->midi[chan])
68  
-			return 0;
  74
+			return NULL;
69 75
 	}
70 76
 	ch = s->midi[chan];
71 77
 
72 78
 	if(!ch->ctrl[ctrl]) {
73 79
 		ch->ctrl[ctrl] = calloc(1, sizeof(struct s_midi_ctrl));
74 80
 		if(!ch->ctrl[ctrl])
75  
-			return 0;
  81
+			return NULL;
76 82
 	}
77 83
 	ct = ch->ctrl[ctrl];
78 84
 
79 85
 	ct->proc = proc;
80  
-	ct->var = var;
  86
+	ct->regs.pfv = ct->regs.pvv = NULL;
81 87
 
82  
-	return 1;
  88
+	return &ct->regs;
83 89
 }
84 90
 
85  
-
86 91
 struct stimuli *stim_new(void)
87 92
 {
88 93
 	struct stimuli *s;
@@ -93,7 +98,6 @@ struct stimuli *stim_new(void)
93 98
 	return s;
94 99
 }
95 100
 
96  
-
97 101
 struct stimuli *stim_get(struct stimuli *s)
98 102
 {
99 103
 	if(s)
@@ -118,18 +122,24 @@ void stim_put(struct stimuli *s)
118 122
 	free(s);
119 123
 }
120 124
 
121  
-void stim_redirect(struct stimuli *s, const float *old, float *new)
  125
+void stim_redirect(struct stimuli *s, const void *old, void *new)
122 126
 {
123 127
 	int i, j;
124 128
 	struct s_midi_ctrl *ct;
125 129
 
126 130
 	if(!s)
127 131
 		return;
128  
-	for(i = 0; i != MIDI_CHANS; i++)
129  
-		if(s->midi[i])
130  
-			for(j = 0; j != MIDI_CTRLS; j++) {
131  
-					ct = s->midi[i]->ctrl[j];
132  
-					if (ct)
133  
-						ct->var = new+(ct->var-old);
134  
-				}
  132
+	for(i = 0; i != MIDI_CHANS; i++) {
  133
+		if(!s->midi[i])
  134
+			continue;
  135
+		for(j = 0; j != MIDI_CTRLS; j++) {
  136
+			ct = s->midi[i]->ctrl[j];
  137
+			if (!ct)
  138
+				continue;
  139
+			if(ct->regs.pfv)
  140
+				ct->regs.pfv = new+((void *) ct->regs.pfv-old);
  141
+			if(ct->regs.pvv)
  142
+				ct->regs.pvv = new+((void *) ct->regs.pvv-old);
  143
+		}
  144
+	}
135 145
 }
11  src/renderer/stimuli.h
@@ -17,11 +17,14 @@
17 17
 #define	MIDI_CHANS	16
18 18
 #define	MIDI_CTRLS	128
19 19
 
  20
+struct stim_regs {
  21
+	float *pfv, *pvv;	/* NULL if unused */
  22
+};
20 23
 
21 24
 struct s_midi_ctrl {
22 25
 	void (*proc)(struct s_midi_ctrl *sct, int value);
23  
-	float *var;
24  
-	uint8_t last;	/* for midi_proc_accel */
  26
+	struct stim_regs regs;
  27
+	uint8_t last;		/* for midi_proc_accel */
25 28
 };
26 29
 
27 30
 struct s_midi_chan {
@@ -42,11 +45,11 @@ void midi_proc_accel_cyclic(struct s_midi_ctrl *ct, int value);
42 45
 void midi_proc_accel_linear(struct s_midi_ctrl *ct, int value);
43 46
 
44 47
 void stim_midi_ctrl(struct stimuli *s, int chan, int ctrl, int value);
45  
-int stim_add(struct stimuli *s, int chan, int ctrl, float *var,
  48
+struct stim_regs *stim_add_midi_ctrl(struct stimuli *s, int chan, int ctrl,
46 49
     void (*proc)(struct s_midi_ctrl *ct, int value));
47 50
 struct stimuli *stim_new(void);
48 51
 struct stimuli *stim_get(struct stimuli *s);
49 52
 void stim_put(struct stimuli *s);
50  
-void stim_redirect(struct stimuli *s, const float *old, float *new);
  53
+void stim_redirect(struct stimuli *s, const void *old, void *new);
51 54
 
52 55
 #endif /* STIMULI_H */

No commit comments for this range

Something went wrong with that request. Please try again.