Skip to content

Commit

Permalink
Add Samson Graphite MIDI controller
Browse files Browse the repository at this point in the history
  • Loading branch information
zbanks committed Dec 16, 2017
1 parent 7a33813 commit 53f8d94
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
2 changes: 1 addition & 1 deletion resources/library/effects/solitaire.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ void main(void) {

// Closed-form bouncing behavior
// I think this is periodic over [0.0, 16.] to prevent discontinuities
vec2 xy = vec2(sawtooth(iStep * 0.325, 0.5), 1.0 - abs(sin(iStep * M_PI * 0.5625)));
vec2 xy = vec2(sawtooth(iStep * 0.3125, 0.5), 1.0 - abs(sin(iStep * M_PI * 0.5625)));

xy = (xy - 0.5) * (1.0 - scale);
vec2 uvSample = (uv - 0.5 + xy) / scale + 0.5;
Expand Down
2 changes: 1 addition & 1 deletion resources/library/effects/tunnel.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ void main()
{
vec2 q = (uv - vec2(0.5, 0.5)) * aspectCorrection;

float t2 = iTime * 0.2;
float t2 = iTime * (M_PI / 16.);
vec2 offset = vec2(sin(t2), cos(t2)) * 0.2;
q -= offset;

Expand Down
54 changes: 54 additions & 0 deletions resources/qml/MidiMappings/SamsonGraphiteMF8.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import QtQuick 2.3
import radiance 1.0

QtObject {
property variant target;

property variant lpfTimer: Timer {
interval: 50; running: true; repeat: true
onTriggered: mc.scrollAccumulator *= 0.9;
}

property variant mc: MidiController {
id: controller
deviceName: "SAMSON Graphite MF8"

property real scrollAccumulator;

onConnectedChanged: {
console.log(deviceName + " " + (connected ? "connected" : "disconnected"));
}

onNoteOn: {
console.log("on ", channel, note, velocity);
}

onNoteOff: {
console.log("off", channel, note, velocity);
}

onControlChange: {
console.log("cc ", channel, control, value, 123);
if (control == 60) { // "A" jogwheel
var N = 4;
var v = value;
if (v > 64) {
v = 64 - v;
}
v /= Math.sqrt(Math.abs(v));

scrollAccumulator += v;
if (scrollAccumulator > N / 2) {
target.Controls.changeControlRel(0, Controls.Scroll, 1);
scrollAccumulator -= N;
} else if (scrollAccumulator <= -N / 2) {
target.Controls.changeControlRel(0, Controls.Scroll, -1);
scrollAccumulator += N;
}
} else if (control == 49) { // "B" jogwheel
var v = value << 25 >> 25;
target.Controls.changeControlRel(0, Controls.PrimaryParameter, v / 127);
}
}
}
}

0 comments on commit 53f8d94

Please sign in to comment.