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: 8553095
...
head fork: m-labs/flickernoise
compare: e6fa3f6
  • 7 commits
  • 14 files changed
  • 0 commit comments
  • 1 contributor
Commits on Jan 30, 2012
Werner Almesberger wpwrak experimental/T.fnp: Tornado Rain Dance variant for new MIDI control s…
…election

This is only temporary to better track changes.
1dd1b1c
Werner Almesberger wpwrak 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 wpwrak 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 wpwrak 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 wpwrak compiler/stimuli: refuse to assign out of range channel/controller nu…
…mbers
9b64d06
Werner Almesberger wpwrak compiler: move retrieval of stimuli pointer from parser into compiler.c
A bit cleaner this way.
bcb404d
Werner Almesberger wpwrak stimuli: rename stim_add to stim_add_midi_ctrl
It's not generic.
e6fa3f6
77 experimental/T.fnp
View
@@ -0,0 +1,77 @@
+/*
+ * Highly experimental variant of Tornado (Rain Dance MIDI RMX)
+ */
+fDecay=0.9950000
+fVideoEchoZoom=2.000000
+fVideoEchoAlpha=0.000000
+nVideoEchoOrientation=0
+nWaveMode=2
+bAdditiveWaves=0
+bWaveDots=0
+bMaximizeWaveColor=1
+bTexWrap=1
+mv_a=0
+nMotionVectorsX=12
+nMotionVectorsY=9
+fWaveAlpha=3.000000
+fWaveScale=3.020000
+fWarpAnimSpeed=1.000000
+fWarpScale=2.853000
+zoom=1.031000
+rot=0.000000
+cx=0.500000
+cy=0.500000
+dx=0.000000
+dy=0.000000
+warp=0.309000
+sx=1.000000
+sy=1.000000
+wave_r=0.600000
+wave_g=0.600000
+wave_b=0.600000
+wave_x=0.500000
+wave_y=0.500000
+
+/* MIDI settings for Faderfox LV3 */
+
+whirl = midi(0, 7); // fader 1
+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
+theta = midi(0, 25, accel_cyclic); // encoder 2
+
+red = midi(4, 7); // fader 5
+green = midi(5, 7); // fader 6
+blue = midi(6, 7); // fader 7
+change = midi(7, 7); // fader 8
+
+offcenter = midi(8, 4); // FX1
+xoff = midi(8, 1);
+yoff = midi(8, 2);
+shift = midi(9, 4); // FX2
+xshift = midi(9, 1);
+yshift = midi(9, 2);
+
+per_frame:
+ wave_scale = sensitivity*20;
+ t = time*change*5;
+ wave_r = red*( 0.60*sin(0.933*t) + 0.40*sin(1.045*t) );
+ wave_g = green*( 0.60*sin(0.900*t) + 0.40*sin(0.956*t) );
+ wave_b = blue*( 0.60*sin(0.910*t) + 0.40*sin(0.920*t) );
+ rot = whirl*2+twist/10;
+ dist = radius/5;
+// cx = offcenter ? 0.5+(xoff-0.5)*0.3 : 0.5;
+// cy = offcenter ? 0.5+(0.5-yoff)*0.3 : 0.5;
+ sx = offcenter ? 0.2*(xoff-0.5)+1 : 1;
+ sy = offcenter ? 0.2*(yoff-0.5)+1 : 1;
+ tmp = theta*6.2832;
+ wave_x = cx+cos(tmp)*dist;
+ wave_y = cy-sin(tmp)*dist;
+ dx = shift ? (xshift-0.5)*0.2 : 0;
+ dy = shift ? (yshift-0.5)*0.2 : 0;
+ zoom = 0.9+growth/5;
+
+per_vertex:
+ rot = rot + (rad-0.4)*1.7*max(0,min((bass_att-1.1)*1.5,5));
37 src/compiler/compiler.c
View
@@ -195,8 +195,8 @@ static void pfv_bind_callback(void *_sc, struct fpvm_sym *sym, int reg)
pfv_update_patch_requires(sc, pfv);
sc->p->pfv_allocation[pfv] = reg;
}
- if(s->cvar != -1)
- sc->p->cvars[s->cvar].pfv_reg = reg;
+ if(s->stim_regs)
+ s->stim_regs->pfv = sc->p->perframe_regs+reg;
}
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)
pvv_update_patch_requires(sc, pvv);
sc->p->pvv_allocation[pvv] = reg;
}
- if(s->cvar != -1)
- sc->p->cvars[s->cvar].pvv_reg = reg;
+ if(s->stim_regs)
+ s->stim_regs->pvv = sc->p->pervertex_regs+reg;
}
static bool init_pvv(struct compiler_sc *sc)
@@ -490,8 +490,6 @@ struct patch *patch_compile(const char *basedir, const char *patch_code,
sc->p->original = NULL;
sc->p->next = NULL;
sc->p->stim = NULL;
- sc->p->ncvars = 0;
- sc->p->cvars = NULL;
sc->basedir = basedir;
sc->rmc = rmc;
@@ -543,19 +541,11 @@ struct patch *patch_compile_filename(const char *filename,
return p;
}
-struct cvar *patch_add_cvar(struct patch *p)
+struct stimuli *compiler_get_stimulus(struct compiler_sc *sc)
{
- struct cvar *old = p->cvars;
- struct cvar *cv;
-
- p->ncvars++;
- p->cvars = realloc(old, sizeof(struct cvar)*p->ncvars);
- if(old)
- stim_redirect(p->stim, &old->val, &p->cvars->val);
- cv = p->cvars+p->ncvars-1;
- cv->val = 0;
- cv->pfv_reg = cv->pvv_reg = -1;
- return cv;
+ if(!sc->p->stim)
+ sc->p->stim = stim_new();
+ return sc->p->stim;
}
#ifndef STANDALONE
@@ -578,13 +568,7 @@ struct patch *patch_copy(struct patch *p)
pixbuf_inc_ref(img->pixbuf);
}
new_patch->stim = stim_get(p->stim);
- if(p->ncvars) {
- size_t size = p->ncvars*sizeof(struct cvar);
-
- new_patch->cvars = malloc(size);
- memcpy(new_patch->cvars, p->cvars, size);
- }
- stim_redirect(p->stim, &p->cvars->val, &new_patch->cvars->val);
+ stim_redirect(p->stim, p, new_patch);
return new_patch;
}
@@ -600,7 +584,6 @@ void patch_free(struct patch *p)
free((void *) img->filename);
}
stim_put(p->stim);
- free(p->cvars);
free(p);
}
@@ -622,4 +605,4 @@ struct patch *patch_refresh(struct patch *p)
return p;
}
-#endif
+#endif /* !STANDALONE */
11 src/compiler/compiler.h
View
@@ -226,12 +226,6 @@ struct image {
struct stat st;
};
-struct cvar {
- float val; /* current value */
- int pfv_reg; /* per-frame register */
- int pvv_reg; /* per-vertex register */
-};
-
struct patch {
/* per-frame */
struct image images[IMAGE_COUNT]; /* images used in this patch */
@@ -264,18 +258,17 @@ struct patch {
/* unified input events */
struct stimuli *stim; /* control variable hierarchy */
- int ncvars; /* number of control variables */
- struct cvar *cvars; /* control variables */
};
typedef void (*report_message)(const char *);
+struct compiler_sc;
void init_fpvm(struct fpvm_fragment *fragment, int vector_mode);
struct patch *patch_compile(const char *basedir, const char *patch_code,
report_message rmc);
struct patch *patch_compile_filename(const char *filename,
const char *patch_code, report_message rmc);
-struct cvar *patch_add_cvar(struct patch *p);
+struct stimuli *compiler_get_stimulus(struct compiler_sc *sc);
struct patch *patch_copy(struct patch *p);
void patch_free(struct patch *p);
struct patch *patch_refresh(struct patch *p);
2  src/compiler/idgen
View
@@ -51,7 +51,7 @@ sed 's/#.*//;/^ *$/d' $1 | LANG=C sort | {
.pfv_idx = $2,
.pvv_idx = $3,
.flags = SF_SYSTEM,
- .cvar = -1,
+ .stim_regs = NULL,
},
EOF
i=`expr $i + 1`
28 src/compiler/parser.y
View
@@ -28,6 +28,7 @@
#include <fpvm/fpvm.h>
#include "symtab.h"
+#include "compiler.h"
#include "parser.h"
#include "parser_itf.h"
#include "parser_helper.h"
@@ -40,10 +41,10 @@ typedef const char *(*assign_callback)(struct parser_comm *comm,
struct sym *sym, struct ast_node *node);
typedef void (*midi_proc)(struct s_midi_ctrl *ct, int value);
-#define FAIL(msg) \
- do { \
- error(state, msg); \
- yy_parse_failed(yypParser); \
+#define FAIL(msg, ...) \
+ do { \
+ error(state, msg, ##__VA_ARGS__); \
+ yy_parse_failed(yypParser); \
} while (0)
#define OTHER_STYLE_new_style old_style
@@ -299,13 +300,11 @@ assignment ::= ident(I) TOK_ASSIGN expr(N) opt_semi. {
assignment ::= ident(I) TOK_ASSIGN TOK_MIDI TOK_LPAREN expr(A) TOK_COMMA
expr(B) midi_proc(P) TOK_RPAREN opt_semi. {
- /* @@@ clean up this mess later */
- struct patch *p = *(struct patch **) state->comm->u.sc;
struct sym *sym = I->sym;
- struct cvar *cvar;
+ struct stimuli *stim = compiler_get_stimulus(state->comm->u.sc);
free(I);
- if(sym->cvar != -1) {
+ if(sym->stim_regs) {
FAIL("duplicate control variable");
return;
}
@@ -313,14 +312,11 @@ assignment ::= ident(I) TOK_ASSIGN TOK_MIDI TOK_LPAREN expr(A) TOK_COMMA
FAIL("midi(chan, ctrl) arguments must be constants");
return;
}
- cvar = patch_add_cvar(p);
- sym->cvar = cvar-p->cvars;
- if(!p->stim)
- p->stim = stim_new();
- /* @@@ check range ! */
- if(!stim_add(p->stim, A->contents.constant, B->contents.constant,
- &cvar->val, P)) {
- FAIL("stim_add failed\n");
+ sym->stim_regs = stim_add_midi_ctrl(stim,
+ A->contents.constant, B->contents.constant, P);
+ if(!sym->stim_regs) {
+ FAIL("cannot add stimulus for MIDI channel %d control %d\n",
+ (int) A->contents.constant, (int) B->contents.constant);
return;
}
parse_free(A);
4 src/compiler/symtab.c
View
@@ -107,7 +107,7 @@ struct sym *unique(const char *s)
new->fpvm_sym.name = strdup(s);
new->pfv_idx = new->pvv_idx = -1;
new->flags = 0;
- new->cvar = -1;
+ new->stim_regs = NULL;
return new;
}
@@ -133,7 +133,7 @@ struct sym *unique_n(const char *s, int n)
new->fpvm_sym.name = strdup_n(s, n);
new->pfv_idx = new->pvv_idx = -1;
new->flags = 0;
- new->cvar = -1;
+ new->stim_regs = NULL;
return new;
}
5 src/compiler/symtab.h
View
@@ -12,7 +12,7 @@
#define SYMTAB_H
#include <fpvm/symbol.h>
-#include "compiler.h"
+#include "../renderer/stimuli.h"
#define SF_SYSTEM (1 << 0)
@@ -22,7 +22,8 @@
struct sym {
struct fpvm_sym fpvm_sym;
int pfv_idx, pvv_idx; /* index; -1 if not a variable known to FN */
- int cvar; /* -1 if not a control variable */
+ struct stim_regs *stim_regs;
+ /* NULL if not a control variable */
int flags;
};
2  src/main.c
View
@@ -52,6 +52,7 @@
#include "yaffs.h"
#include "version.h"
#include "renderer/videoinreconf.h"
+#include "renderer/renderer.h"
#include "shellext.h"
#include "sysconfig.h"
#include "fb.h"
@@ -95,6 +96,7 @@ static rtems_task gui_task(rtems_task_argument argument)
init_osc();
init_messagebox();
init_performance();
+ init_renderer();
init_cp();
init_keyboard();
init_ir();
12 src/renderer/eval.c
View
@@ -58,8 +58,6 @@ static void write_pvv(struct patch *p, int pvv, float x)
static void transfer_pvv_regs(struct patch *p)
{
- const struct cvar *cv;
-
write_pvv(p, pvv_texsize, renderer_texsize << TMU_FIXEDPOINT_SHIFT);
write_pvv(p, pvv_hmeshsize, 1.0/(float)renderer_hmeshlast);
write_pvv(p, pvv_vmeshsize, 1.0/(float)renderer_vmeshlast);
@@ -117,10 +115,6 @@ static void transfer_pvv_regs(struct patch *p)
write_pvv(p, pvv_midi6, read_pfv(p, pfv_midi6));
write_pvv(p, pvv_midi7, read_pfv(p, pfv_midi7));
write_pvv(p, pvv_midi8, read_pfv(p, pfv_midi8));
-
- for(cv = p->cvars; cv != p->cvars+p->ncvars; cv++)
- if(cv->pvv_reg >= 0)
- p->pervertex_regs[cv->pvv_reg] = cv->val;
}
static void reinit_pfv(struct patch *p, int pfv)
@@ -142,8 +136,6 @@ static void reinit_all_pfv(struct patch *p)
static void set_pfv_from_frd(struct patch *p, struct frame_descriptor *frd)
{
- const struct cvar *cv;
-
write_pfv(p, pfv_time, frd->time);
write_pfv(p, pfv_frame, frd->frame);
write_pfv(p, pfv_bass, frd->bass);
@@ -175,10 +167,6 @@ static void set_pfv_from_frd(struct patch *p, struct frame_descriptor *frd)
write_pfv(p, pfv_midi6, frd->midi[5]);
write_pfv(p, pfv_midi7, frd->midi[6]);
write_pfv(p, pfv_midi8, frd->midi[7]);
-
- for(cv = p->cvars; cv != p->cvars+p->ncvars; cv++)
- if(cv->pfv_reg >= 0)
- p->perframe_regs[cv->pfv_reg] = cv->val;
}
static void set_frd_from_pfv(struct patch *p, struct frame_descriptor *frd)
7 src/renderer/renderer.c
View
@@ -144,7 +144,7 @@ struct patch *renderer_get_patch(int spin)
return current_patch;
}
-void renderer_start(int framebuffer_fd, struct patch *p)
+void init_renderer(void)
{
rtems_status_code sc;
@@ -156,7 +156,10 @@ void renderer_start(int framebuffer_fd, struct patch *p)
&patch_lock
);
assert(sc == RTEMS_SUCCESSFUL);
+}
+void renderer_start(int framebuffer_fd, struct patch *p)
+{
assert(mashup_head == NULL);
mashup_head = patch_copy(p);
current_patch = mashup_head;
@@ -189,5 +192,5 @@ void renderer_stop(void)
patch_free(mashup_head);
mashup_head = p;
}
- rtems_semaphore_delete(patch_lock);
+ current_patch = NULL;
}
1  src/renderer/renderer.h
View
@@ -42,6 +42,7 @@ void renderer_add_patch(struct patch *p);
void renderer_del_patch(struct patch *p);
struct patch *renderer_get_patch(int spin);
+void init_renderer(void);
void renderer_start(int framebuffer_fd, struct patch *p);
void renderer_stop(void);
3  src/renderer/sampler.c
View
@@ -273,7 +273,8 @@ static void midi_ctrl_event(struct patch *p, mtk_event *e)
if(chan == midi_channel)
midi_controllers[ctrl] = value;
- stim_midi_ctrl(p->stim, chan, ctrl, value);
+ if(p)
+ stim_midi_ctrl(p->stim, chan, ctrl, value);
}
/*
50 src/renderer/stimuli.c
View
@@ -16,9 +16,14 @@
void midi_proc_linear(struct s_midi_ctrl *ct, int value)
{
- *ct->var = (float) value/127.0;
-}
+ 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_accel_cyclic(struct s_midi_ctrl *ct, int value)
{
@@ -26,7 +31,7 @@ void midi_proc_accel_cyclic(struct s_midi_ctrl *ct, int value)
ct->last += value;
else
ct->last -= 128-value;
- *ct->var = (float) (ct->last & 0x7f)/127.0;
+ midi_proc_linear(ct, ct->last & 0x7f);
}
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)
if(ct->last & 0x80)
ct->last = 0;
}
- *ct->var = (float) ct->last/127.0;
+ midi_proc_linear(ct, ct->last);
}
@@ -55,34 +60,34 @@ void stim_midi_ctrl(struct stimuli *s, int chan, int ctrl, int value)
}
}
-
-int stim_add(struct stimuli *s, int chan, int ctrl, float *var,
+struct stim_regs *stim_add_midi_ctrl(struct stimuli *s, int chan, int ctrl,
void (*proc)(struct s_midi_ctrl *ct, int value))
{
struct s_midi_chan *ch;
struct s_midi_ctrl *ct;
+ if(chan < 0 || chan > 15 || ctrl < 0 || ctrl > 127)
+ return NULL;
if(!s->midi[chan]) {
s->midi[chan] = calloc(1, sizeof(struct s_midi_chan));
if(!s->midi[chan])
- return 0;
+ return NULL;
}
ch = s->midi[chan];
if(!ch->ctrl[ctrl]) {
ch->ctrl[ctrl] = calloc(1, sizeof(struct s_midi_ctrl));
if(!ch->ctrl[ctrl])
- return 0;
+ return NULL;
}
ct = ch->ctrl[ctrl];
ct->proc = proc;
- ct->var = var;
+ ct->regs.pfv = ct->regs.pvv = NULL;
- return 1;
+ return &ct->regs;
}
-
struct stimuli *stim_new(void)
{
struct stimuli *s;
@@ -93,7 +98,6 @@ struct stimuli *stim_new(void)
return s;
}
-
struct stimuli *stim_get(struct stimuli *s)
{
if(s)
@@ -118,18 +122,24 @@ void stim_put(struct stimuli *s)
free(s);
}
-void stim_redirect(struct stimuli *s, const float *old, float *new)
+void stim_redirect(struct stimuli *s, const void *old, void *new)
{
int i, j;
struct s_midi_ctrl *ct;
if(!s)
return;
- for(i = 0; i != MIDI_CHANS; i++)
- if(s->midi[i])
- for(j = 0; j != MIDI_CTRLS; j++) {
- ct = s->midi[i]->ctrl[j];
- if (ct)
- ct->var = new+(ct->var-old);
- }
+ for(i = 0; i != MIDI_CHANS; i++) {
+ if(!s->midi[i])
+ continue;
+ for(j = 0; j != MIDI_CTRLS; j++) {
+ ct = s->midi[i]->ctrl[j];
+ if (!ct)
+ continue;
+ if(ct->regs.pfv)
+ ct->regs.pfv = new+((void *) ct->regs.pfv-old);
+ if(ct->regs.pvv)
+ ct->regs.pvv = new+((void *) ct->regs.pvv-old);
+ }
+ }
}
11 src/renderer/stimuli.h
View
@@ -17,11 +17,14 @@
#define MIDI_CHANS 16
#define MIDI_CTRLS 128
+struct stim_regs {
+ float *pfv, *pvv; /* NULL if unused */
+};
struct s_midi_ctrl {
void (*proc)(struct s_midi_ctrl *sct, int value);
- float *var;
- uint8_t last; /* for midi_proc_accel */
+ struct stim_regs regs;
+ uint8_t last; /* for midi_proc_accel */
};
struct s_midi_chan {
@@ -42,11 +45,11 @@ void midi_proc_accel_cyclic(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);
-int stim_add(struct stimuli *s, int chan, int ctrl, float *var,
+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_get(struct stimuli *s);
void stim_put(struct stimuli *s);
-void stim_redirect(struct stimuli *s, const float *old, float *new);
+void stim_redirect(struct stimuli *s, const void *old, void *new);
#endif /* STIMULI_H */

No commit comments for this range

Something went wrong with that request. Please try again.