1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324
|
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2017 - ROLI Ltd.
JUCE is an open source library subject to commercial or open-source
licensing.
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
namespace BlocksProtocol
{
#ifndef DOXYGEN
// This file isn't part of the public API, it's where we encode the knowledge base
// of all the different types of block we know about..
struct BlockDataSheet
{
BlockDataSheet (const BlocksProtocol::BlockSerialNumber& serial) : serialNumber (serial)
{
if (serialNumber.isPadBlock()) initialiseForPadBlock2x2();
if (serialNumber.isLiveBlock()) initialiseForControlBlockLive();
if (serialNumber.isLoopBlock()) initialiseForControlBlockLoop();
if (serialNumber.isDevCtrlBlock()) initialiseForControlBlockDeveloper();
if (serialNumber.isTouchBlock()) initialiseForControlBlockTouch();
if (serialNumber.isSeaboardBlock()) initialiseForSeaboardBlock();
}
Block::ConnectionPort convertPortIndexToConnectorPort (BlocksProtocol::ConnectorPort port) const noexcept
{
return ports[(int) port.get()];
}
const BlocksProtocol::BlockSerialNumber serialNumber;
Block::Type apiType = Block::Type::unknown;
const char* description = nullptr;
int widthUnits = 0, heightUnits = 0;
int lightGridWidth = 0, lightGridHeight = 0, lightGridStartIndex = 0;
bool hasTouchSurface = false;
int numKeywaves = 0;
int numLEDRowLEDs = 0;
uint32 programAndHeapSize = 0;
struct ButtonInfo
{
ControlButton::ButtonFunction type;
float x, y;
};
struct StatusLEDInfo
{
juce::String name;
float x, y;
};
juce::Array<ButtonInfo> buttons;
juce::Array<StatusLEDInfo> statusLEDs;
juce::Array<Block::ConnectionPort> ports;
juce::Array<const char*> dials;
private:
//==============================================================================
void initialiseForPadBlock2x2()
{
apiType = Block::Type::lightPadBlock;
description = "Pad BLOCK (2x2)";
widthUnits = 2;
heightUnits = 2;
lightGridWidth = 15;
lightGridHeight = 15;
addPorts (2, 2, 2, 2);
hasTouchSurface = true;
programAndHeapSize = BlocksProtocol::padBlockProgramAndHeapSize;
addModeButton();
}
void initialiseForControlBlockLoop()
{
initialiseControlBlock ("Loop BLOCK", Block::Type::loopBlock,
ControlButton::ButtonFunction::mode,
ControlButton::ButtonFunction::volume,
ControlButton::ButtonFunction::click,
ControlButton::ButtonFunction::snap,
ControlButton::ButtonFunction::back,
ControlButton::ButtonFunction::playOrPause,
ControlButton::ButtonFunction::record,
ControlButton::ButtonFunction::learn,
ControlButton::ButtonFunction::down,
ControlButton::ButtonFunction::up);
}
void initialiseForControlBlockLive()
{
initialiseControlBlock ("Live BLOCK", Block::Type::liveBlock,
ControlButton::ButtonFunction::mode,
ControlButton::ButtonFunction::volume,
ControlButton::ButtonFunction::scale,
ControlButton::ButtonFunction::chord,
ControlButton::ButtonFunction::arp,
ControlButton::ButtonFunction::sustain,
ControlButton::ButtonFunction::octave,
ControlButton::ButtonFunction::love,
ControlButton::ButtonFunction::down,
ControlButton::ButtonFunction::up);
}
void initialiseForControlBlockDeveloper()
{
initialiseControlBlock ("Dev Ctrl BLOCK", Block::Type::developerControlBlock,
ControlButton::ButtonFunction::button0,
ControlButton::ButtonFunction::button1,
ControlButton::ButtonFunction::button2,
ControlButton::ButtonFunction::button3,
ControlButton::ButtonFunction::button4,
ControlButton::ButtonFunction::button5,
ControlButton::ButtonFunction::button6,
ControlButton::ButtonFunction::button7,
ControlButton::ButtonFunction::down,
ControlButton::ButtonFunction::up);
}
void initialiseForControlBlockTouch()
{
initialiseControlBlock ("Touch BLOCK", Block::Type::touchBlock,
ControlButton::ButtonFunction::velocitySensitivity,
ControlButton::ButtonFunction::glideSensitivity,
ControlButton::ButtonFunction::slideSensitivity,
ControlButton::ButtonFunction::pressSensitivity,
ControlButton::ButtonFunction::liftSensitivity,
ControlButton::ButtonFunction::fixedVelocity,
ControlButton::ButtonFunction::glideLock,
ControlButton::ButtonFunction::pianoMode,
ControlButton::ButtonFunction::down,
ControlButton::ButtonFunction::up);
}
void initialiseControlBlock (const char* name, Block::Type type,
ControlButton::ButtonFunction b1, ControlButton::ButtonFunction b2,
ControlButton::ButtonFunction b3, ControlButton::ButtonFunction b4,
ControlButton::ButtonFunction b5, ControlButton::ButtonFunction b6,
ControlButton::ButtonFunction b7, ControlButton::ButtonFunction b8,
ControlButton::ButtonFunction b9, ControlButton::ButtonFunction b10)
{
apiType = type;
description = name;
widthUnits = 2;
heightUnits = 1;
programAndHeapSize = BlocksProtocol::controlBlockProgramAndHeapSize;
addPorts (2, 1, 2, 1);
float x1 = 0.2f;
float x2 = 0.6f;
float x3 = 1.0f;
float x4 = 1.4f;
float x5 = 1.8f;
float y1 = 0.405f;
float y2 = 0.798f;
addButtons (b1, x1, y1,
b2, x2, y1,
b3, x3, y1,
b4, x4, y1,
b5, x5, y1,
b6, x1, y2,
b7, x2, y2,
b8, x3, y2,
b9, x4, y2,
b10, x5, y2);
numLEDRowLEDs = 15;
}
void initialiseForSeaboardBlock()
{
apiType = Block::Type::seaboardBlock;
description = "Seaboard BLOCK (6x3)";
widthUnits = 6;
heightUnits = 3;
lightGridWidth = 0;
lightGridHeight = 0;
numKeywaves = 24;
addPortsSW (Block::ConnectionPort::DeviceEdge::west, 1);
addPortsNE (Block::ConnectionPort::DeviceEdge::north, 2);
addPortsNE (Block::ConnectionPort::DeviceEdge::east, 1);
hasTouchSurface = true;
programAndHeapSize = BlocksProtocol::padBlockProgramAndHeapSize;
addModeButton();
}
//==============================================================================
void addStatusLED (const char* name, float x, float y)
{
statusLEDs.add ({ name, x, y });
}
template <typename... Args>
void addButtons (ControlButton::ButtonFunction fn, float x, float y, Args... others)
{
addButtons (fn, x, y);
addButtons (others...);
}
void addButtons (ControlButton::ButtonFunction fn, float x, float y)
{
buttons.add ({ fn, x, y });
}
void addModeButton()
{
addButtons (ControlButton::ButtonFunction::mode, -1.0f, -1.0f);
}
void addPorts (int numNorth, int numEast, int numSouth, int numWest)
{
addPortsNE (Block::ConnectionPort::DeviceEdge::north, numNorth);
addPortsNE (Block::ConnectionPort::DeviceEdge::east, numEast);
addPortsSW (Block::ConnectionPort::DeviceEdge::south, numSouth);
addPortsSW (Block::ConnectionPort::DeviceEdge::west, numWest);
}
void addPortsNE (Block::ConnectionPort::DeviceEdge edge, int num)
{
for (int i = 0; i < num; ++i)
ports.add ({ edge, i});
}
void addPortsSW (Block::ConnectionPort::DeviceEdge edge, int num)
{
for (int i = 0; i < num; ++i)
ports.add ({ edge, num - i - 1});
}
};
//==============================================================================
static const char* getButtonNameForFunction (ControlButton::ButtonFunction fn) noexcept
{
using BF = ControlButton::ButtonFunction;
switch (fn)
{
case BF::mode: return "Mode";
case BF::volume: return "Volume";
case BF::up: return "Up";
case BF::down: return "Down";
case BF::scale: return "Scale";
case BF::chord: return "Chord";
case BF::arp: return "Arp";
case BF::sustain: return "Sustain";
case BF::octave: return "Octave";
case BF::love: return "Love";
case BF::click: return "Click";
case BF::snap: return "Snap";
case BF::back: return "Back";
case BF::playOrPause: return "Play/Pause";
case BF::record: return "Record";
case BF::learn: return "Learn";
case BF::button0: return "0";
case BF::button1: return "1";
case BF::button2: return "2";
case BF::button3: return "3";
case BF::button4: return "4";
case BF::button5: return "5";
case BF::button6: return "6";
case BF::button7: return "7";
case BF::velocitySensitivity: return "Velocity Sensitivity";
case BF::glideSensitivity: return "Glide Sensitivity";
case BF::slideSensitivity: return "Slide Sensitivity";
case BF::pressSensitivity: return "Press Sensitivity";
case BF::liftSensitivity: return "Lift Sensitivity";
case BF::fixedVelocity: return "Fixed Velocity";
case BF::glideLock: return "Glide Lock";
case BF::pianoMode: return "Piano Mode";
}
jassertfalse;
return nullptr;
}
#endif
} // namespace BlocksProtocol
} // namespace juce
|