Hello,
I'm working on a project involving multiple percussionists and midi triggers. The idea is to show a background video of different shapes moving around and then have some of those shapes move and/or new shapes appear on the screen depending on which drum is hit and how hard. At this point, when a note happens, a shape appears on the screen and spins depending on the pitch and velocity. The spinning seems kind of jerky to me though. Any thoughts on how to get smoother movement? Thanks very much.
/* Creates an ArrayList of LinkedLists to hold the note data. If three different pitch values are allowed (or three different drum trigger inputs), an ArrayList of 3 linked lists is created. Each linked list holds the 5 most recent note events for its pitch value.*/
import themidibus.*; //Midi library
MidiBus myBus; // The MidiBus int numStreams = 3; //Number of MIDI inputs int numNotes = 5; //Maximum number of notes shown at any given time per MIDI input boolean noteEvent = false; ArrayList< LinkedList<Note>> streams; LinkedList<Note> currentStream; Note[] newNotes;
void setup() { streams = new ArrayList< LinkedList< Note >>(); newNotes = new Note[numStreams]; size(854, 480); noStroke(); smooth(); rectMode(CENTER); for (int i = 0; i < numStreams; i++) { currentStream = new LinkedList<Note>(); streams.add(currentStream); } myBus = new MidiBus(this, -1, "Java Sound Synthesizer"); }
void draw() { background(0);
for (LinkedList<Note> y : streams) { for (Note z : y) { z.display(); //display each Note and update its rotation and opacity } }
if (noteEvent == true) { //if note events have happened since last time through draw, update the appropriate linked lists for (int i = 0; i < numStreams; i++) { if (newNotes[i] != null) { (streams.get(i)).add(newNotes[i]); while ((streams.get(i)).size() > numNotes) { (streams.get(i)).remove(); } newNotes[i] = null; } } noteEvent = false; } }
void keyPressed() { //using keyboard keys a, s, and d in this version int channel = 0; int pitch = 0; int velocity = 100;