The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

766 lines
25KB

  1. /** Reads and returns the value of a single byte from the heap.
  2. @param byteIndex the index (in bytes) of the byte to read
  3. @returns the value of the byte
  4. */
  5. int getHeapByte (int byteIndex);
  6. /** Reads 4 bytes from the heap and returns the value as an integer.
  7. @param byteIndex the index (in bytes) of the start of the 4 bytes to read
  8. @returns the value of the 4 bytes as an integer
  9. */
  10. int getHeapInt (int byteIndex);
  11. /** Reads a sequence of bits from the heap and returns the value as an integer.
  12. @param startBitIndex the index (in bits) of the start of the sequence of bits to read
  13. @param numBits how many bits to read
  14. @returns the value of the sequence of bits as an integer
  15. */
  16. int getHeapBits (int startBitIndex, int numBits);
  17. /** Writes a single byte to the heap.
  18. @param byteIndex the index (in bytes) of the byte to set
  19. @param newValue the new value to set this byte to
  20. */
  21. void setHeapByte (int byteIndex, int newValue);
  22. /** Writes 4 bytes to the heap.
  23. @param byteIndex the index (in bytes) of the start of the 4 bytes to set
  24. @param newValue the new value to set the 4 bytes to
  25. */
  26. void setHeapInt (int byteIndex, int newValue);
  27. /** Returns the smaller of two integer values.
  28. @param a The first parameter
  29. @param b The second parameter
  30. @retval The minimum of a and b
  31. */
  32. int min (int a, int b);
  33. /** Returns the smaller of two floating point values.
  34. @param a The first parameter
  35. @param b The second parameter
  36. @retval The minimum of a and b
  37. */
  38. float min (float a, float b);
  39. /** Returns the larger of two integer values.
  40. @param a The first parameter
  41. @param b The second parameter
  42. @retval The maximum of a and b
  43. */
  44. int max (int a, int b);
  45. /** Returns the larger of two floating point values.
  46. @param a The first parameter
  47. @param b The second parameter
  48. @retval The maximum of a and b
  49. */
  50. float max (float a, float b);
  51. /** Constrains an integer value to keep it within a given range.
  52. @param lowerLimit the minimum value to return
  53. @param upperLimit the maximum value to return
  54. @param valueToConstrain the value to try to return
  55. @returns the closest value to valueToConstrain which lies between lowerLimit
  56. and upperLimit (inclusive)
  57. */
  58. int clamp (int lowerLimit, int upperLimit, int valueToConstrain);
  59. /** Constrains a floating point value to keep it within a given range.
  60. @param lowerLimit the minimum value to return
  61. @param upperLimit the maximum value to return
  62. @param valueToConstrain the value to try to return
  63. @returns the closest value to valueToConstrain which lies between lowerLimit
  64. and upperLimit (inclusive)
  65. */
  66. float clamp (float lowerLimit, float upperLimit, float valueToConstrain);
  67. /** Returns the absolute value of an integer value.
  68. @param arg The argument to compute the absolute value of
  69. @retval either -arg if arg is negative or arg if arg is positive
  70. */
  71. int abs (int arg);
  72. /** Returns the absolute value of a floating point value.
  73. @param arg The argument to compute the absolute value of
  74. @retval either -arg if arg is negative or arg if arg is positive
  75. */
  76. float abs (float arg);
  77. /** Remaps a value from a source range to a target range.
  78. @param value the value within the source range to map
  79. @param sourceMin the minimum value of the source range
  80. @param sourceMax the maximum value of the source range
  81. @param destMin the minumum value of the destination range
  82. @param destMax the maximum value of the destination range
  83. @returns the original value mapped to the destination range
  84. */
  85. float map (float value, float sourceMin, float sourceMax, float destMin, float destMax);
  86. /** Remaps a value from a source range to the range 0 - 1.0.
  87. @param value the value within the source range to map
  88. @param sourceMin the minimum value of the source range
  89. @param sourceMax the maximum value of the source range
  90. @returns the original value mapped to the range 0 - 1.0
  91. */
  92. float map (float value, float sourceMin, float sourceMax);
  93. /** Performs a modulo operation (can cope with the dividend being negative).
  94. The divisor must be greater than zero.
  95. @returns the result of the modulo operation
  96. */
  97. int mod (int dividend, int divisor);
  98. /** Returns a random floating-point number.
  99. @returns a random value in the range 0 (inclusive) to 1.0 (exclusive)
  100. */
  101. float getRandomFloat();
  102. /** Returns a random integer, limited to a given range.
  103. @returns a random integer between 0 (inclusive) and maxValue (exclusive).
  104. */
  105. int getRandomInt (int maxValue);
  106. /** Returns the number of milliseconds since a fixed event (usually system startup).
  107. @returns a monotonically increasing value which is unaffected by changes to the
  108. system clock. It should be accurate to within a few millisecseconds.
  109. */
  110. int getMillisecondCounter();
  111. /** Returns the length of time spent in the current function call in milliseconds.
  112. @returns the length of time spent in the current function call in milliseconds.
  113. */
  114. int getTimeInCurrentFunctionCall();
  115. /** Logs an integer value to the console.
  116. @param data The 32 bit signed integer to log to the topology as an integer
  117. */
  118. void log (int data);
  119. /** Logs a hexadecimal value to the console.
  120. @param data The 32 bit signed integer to log to the topology as a hexidecimal int
  121. */
  122. void logHex (int data);
  123. /** Sends a 1-byte short midi message. */
  124. void sendMIDI (int byte0);
  125. /** Sends a 2-byte short midi message. */
  126. void sendMIDI (int byte0, int byte1);
  127. /** Sends a 3-byte short midi message. */
  128. void sendMIDI (int byte0, int byte1, int byte2);
  129. /** Sends a key-down message.
  130. @param channel the midi channel, in the range 0 to 15
  131. @param noteNumber the key number, in the range 0 to 127
  132. @param velocity the velocity, in the range 0 to 127
  133. */
  134. void sendNoteOn (int channel, int noteNumber, int velocity);
  135. /** Sends a key-up message.
  136. @param channel the midi channel, in the range 0 to 15
  137. @param noteNumber the key number, in the range 0 to 127
  138. @param velocity the velocity, in the range 0 to 127
  139. */
  140. void sendNoteOff (int channel, int noteNumber, int velocity);
  141. /** Sends an aftertouch message.
  142. @param channel the midi channel, in the range 0 to 15
  143. @param noteNumber the key number, in the range 0 to 127
  144. @param level the amount of aftertouch, in the range 0 to 127
  145. */
  146. void sendAftertouch (int channel, int noteNumber, int level);
  147. /** Sends a controller message.
  148. @param channel the midi channel, in the range 0 to 15
  149. @param controller the type of controller
  150. @param value the controller value
  151. */
  152. void sendCC (int channel, int controller, int value);
  153. /** Sends a pitch bend message.
  154. @param channel the midi channel, in the range 0 to 15
  155. @param position the wheel position, in the range 0 to 16383
  156. */
  157. void sendPitchBend (int channel, int position);
  158. /** Sends a channel-pressure change event.
  159. @param channel the midi channel, in the range 0 to 15
  160. @param pressure the pressure, in the range 0 to 127
  161. */
  162. void sendChannelPressure (int channel, int pressure);
  163. /** Sets the MIDI channel range.
  164. @param useMPE
  165. @param lowChannel
  166. @param highChannel
  167. */
  168. void setChannelRange (bool useMPE, int lowChannel, int highChannel);
  169. /** Assigns a MIDI channel to a note number.
  170. @param noteNumber the note number to assign the channel to
  171. @returns the MIDI channel that has been assigned
  172. */
  173. int assignChannel (int noteNumber);
  174. /** Deassigns a channel from a note number.
  175. @param noteNumber the note number to deassign
  176. @param channel the MIDI channel
  177. */
  178. void deassignChannel (int noteNumber, int channel);
  179. /** Returns the channel that is being used for control messages.
  180. @returns the channel that is being used for control messages. (If MPE is enabled then this will be the first channel.)
  181. */
  182. int getControlChannel();
  183. /** Sets whether duplicate notes should be filtered out when MPE is enabled. */
  184. void useMPEDuplicateFilter (bool active);
  185. /** Use this method to draw the display.
  186. The block will call this approximately 25 times per second.
  187. */
  188. void repaint();
  189. /** Called when a button is pushed.
  190. @param index the index of the button that was pushed
  191. */
  192. void handleButtonDown (int index);
  193. /** Called when a button is released.
  194. @param index the index of the button that was released
  195. */
  196. void handleButtonUp (int index);
  197. /** Called when a control block button is pressed.
  198. @param buttonIndex the index of the button
  199. @note Requires >= 0.2.5 firmware
  200. @note Only valid with a control block
  201. */
  202. void onControlPress (int buttonIndex);
  203. /** Called when a control block button is released.
  204. @param buttonIndex the index of the button
  205. @note Requires >= 0.2.5 firmware
  206. @note Only valid with a control block
  207. */
  208. void onControlRelease (int buttonIndex);
  209. /** Called when a touch event starts.
  210. @param index the touch index, which will stay constant for each finger as it is tracked
  211. @param x the X position of this touch on the device, in block units starting from 0 (left)
  212. @param y the Y position of this touch on the device, in block units starting from 0 (top)
  213. @param z the current pressure of this touch, in the range 0.0 (no pressure) to 1.0 (very hard)
  214. @param vz the rate at which pressure is currently changing, measured in units/second
  215. */
  216. void touchStart (int index, float x, float y, float z, float vz);
  217. /** Called when a touch event moves.
  218. @param index the touch index, which will stay constant for each finger as it is tracked
  219. @param x the X position of this touch on the device, in block units starting from 0 (left)
  220. @param y the Y position of this touch on the device, in block units starting from 0 (top)
  221. @param z the current pressure of this touch, in the range 0.0 (no pressure) to 1.0 (very hard)
  222. @param vz the rate at which pressure is currently changing, measured in units/second
  223. */
  224. void touchMove (int index, float x, float y, float z, float vz);
  225. /** Called when a touch event ends.
  226. @param index the touch index, which will stay constant for each finger as it is tracked
  227. @param x the X position of this touch on the device, in block units starting from 0 (left)
  228. @param y the Y position of this touch on the device, in block units starting from 0 (top)
  229. @param z the current pressure of this touch, in the range 0.0 (no pressure) to 1.0 (very hard)
  230. @param vz the rate at which pressure is currently changing, measured in units/second
  231. */
  232. void touchEnd (int index, float x, float y, float z, float vz);
  233. /** Called when a program is loaded onto the block and is about to start. Do any setup here. */
  234. void initialise();
  235. /** Called when a block receives a MIDI message. */
  236. void handleMIDI (int byte0, int byte1, int byte2);
  237. /** Called when a block receives a message.
  238. @see sendMessageToBlock
  239. */
  240. void handleMessage (int param1, int param2, int param3);
  241. /** Combines a set of 8-bit ARGB values into a 32-bit colour and returns the result.
  242. @return a 32-bit colour
  243. @param alpha The alpha in range 0 - 255 inclusive
  244. @param red The red in range 0 - 255 inclusive
  245. @param green The green in range 0 - 255 inclusive
  246. @param blue The blue in range 0 - 255 inclusive
  247. */
  248. int makeARGB (int alpha, int red, int green, int blue);
  249. /** Blends the overlaid ARGB colour onto the base one and returns the new colour.
  250. @param baseColour the colour to blend on to
  251. @param overlaidColour The colour to blend in to the baseColour
  252. @returns The blended colour
  253. */
  254. int blendARGB (int baseColour, int overlaidColour);
  255. /** Displays an animation indicating the current battery level of this block.
  256. A control block will light up its top LEDs indicating battery level and a lightpad
  257. block will draw the battery level on the display.
  258. @note Requires >= 0.2.5 firmware
  259. */
  260. void displayBatteryLevel();
  261. /** Clears the display and sets all the LEDs to black. */
  262. void clearDisplay();
  263. /** Clears the display and sets all the LEDs to a specified colour.
  264. @param rgb the colour to use (0xff...)
  265. */
  266. void clearDisplay (int rgb);
  267. /** Sets a pixel to a specified colour with full alpha.
  268. @param rgb the colour to use (0xff...)
  269. @param x the x coordinate of the pixel to fill
  270. @param y the y coordinate of the pixel to fill
  271. */
  272. void fillPixel (int rgb, int x, int y);
  273. /** Blends the current pixel colour with a specified colour.
  274. @param argb the colour to use
  275. @param x the x coordinate of the pixel to blend
  276. @param y the y coordinate of the pixel to blend
  277. */
  278. void blendPixel (int argb, int x, int y);
  279. /** Fills a rectangle on the display with a specified colour.
  280. @param rgb the colour to use (0xff...)
  281. @param x the x coordinate of the rectangle to draw
  282. @param y the y coordinate of the rectangle to draw
  283. @param width the width of the rectangle to draw
  284. @param height the height of the rectangle to draw
  285. */
  286. void fillRect (int rgb, int x, int y, int width, int height);
  287. /** Blends a rectangle on the display with a specified colour.
  288. @param argb the colour to use
  289. @param x the x coordinate of the rectangle to blend
  290. @param y the y coordinate of the rectangle to blend
  291. @param width the width of the rectangle to blend
  292. @param height the height of the rectangle to blend
  293. */
  294. void blendRect (int argb, int x, int y, int width, int height);
  295. /** Fills a rectangle on the display with four corner colours blended together.
  296. @param colourNW the colour to use in the north west corner of the rectangle
  297. @param colourNE the colour to use in the north east corner of the rectangle
  298. @param colourSE the colour to use in the south east corner of the rectangle
  299. @param colourSW the colour to use in the south west corner of the rectangle
  300. @param x the x coordinate of the rectangle
  301. @param y the y coordinate of the rectangle
  302. @param width the width of the rectangle
  303. @param height the height of the rectangle
  304. */
  305. void blendGradientRect (int colourNW, int colourNE, int colourSE, int colourSW, int x, int y, int width, int height);
  306. /** Blends a circle on the display with a specified colour.
  307. @param argb the colour to use
  308. @param xCentre the x position of the circle's centre in block units
  309. @param yCentre the y position of the circle's centre in block units
  310. @param radius the radius of the circle in block units
  311. @param fill if true then the circle will be filled, if false the circle will be an outline
  312. @note Requires >= 0.2.5 firmware
  313. */
  314. void blendCircle (int argb, float xCentre, float yCentre, float radius, bool fill);
  315. /** Draws a number on the display.
  316. @param value the number to draw between 0 and 99
  317. @param colour the colour to use
  318. @param x the x coordinate to use
  319. @param y the y coordinate to use
  320. */
  321. void drawNumber (int value, int colour, int x, int y);
  322. /** Returns the current firmware version of this block.
  323. @returns The firmware version of the form 0xMJMIRV (where MJ = Major, MI = Minor, RV = Revision)
  324. @note Requires >= 0.2.5 firmware
  325. */
  326. int getFirmwareVersion();
  327. /** Returns the battery level of this block, between 0 and 1.0.
  328. @returns the battery level of this block, between 0 and 1.0.
  329. @note Requires >= 0.2.5 firmware
  330. */
  331. float getBatteryLevel();
  332. /** Returns true if this block's battery is charging.
  333. @returns true if this block's battery is charging
  334. @note Requires >= 0.2.5 firmware
  335. */
  336. bool isBatteryCharging();
  337. /** Sets whether status overlays should be displayed on this block.
  338. @note Requires >= 0.2.5 firmware
  339. */
  340. void setStatusOverlayActive (bool active);
  341. /** Sets whether power saving mode should be enabled on this block.
  342. @note Requires >= 0.2.5 firmware
  343. */
  344. void setPowerSavingEnabled (bool enabled);
  345. /** Returns the type of the block with a given ID.
  346. @returns an enum indicating the type of block @see Block::Type
  347. @note Requires >= 0.2.5 firmware
  348. */
  349. int getBlockTypeForID (int blockID);
  350. /** Sends a message to the block with the specified ID.
  351. This will be processed in the handleMessage() callback.
  352. @param blockID the ID of the block to send this message to
  353. @param param1 the first chunk of data to send
  354. @param param2 the second chunk of data to send
  355. @param param3 the third chunk of data to send
  356. */
  357. void sendMessageToBlock (int blockID, int param1, int param2, int param3);
  358. /** Sends a message to the host. To receive this the host will need to implement
  359. the Block::ProgramEventListener::handleProgramEvent() method.
  360. @param param1 the first chunk of data to send
  361. @param param2 the second chunk of data to send
  362. @param param3 the third chunk of data to send
  363. */
  364. void sendMessageToHost (int param1, int param2, int param3);
  365. /** Draws a pressure point with a specified colour and pressure.
  366. @param argb the colour to use
  367. @param touchX the x position of the touch in block units
  368. @param touchY the y position of the touch in block units
  369. @param touchZ the pressure value of the touch
  370. */
  371. void addPressurePoint (int argb, float touchX, float touchY, float touchZ);
  372. /** Draws the pressure map on the display. */
  373. void drawPressureMap();
  374. /** Fades the pressure map on the display. */
  375. void fadePressureMap();
  376. /** Links a another block to this control block.
  377. @param blockID the ID of the block to link
  378. @note Requires >= 0.2.5 firmware
  379. @note Only valid with a control block
  380. */
  381. void linkBlockIDtoController (int blockID);
  382. /** Repaints the control block display.
  383. @note Requires >= 0.2.5 firmware
  384. @note Only valid with a control block
  385. */
  386. void repaintControl();
  387. /** Initialises one of the control block buttons.
  388. @param buttonIndex the index of the button to initialise
  389. @param modeToUse the mode to use for this button @see ControlMode
  390. @param outputType the control type to use @see ControlType
  391. @param val the current value to set this button to
  392. @param min the minimum value for this button
  393. @param max the maximum value for this button
  394. @param index the item index
  395. @param onColourToUse the colour to use when this button is on
  396. @param offColourToUse the colour to use when this button is off
  397. @note Requires >= 0.2.5 firmware
  398. @note Only valid with a control block
  399. */
  400. void initControl (int buttonIndex, int modeToUse, int outputType, int val, int min, int max,
  401. int index, int onColourToUse, int offColourToUse);
  402. /** Control type for use with initControl
  403. @see initControl
  404. */
  405. enum ControlType
  406. {
  407. internalConfig = 0,
  408. midiCC,
  409. sysex
  410. };
  411. /** Control mode for use with initControl
  412. @see initControl
  413. */
  414. enum ControlMode
  415. {
  416. toggle = 0,
  417. togglePulse,
  418. gate,
  419. trigger,
  420. cycle,
  421. incDec,
  422. triState
  423. };
  424. /** Forces a touch event to be handled as seaboard playing.
  425. @param touchIndex the index of the touch event
  426. @note Requires >= 0.2.5 firmware
  427. @note Only valid on a Seaboard
  428. */
  429. void handleTouchAsSeaboard (int touchIndex);
  430. /** Returns the number of blocks in the current topology.
  431. @note Requires >= 0.2.5 firmware
  432. */
  433. int getNumBlocksInTopology();
  434. /** Returns the ID of a block at a given index in the topology.
  435. @param index The index of the block to find in the topology
  436. @returns int The id of the block
  437. @note Requires >= 0.2.5 firmware
  438. */
  439. int getBlockIDForIndex (int index);
  440. /** Returns true if this block is directly connected to the host,
  441. as opposed to only being connected to a different block via a connection port.
  442. @note Requires >= 0.2.5 firmware
  443. */
  444. bool isMasterBlock();
  445. /** Returns true if this block is connected to the host computer, this can be
  446. directly or through connections to other blocks.
  447. @note Requires >= 0.2.5 firmware
  448. */
  449. bool isConnectedToHost();
  450. /** Returns the ID of a block connected to a specified port on this block.
  451. @note Requires >= 0.2.5 firmware
  452. */
  453. int getBlockIDOnPort (int port);
  454. /** Returns the port number that is connected to the master block. Returns 0xFF if there is
  455. no port connected to master.
  456. @returns the port number that is connected to the master block. Returns 0xFF if there is
  457. no port connected to master.
  458. @note Requires >= 0.2.5 firmware
  459. */
  460. int getPortToMaster();
  461. /** Returns the horizontal distance between this block and the master block in block units.
  462. @note Requires >= 0.2.5 firmware
  463. */
  464. int getHorizontalDistFromMaster();
  465. /** Returns the vertical distance between this block and the master block in block units.
  466. @note Requires >= 0.2.5 firmware
  467. */
  468. int getVerticalDistFromMaster();
  469. /** Returns the angle of this block relative to the master block in degrees.
  470. @note Requires >= 0.2.5 firmware
  471. */
  472. int getAngleFromMaster();
  473. /** Sets whether this block should auto-rotate when its angle relative to the master block changes.
  474. @note Requires >= 0.2.5 firmware
  475. */
  476. void setAutoRotate (bool enabled);
  477. /** Returns the index of this block in the current cluster.
  478. @note Requires >= 0.2.5 firmware
  479. */
  480. int getClusterIndex();
  481. /** Returns how many blocks wide the current cluster is.
  482. @returns the width of the cluster (note that a single block will return 1 here)
  483. @note Requires >= 0.2.5 firmware
  484. */
  485. int getClusterWidth();
  486. /** Returns how many blocks high the current cluster is.
  487. @returns the height of the cluster (note that a single block will return 1 here)
  488. @note Requires >= 0.2.5 firmware
  489. */
  490. int getClusterHeight();
  491. /** Returns the x index of this block in the current cluster.
  492. @returns int The cluster x position. (0, 0) is considered to be the top left block
  493. @note Requires >= 0.2.5 firmware
  494. */
  495. int getClusterXpos();
  496. /** Returns the y index of this block in the current cluster.
  497. @returns int The cluster x position. (0, 0) is considered to be the top left block
  498. @note Requires >= 0.2.5 firmware
  499. */
  500. int getClusterYpos();
  501. /** Returns the number of blocks in the current cluster.
  502. @returns the number of blocks in the current cluster.
  503. @note Requires >= 0.2.5 firmware
  504. */
  505. int getNumBlocksInCurrentCluster();
  506. /** Returns the block ID for a block in the current cluster.
  507. @param index the cluster index of the block to get the ID of
  508. @note Requires >= 0.2.5 firmware
  509. */
  510. int getBlockIdForBlockInCluster (int index);
  511. /** Returns true if the master block is in the current cluster.
  512. @note Requires >= 0.2.5 firmware
  513. */
  514. bool isMasterInCurrentCluster();
  515. /** Returns current value of one of the local config items.
  516. @param item the config item to get (see ConfigItemId enum in juce_BlocksProtocolDefinitions.h)
  517. @note Requires >= 0.2.5 firmware
  518. */
  519. int getLocalConfig (int item);
  520. /** Sets the current value of one of the local config items.
  521. @param item the config item to set the value of (see ConfigItemId enum in juce_BlocksProtocolDefinitions.h)
  522. @param value the value to set the config to
  523. @note Requires >= 0.2.5 firmware
  524. */
  525. void setLocalConfig (int item, int value);
  526. /** Sets the local config of a block to the config item of a remote block.
  527. @param longAddress the address of the remote block
  528. @param item the config item (see ConfigItemId enum in juce_BlocksProtocolDefinitions.h)
  529. @note Requires >= 0.2.5 firmware
  530. */
  531. void requestRemoteConfig (int longAddress, int item);
  532. /** Sets the config of a remote block.
  533. @param longAddress the address of the remote block
  534. @param item the config item (see ConfigItemId enum in juce_BlocksProtocolDefinitions.h)
  535. @param value the value to set the config to
  536. @note Requires >= 0.2.5 firmware
  537. */
  538. void setRemoteConfig (int longAddress, int item, int value);
  539. /** Sets the range of one of the local config items.
  540. @param item the config item to set the range of (see ConfigItemId enum in juce_BlocksProtocolDefinitions.h)
  541. @param min the minimum value this config item should use
  542. @param max the maximum value this config item should use
  543. @note Requires >= 0.2.5 firmware
  544. */
  545. void setLocalConfigItemRange (int item, int min, int max);
  546. /** Sets whether a local config item should be active.
  547. @param item the config item to set active (see ConfigItemId enum in juce_BlocksProtocolDefinitions.h)
  548. @param isActive sets whether the config should be active or not
  549. @param saveToFlash if true then this config item will be saved to the flash memory of the block
  550. @note Requires >= 0.2.5 firmware
  551. */
  552. void setLocalConfigActiveState (int item, bool isActive, bool saveToFlash);