/* */ int view; const int faderView = 0; const int xyPadView = 1; const int wheelView = 2; int slider0; int slider1; int slider2; int wheel0; int wheel1; int time; void initialise() { view = faderView; slider0 = slider1 = slider2 = 64; wheel0 = 8192; for (int i = 0; i < 32; ++i) setLocalConfigActiveState (i, false, false); } int mapTouchToRange (float v, float max) { return int (map (v, 7.0 / 100.0, 193.0 / 100.0, 0.0, max)); } void handleTouchFader (int index, float x, float y, float z, float vz) { int xPixel = mapTouchToRange (x, 14.0); int yValue = 127 - mapTouchToRange (y, 127.0); if (xPixel < 5) { slider0 = yValue; sendCC ((channel - 1), s0CC, slider0); } if (xPixel >= 5 && xPixel < 10) { slider1 = yValue; sendCC ((channel - 1), s1CC, slider1); } if (xPixel >= 10) { slider2 = yValue; sendCC ((channel - 1), s2CC, slider2); } } void handleTouchWheels (int index, float x, float y, float z, float vz) { int xPixel = mapTouchToRange (x, 14.0); int yValue = 127 - mapTouchToRange (y, 127.0); int yValue2 = 16383 - mapTouchToRange (y, 16383.0); if (xPixel < 6) { wheel0 = yValue2; if (wheel0 >= 15471) { wheel0 = 16383; } if (wheel0 <= 100) { wheel0 = 0; } sendPitchBend ((channel - 1), wheel0); } if (xPixel >= 9 && xPixel < 13) { wheel1 = yValue; sendCC ((channel - 1), w1CC, wheel1); } } void handleTouchWheelEnd (int index, float x, float y, float z, float vz) { wheel0 = 8192 + ((wheel0 - 8192) / 2); sendPitchBend ((channel - 1), wheel0); for (time = 0; time < 20; time = getTimeInCurrentFunctionCall()) { } wheel0 = 8192; sendPitchBend ((channel - 1), wheel0); } int mapTouchToRange (float v, float inMin, float inMax, float outMax) { return int (map (v, inMin / 100.0, inMax / 100.0, 0.0, outMax)); } void outputCC (float v, int cc, float inMin, float inMax, bool invert) { int value = mapTouchToRange (v, inMin, inMax, 127.0); if (invert) value = 127 - value; sendCC ((channel - 1), cc, value); } void handleTouchXYPad (int index, float x, float y, float z, float vz) { addPressurePoint (xyzColour, x, y, z * 20.0); if (send == 0) { outputCC (x, xCC, 7.0, 193.0, false); outputCC (y, yCC, 7.0, 193.0, true); outputCC (z, zCC, 0.0, 100.0, false); } if (send == 1) { outputCC (x, xCC, 7.0, 193.0, false); outputCC (y, yCC, 7.0, 193.0, true); } if (send == 2) { outputCC (x, xCC, 7.0, 193.0, false); } if (send == 3) { outputCC (y, yCC, 7.0, 193.0, true); } if (send == 4) { outputCC (z, zCC, 0.0, 100.0, false); } } void handleTouch (int index, float x, float y, float z, float vz) { if (view == faderView) handleTouchFader (index, x, y, z, vz); if (view == xyPadView) handleTouchXYPad (index, x, y, z, vz); if (view == wheelView) handleTouchWheels (index, x, y, z, vz); } void touchStart (int index, float x, float y, float z, float vz) { handleTouch (index, x, y, z, vz); } void touchMove (int index, float x, float y, float z, float vz) { handleTouch (index, x, y, z, vz); } void touchEnd (int index, float x, float y, float z, float vz) { if (view == wheelView && x < 7) handleTouchWheelEnd (index, x, y, z, vz); else handleTouch (index, x, y, z, vz); } void handleButtonDown (int index) { if (view == faderView) view = wheelView; else if (view == wheelView) view = xyPadView; else view = faderView; } void repaint() { clearDisplay(); if (view == faderView) paintFaderView(); if (view == xyPadView) paintXYPadView(); if (view == wheelView) paintWheelsView(); } void paintFaderView() { int slider0DrawableHeight = int (map (float (slider0), 0.0, 127.0, 1.0, 15.0)); int slider1DrawableHeight = int (map (float (slider1), 0.0, 127.0, 1.0, 15.0)); int slider2DrawableHeight = int (map (float (slider2), 0.0, 127.0, 1.0, 15.0)); blendGradientRect ( s0Colour, s0Colour, s0bColour, s0bColour, 1, 0, 3, 15); fillRect (0x080808, 1, 0, 3, 15 - slider0DrawableHeight); blendGradientRect ( s1Colour, s1Colour, s1bColour, s1bColour, 6, 0, 3, 15); fillRect (0x080808, 6, 0, 3, 15 - slider1DrawableHeight); blendGradientRect ( s2Colour, s2Colour, s2bColour, s2bColour, 11, 0, 3, 15); fillRect (0x080808, 11, 0, 3, 15 - slider2DrawableHeight); } void paintWheelsView() { int wheel0DrawableHeight = int (map (float (wheel0), 0.0, 16383.0, 1.0, 15.0)); int wheel1DrawableHeight = int (map (float (wheel1), 0.0, 127.0, 1.0, 15.0)); //int pLineColor = 0x11FFFFFF; fillRect (0x080808, 2, 0, 4, 15); if (wheel0 > 8192) { fillRect (w0Colour, 2, 15 - wheel0DrawableHeight, 4, wheel0DrawableHeight); fillRect (0x080808, 2, 8, 4, 7); } else if (wheel0 < 8192) { fillRect (w0Colour, 2, 8, 4, 7); fillRect (0x080808, 2, 16 - wheel0DrawableHeight, 4, wheel0DrawableHeight); } fillRect (0xFF2E362D, 1, 7, 6, 1); blendRect (0xFF00ffff, 2, 7, 4, 1); if (wheel0 == 8192) { fillRect (w0Colour, 2, 7, 4, 1); } blendGradientRect ( w1Colour, w1Colour, w1bColour, w1bColour, 9, 0, 4, 15); fillRect (0x080808, 9, 0, 4, 15 - wheel1DrawableHeight); //blendRect (pLineColor, 2, 4, 4, 1); //blendRect (pLineColor, 2, 11, 4, 1); } void paintXYPadView() { int blendCol1 = 0x10ffffff; int blendCol2 = 0x99000000; fillRect (xyzBackColour, 0, 0, 15, 15); blendRect (blendCol1, 0, 0, 1, 15); blendRect (blendCol1, 14, 0, 1, 15); blendRect (blendCol1, 0, 0, 15, 1); blendRect (blendCol1, 0, 14, 15, 1); blendRect (blendCol2, 1, 7, 13, 1); blendRect (blendCol2, 7, 1, 1, 13); drawPressureMap(); fadePressureMap(); } /* */