Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/flickernoise
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: e6fa3f6
Choose a base ref
...
head repository: m-labs/flickernoise
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c037acc
Choose a head ref
  • 2 commits
  • 6 files changed
  • 1 contributor

Commits on Jan 30, 2012

  1. stimuli: added processor for acceleration with an unbounded range

    accel_unbounded is (re)settable, as shown in T.fnp
    wpwrak committed Jan 30, 2012
    Copy the full SHA
    2f337e1 View commit details
  2. 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.
    wpwrak committed Jan 30, 2012
    Copy the full SHA
    c037acc View commit details
Showing with 41 additions and 10 deletions.
  1. +4 −1 experimental/T.fnp
  2. +2 −2 src/compiler/compiler.c
  3. +4 −0 src/compiler/parser.y
  4. +1 −0 src/compiler/scanner.re
  5. +26 −5 src/renderer/stimuli.c
  6. +4 −2 src/renderer/stimuli.h
5 changes: 4 additions & 1 deletion experimental/T.fnp
Original file line number Diff line number Diff line change
@@ -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 changes: 2 additions & 2 deletions src/compiler/compiler.c
Original file line number Diff line number Diff line change
@@ -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 changes: 4 additions & 0 deletions src/compiler/parser.y
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions src/compiler/scanner.re
Original file line number Diff line number Diff line change
@@ -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 changes: 26 additions & 5 deletions src/renderer/stimuli.c
Original file line number Diff line number Diff line change
@@ -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 changes: 4 additions & 2 deletions src/renderer/stimuli.h
Original file line number Diff line number Diff line change
@@ -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 */