Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: m-labs/flickernoise
base: e6fa3f6
...
head fork: m-labs/flickernoise
compare: c037acc
  • 2 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
Commits on Jan 30, 2012
Werner Almesberger wpwrak stimuli: added processor for acceleration with an unbounded range
accel_unbounded is (re)settable, as shown in T.fnp
2f337e1
Werner Almesberger wpwrak stimuli: remember and update base pointer for stim_redirect
Running a patch twice broke direct MIDI because pointers were updated
relative to the previous copy instead of the original patch. The commit
fixed the problem. The overall ugliness of the process remains, though.
c037acc
5 experimental/T.fnp
View
@@ -39,7 +39,8 @@ growth = midi(1, 7); // fader 2
radius = midi(2, 7); // fader 3
sensitivity = midi(3, 7); // fader 4
-twist = midi(0, 24, accel_linear); // encoder 1
+twist = midi(0, 24, accel_unbounded); // encoder 1
+reset_twist = midi(0, 28); // encoder 1 push
theta = midi(0, 25, accel_cyclic); // encoder 2
red = midi(4, 7); // fader 5
@@ -72,6 +73,8 @@ per_frame:
dx = shift ? (xshift-0.5)*0.2 : 0;
dy = shift ? (yshift-0.5)*0.2 : 0;
zoom = 0.9+growth/5;
+ twist = last_reset_twist == reset_twist+1 ? twist : 0;
+ last_reset_twist = reset_twist+1; // avoid 0, so first push is change
per_vertex:
rot = rot + (rad-0.4)*1.7*max(0,min((bass_att-1.1)*1.5,5));
4 src/compiler/compiler.c
View
@@ -544,7 +544,7 @@ struct patch *patch_compile_filename(const char *filename,
struct stimuli *compiler_get_stimulus(struct compiler_sc *sc)
{
if(!sc->p->stim)
- sc->p->stim = stim_new();
+ sc->p->stim = stim_new(sc->p);
return sc->p->stim;
}
@@ -568,7 +568,7 @@ struct patch *patch_copy(struct patch *p)
pixbuf_inc_ref(img->pixbuf);
}
new_patch->stim = stim_get(p->stim);
- stim_redirect(p->stim, p, new_patch);
+ stim_redirect(p->stim, new_patch);
return new_patch;
}
4 src/compiler/parser.y
View
@@ -335,6 +335,10 @@ midi_proc(P) ::= TOK_COMMA TOK_ACCEL_LINEAR. {
P = midi_proc_accel_linear;
}
+midi_proc(P) ::= TOK_COMMA TOK_ACCEL_UNBOUNDED. {
+ P = midi_proc_accel_unbounded;
+}
+
midi_proc(P) ::= TOK_COMMA TOK_ACCEL_CYCLIC. {
P = midi_proc_accel_cyclic;
}
1  src/compiler/scanner.re
View
@@ -133,6 +133,7 @@ int scan(struct scanner *s)
<N>"midi" { return TOK_MIDI; }
<N>"linear" { return TOK_LINEAR; }
<N>"accel_linear" { return TOK_ACCEL_LINEAR; }
+ <N>"accel_unbounded" { return TOK_ACCEL_UNBOUNDED; }
<N>"accel_cyclic" { return TOK_ACCEL_CYCLIC; }
<N>"imagefile"[1-9] { YYSETCONDITION(yycFNAME1);
31 src/renderer/stimuli.c
View
@@ -10,10 +10,22 @@
#include <stdlib.h>
#include <string.h>
+#include <sys/types.h>
#include "stimuli.h"
+static void midi_add(struct s_midi_ctrl *ct, int value)
+{
+ float f;
+
+ f = (float) value/127.0;
+ if(ct->regs.pfv)
+ *ct->regs.pfv += f;
+ if(ct->regs.pvv)
+ *ct->regs.pvv += f;
+}
+
void midi_proc_linear(struct s_midi_ctrl *ct, int value)
{
float f;
@@ -34,6 +46,11 @@ void midi_proc_accel_cyclic(struct s_midi_ctrl *ct, int value)
midi_proc_linear(ct, ct->last & 0x7f);
}
+void midi_proc_accel_unbounded(struct s_midi_ctrl *ct, int value)
+{
+ midi_add(ct, value < 64 ? value : value-128);
+}
+
void midi_proc_accel_linear(struct s_midi_ctrl *ct, int value)
{
if(value < 64) {
@@ -88,13 +105,15 @@ struct stim_regs *stim_add_midi_ctrl(struct stimuli *s, int chan, int ctrl,
return &ct->regs;
}
-struct stimuli *stim_new(void)
+struct stimuli *stim_new(const void *target)
{
struct stimuli *s;
s = calloc(1, sizeof(struct stimuli));
- if(s)
+ if(s) {
s->ref = 1;
+ s->target = target;
+ }
return s;
}
@@ -122,10 +141,11 @@ void stim_put(struct stimuli *s)
free(s);
}
-void stim_redirect(struct stimuli *s, const void *old, void *new)
+void stim_redirect(struct stimuli *s, void *new)
{
int i, j;
struct s_midi_ctrl *ct;
+ ptrdiff_t d = new-s->target;
if(!s)
return;
@@ -137,9 +157,10 @@ void stim_redirect(struct stimuli *s, const void *old, void *new)
if (!ct)
continue;
if(ct->regs.pfv)
- ct->regs.pfv = new+((void *) ct->regs.pfv-old);
+ ct->regs.pfv = (void *) ct->regs.pfv+d;
if(ct->regs.pvv)
- ct->regs.pvv = new+((void *) ct->regs.pvv-old);
+ ct->regs.pvv = (void *) ct->regs.pvv+d;
}
}
+ s->target = new;
}
6 src/renderer/stimuli.h
View
@@ -34,6 +34,7 @@ struct s_midi_chan {
struct stimuli {
struct s_midi_chan *midi[MIDI_CHANS];
int ref;
+ const void *target; /* reference address for pointer relocation */
};
@@ -42,14 +43,15 @@ void midi_proc_linear(struct s_midi_ctrl *ct, int value);
/* "Acceleration" (signed 7 bit delta value) with linear mapping */
void midi_proc_accel_cyclic(struct s_midi_ctrl *ct, int value);
+void midi_proc_accel_unbounded(struct s_midi_ctrl *ct, int value);
void midi_proc_accel_linear(struct s_midi_ctrl *ct, int value);
void stim_midi_ctrl(struct stimuli *s, int chan, int ctrl, int value);
struct stim_regs *stim_add_midi_ctrl(struct stimuli *s, int chan, int ctrl,
void (*proc)(struct s_midi_ctrl *ct, int value));
-struct stimuli *stim_new(void);
+struct stimuli *stim_new(const void *target);
struct stimuli *stim_get(struct stimuli *s);
void stim_put(struct stimuli *s);
-void stim_redirect(struct stimuli *s, const void *old, void *new);
+void stim_redirect(struct stimuli *s, void *new);
#endif /* STIMULI_H */

No commit comments for this range

Something went wrong with that request. Please try again.