Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Flag patches requiring stimulus and exclude them from simple mode

  • Loading branch information...
commit 96091d51bcb133b3da96992eba7967fbcfa96dd8 1 parent 5109cd4
Sébastien Bourdeauducq authored February 26, 2012
6  src/compiler/compiler.c
@@ -118,7 +118,6 @@ static void pfv_update_patch_requires(struct compiler_sc *sc, int pfv)
118 118
 		sc->p->require |= REQUIRE_DMX;
119 119
 	if(pfv >= pfv_osc1 && pfv <= pfv_osc4)
120 120
 		sc->p->require |= REQUIRE_OSC;
121  
-	// TODO: MIDI detection
122 121
 	if(pfv == pfv_video_a)
123 122
 		sc->p->require |= REQUIRE_VIDEO;
124 123
 }
@@ -197,6 +196,8 @@ static void pfv_bind_callback(void *_sc, struct fpvm_sym *sym, int reg)
197 196
 		pfv_update_patch_requires(sc, pfv);
198 197
 		sc->p->pfv_allocation[pfv] = reg;
199 198
 	}
  199
+	if(s->stim != NULL)
  200
+		sc->p->require |= REQUIRE_STIM;
200 201
 	for(r = s->stim; r; r = r->next)
201 202
 		r->regs->pfv = sc->p->perframe_regs+reg;
202 203
 }
@@ -263,7 +264,6 @@ static void pvv_update_patch_requires(struct compiler_sc *sc, int pvv)
263 264
 		sc->p->require |= REQUIRE_DMX;
264 265
 	if(pvv >= pvv_osc1 && pvv <= pvv_osc4)
265 266
 		sc->p->require |= REQUIRE_OSC;
266  
-	// TODO: MIDI detection
267 267
 }
268 268
 
269 269
 static void pvv_bind_callback(void *_sc, struct fpvm_sym *sym, int reg)
@@ -278,6 +278,8 @@ static void pvv_bind_callback(void *_sc, struct fpvm_sym *sym, int reg)
278 278
 		pvv_update_patch_requires(sc, pvv);
279 279
 		sc->p->pvv_allocation[pvv] = reg;
280 280
 	}
  281
+	if(s->stim != NULL)
  282
+		sc->p->require |= REQUIRE_STIM;
281 283
 	for(r = s->stim; r; r = r->next)
282 284
 		r->regs->pvv = sc->p->pervertex_regs+reg;
283 285
 }
4  src/compiler/compiler.h
@@ -201,7 +201,7 @@ enum {
201 201
 
202 202
 #define REQUIRE_DMX	(1 << 0)
203 203
 #define REQUIRE_OSC	(1 << 1)
204  
-#define REQUIRE_MIDI	(1 << 2)
  204
+#define REQUIRE_STIM	(1 << 2)
205 205
 #define REQUIRE_VIDEO	(1 << 3)
206 206
 
207 207
 struct image {
@@ -235,7 +235,7 @@ struct patch {
235 235
 	float pervertex_regs[PFPU_REG_COUNT];	/* PFPU initial per-vertex
236 236
 						   regf */
237 237
 	/* meta */
238  
-	unsigned int require;	/* bitmask: dmx, osc, midi, video */
  238
+	unsigned int require;	/* bitmask: dmx, osc, stim, video */
239 239
 	void *original;		/* original patch (with initial register
240 240
 				   values) */
241 241
 	int ref;		/* reference count */
24  src/gui/midi.c
@@ -159,7 +159,6 @@ static int midistr(const char *str)
159 159
 
160 160
 static int appid;
161 161
 static struct filedialog *browse_dlg;
162  
-static int learn = -1;
163 162
 
164 163
 static int w_open;
165 164
 
@@ -246,25 +245,31 @@ static void selchange_callback(mtk_event *e, void *arg)
246 245
 	}
247 246
 }
248 247
 
249  
-static void note_event(int code)
  248
+static void note_event(int chan, int code)
250 249
 {
251 250
 	char note[16];
252 251
 	
  252
+	chan++;
  253
+	
253 254
 	strmidi(note, code);
254  
-	mtk_cmdf(appid, "e_note.set(-text \"%s\")", note);
  255
+	if(chan == mtk_req_i(appid, "e_channel.text")) {
  256
+		mtk_cmdf(appid, "e_note.set(-text \"%s\")", note);
  257
+		mtk_cmdf(appid, "l_lastctl.set(-text \"\e%d = %s\")",
  258
+		    chan, note);
  259
+	} else {
  260
+		mtk_cmdf(appid, "l_lastctl.set(-text \"\e(%d = %s)\")",
  261
+		    chan, note);
  262
+	}
255 263
 }
256 264
 
257 265
 static void controller_event(int chan, int controller, int value)
258 266
 {
259 267
 	chan++;
260 268
 	if(chan == mtk_req_i(appid, "e_channel.text")) {
261  
-		mtk_cmdf(appid, "l_lastctl.set(-text \"%d.%d = %d\")",
  269
+		mtk_cmdf(appid, "l_lastctl.set(-text \"\e%d.%d = %d\")",
262 270
 		    chan, controller, value);
263  
-		if(learn != -1)
264  
-			mtk_cmdf(appid, "e_midi%d.set(-text \"%d\")",
265  
-			    learn, controller);
266 271
 	} else {
267  
-		mtk_cmdf(appid, "l_lastctl.set(-text \"(%d.%d = %d)\")",
  272
+		mtk_cmdf(appid, "l_lastctl.set(-text \"\e(%d.%d = %d)\")",
268 273
 		    chan, controller, value);
269 274
 	}
270 275
 }
@@ -277,8 +282,7 @@ static void midi_event(mtk_event *e, int count)
277 282
 		chan = (e[i].press.code & 0x0f0000) >> 16;
278 283
 		switch(e[i].type) {
279 284
 			case EVENT_TYPE_MIDI_NOTEON:
280  
-				if(chan == mtk_req_i(appid, "e_channel.text")-1)
281  
-					note_event(e[i].press.code & 0x7f);
  285
+				note_event(chan, e[i].press.code & 0x7f);
282 286
 				break;
283 287
 			case EVENT_TYPE_MIDI_CONTROLLER:
284 288
 				controller_event(chan,
2  src/gui/performance.c
@@ -426,7 +426,7 @@ static int suitable_for_simple(struct patch *p)
426 426
 	suitable = 1;
427 427
 	if(p->require & REQUIRE_DMX) suitable = 0;
428 428
 	if(p->require & REQUIRE_OSC) suitable = 0;
429  
-	if(p->require & REQUIRE_MIDI) suitable = 0;
  429
+	if(p->require & REQUIRE_STIM) suitable = 0;
430 430
 	if((p->require & REQUIRE_VIDEO) && !input_video) suitable = 0;
431 431
 	return suitable;
432 432
 }

0 notes on commit 96091d5

Please sign in to comment.
Something went wrong with that request. Please try again.