I have a number of values in my sketch that I would like to scale according to screen resolution.
For example: at a resolution of 1920x1080, the variable
strength is equal to
20. When the resolution is at 960x540, I want that value to be equal to
5 and so on.
Unfortunately maths has never been my strong point and I have no idea how to achieve this. Can someone throw some suggestions at me?
I've implemented a class called drums, which receives an array of values (via OSC) from Max. The values are extracted and used to resize one of 8 corresponding ellipses a few times a second.
When drawing the shapes via the standard ellispe(x,y,x1,y1); method, frame rate performance is pretty stable and more or less acceptable (occasional spikes down, but they're not significant). When implementing the PShape() method and drawing the shapes with shape(); performance takes a massive hit. I've benchmarked the phenomenon using a 5 minute benchmark in FRAPS. The graph is attached below.
Is this a known issue with PShape() or am I implementing it wrong? The code in its entirety is below. The PShape code is commented out and the standard code is working.
I've been trying to get proMidi working with a MIDI controller, and after a lot of tedious testing I finally have it working with my padKontrol. However, I'm encountering an issue that I can't seem to find anywhere else; whenever I press something on the padKontrol, my sketch detects 3 noteOn events, despite the fact that MIDI-OX only detects one. Has anyone else encountered this issue? Are there any other MIDI libraries that I could use instead of proMIDI?
My code is as follows:
import promidi.*;
MidiIO midiIO;
void setup(){
size(128*5,128*5);
smooth();
background(0);
midiIO = MidiIO.getInstance(this);
midiIO.printDevices();
midiIO.plug(this,"noteOn",9,9);
}
void draw(){
fill(255,20);
rect(0,0,128*5,128*5);
}
void noteOn(Note note){
int vel = note.getVelocity();
int pit = note.getPitch();
println(vel+" "+ pit);
}
And here's an example of the output from Processing and from MIDI-OX (Processing top, MIDI-OX below):
127 61
64 61
64 61
001233D1 10 -- 99 3D 7F 10 C# 4 Note On
00123415 10 -- 89 3D 40 10 C# 4 Note Off
In this case, the velocity is set to fixed, which is currently set to 127. The second two noteOn events (according to the Sketch) register at 64, which is clearly not whats being sent from the padKontrol since noteOn events [i]always[/i] output at a velocity of 127, and since MIDI-OX doesn't register either of these events.
EDIT: I'm monitoring all available MIDI-channels with MIDI-OX, by the way. Also, not sure why the question posted three times, apologies.