Trouble making midi trigger video in processing, please help!

edited March 2018 in Library Questions

Was wondering if anyone could please offer some advice on a piece of code? I'm trying to write a sketch that plays a video whilst a key is being pressed on a midi keyboard, as far as I can tell this should work but for whatever reason, it isn't, so it's a bit of a brick wall. Any ideas? The sketch runs without crashing but the video doesn't trigger despite the IF statement seeming correct. Total noob here so I may be way off.

Code below.

import processing.video.*; import themidibus.*; //Import the library String PATH = "//Users/macuser/Desktop/Beyond_Midi_Vid_/data/BLS 4.mp4";

Movie mov; MidiBus myBus; // The MidiBus int val; // Data value received from the serial port long startTime = 0; // Starts at point triggered long interval = (1000); // length of time boolean draw = false; //default state is off boolean prevPlayMov = false; // don't play the mov boolean playMov = false; // don't play the sound

void delay(int time) {int current = millis(); while (millis () < current+time) Thread.yield();}

void movieEvent (Movie mov) {mov.read();}

void setup() {size(600, 540); background(0);}

myBus = new MidiBus(this, 0, 1); // Create a new MidiBus using the device index to select the Midi input and output devices respectively. }

void noteOn(int channel, int pitch, int velocity) // Receive a noteOn { println(); println("Note On:"); println("--------"); println("Channel:"+channel); println("Pitch:"+pitch); println("Velocity:"+velocity); }

void noteOff(int channel, int pitch, int velocity) // Receive a noteOff { println(); println("Note Off:"); println("--------"); println("Channel:"+channel); println("Pitch:"+pitch); println("Velocity:"+velocity); } void draw() { int channel = 0; int pitch = 64; int velocity = 127;

myBus.sendNoteOn(channel, pitch, velocity); // Send a Midi noteOn delay(200); myBus.sendNoteOff(channel, pitch, velocity); // Send a Midi nodeOff

if (velocity == 100) { playMov = true; }

if (playMov == true) { mov.read(); mov.play(); mov.speed(1); mov.volume(0); image(mov, 0, 0, width, height); }

if (velocity < 100) { playMov = false; } }

Sign In or Register to comment.