Skip to content

Commit

Permalink
Flag patches requiring stimulus and exclude them from simple mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastien Bourdeauducq committed Feb 26, 2012
1 parent 5109cd4 commit 96091d5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
6 changes: 4 additions & 2 deletions src/compiler/compiler.c
Expand Up @@ -118,7 +118,6 @@ static void pfv_update_patch_requires(struct compiler_sc *sc, int pfv)
sc->p->require |= REQUIRE_DMX;
if(pfv >= pfv_osc1 && pfv <= pfv_osc4)
sc->p->require |= REQUIRE_OSC;
// TODO: MIDI detection
if(pfv == pfv_video_a)
sc->p->require |= REQUIRE_VIDEO;
}
Expand Down Expand Up @@ -197,6 +196,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->stim != NULL)
sc->p->require |= REQUIRE_STIM;
for(r = s->stim; r; r = r->next)
r->regs->pfv = sc->p->perframe_regs+reg;
}
Expand Down Expand Up @@ -263,7 +264,6 @@ static void pvv_update_patch_requires(struct compiler_sc *sc, int pvv)
sc->p->require |= REQUIRE_DMX;
if(pvv >= pvv_osc1 && pvv <= pvv_osc4)
sc->p->require |= REQUIRE_OSC;
// TODO: MIDI detection
}

static void pvv_bind_callback(void *_sc, struct fpvm_sym *sym, int reg)
Expand All @@ -278,6 +278,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->stim != NULL)
sc->p->require |= REQUIRE_STIM;
for(r = s->stim; r; r = r->next)
r->regs->pvv = sc->p->pervertex_regs+reg;
}
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/compiler.h
Expand Up @@ -201,7 +201,7 @@ enum {

#define REQUIRE_DMX (1 << 0)
#define REQUIRE_OSC (1 << 1)
#define REQUIRE_MIDI (1 << 2)
#define REQUIRE_STIM (1 << 2)
#define REQUIRE_VIDEO (1 << 3)

struct image {
Expand Down Expand Up @@ -235,7 +235,7 @@ struct patch {
float pervertex_regs[PFPU_REG_COUNT]; /* PFPU initial per-vertex
regf */
/* meta */
unsigned int require; /* bitmask: dmx, osc, midi, video */
unsigned int require; /* bitmask: dmx, osc, stim, video */
void *original; /* original patch (with initial register
values) */
int ref; /* reference count */
Expand Down
24 changes: 14 additions & 10 deletions src/gui/midi.c
Expand Up @@ -159,7 +159,6 @@ static int midistr(const char *str)

static int appid;
static struct filedialog *browse_dlg;
static int learn = -1;

static int w_open;

Expand Down Expand Up @@ -246,25 +245,31 @@ static void selchange_callback(mtk_event *e, void *arg)
}
}

static void note_event(int code)
static void note_event(int chan, int code)
{
char note[16];

chan++;

strmidi(note, code);
mtk_cmdf(appid, "e_note.set(-text \"%s\")", note);
if(chan == mtk_req_i(appid, "e_channel.text")) {
mtk_cmdf(appid, "e_note.set(-text \"%s\")", note);
mtk_cmdf(appid, "l_lastctl.set(-text \"\e%d = %s\")",
chan, note);
} else {
mtk_cmdf(appid, "l_lastctl.set(-text \"\e(%d = %s)\")",
chan, note);
}
}

static void controller_event(int chan, int controller, int value)
{
chan++;
if(chan == mtk_req_i(appid, "e_channel.text")) {
mtk_cmdf(appid, "l_lastctl.set(-text \"%d.%d = %d\")",
mtk_cmdf(appid, "l_lastctl.set(-text \"\e%d.%d = %d\")",
chan, controller, value);
if(learn != -1)
mtk_cmdf(appid, "e_midi%d.set(-text \"%d\")",
learn, controller);
} else {
mtk_cmdf(appid, "l_lastctl.set(-text \"(%d.%d = %d)\")",
mtk_cmdf(appid, "l_lastctl.set(-text \"\e(%d.%d = %d)\")",
chan, controller, value);
}
}
Expand All @@ -277,8 +282,7 @@ static void midi_event(mtk_event *e, int count)
chan = (e[i].press.code & 0x0f0000) >> 16;
switch(e[i].type) {
case EVENT_TYPE_MIDI_NOTEON:
if(chan == mtk_req_i(appid, "e_channel.text")-1)
note_event(e[i].press.code & 0x7f);
note_event(chan, e[i].press.code & 0x7f);
break;
case EVENT_TYPE_MIDI_CONTROLLER:
controller_event(chan,
Expand Down
2 changes: 1 addition & 1 deletion src/gui/performance.c
Expand Up @@ -426,7 +426,7 @@ static int suitable_for_simple(struct patch *p)
suitable = 1;
if(p->require & REQUIRE_DMX) suitable = 0;
if(p->require & REQUIRE_OSC) suitable = 0;
if(p->require & REQUIRE_MIDI) suitable = 0;
if(p->require & REQUIRE_STIM) suitable = 0;
if((p->require & REQUIRE_VIDEO) && !input_video) suitable = 0;
return suitable;
}
Expand Down

0 comments on commit 96091d5

Please sign in to comment.