JUCE
Classes | Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
juce::Block Class Referenceabstract

Represents an individual BLOCKS device. More...

Inheritance diagram for juce::Block:

Classes

struct  ConfigMetaData
 Metadata for a given config item. More...
 
struct  ConnectionPort
 These are the edge-connectors that a device may have. More...
 
struct  DataInputPortListener
 Interface for objects listening to input data port. More...
 
struct  Program
 A program that can be loaded onto a block. More...
 
struct  ProgramEventListener
 Interface for objects listening to custom program events. More...
 
struct  ProgramEventMessage
 A message that can be sent to the currently loaded program. More...
 

Public Types

enum  Type {
  unknown = 0, lightPadBlock, liveBlock, loopBlock,
  developerControlBlock, touchBlock, seaboardBlock
}
 The different block types. More...
 
using Ptr = juce::ReferenceCountedObjectPtr< Block >
 The Block class is reference-counted, so always use a Block::Ptr when you are keeping references to them. More...
 
using Array = juce::ReferenceCountedArray< Block >
 The Block class is reference-counted, so Block::Array is useful when you are storing lists of them. More...
 
using UID = uint64
 This type is used for the unique block identifier. More...
 
using Timestamp = uint32
 This type is used for timestamping events. More...
 

Public Member Functions

virtual ~Block ()
 Destructor. More...
 
bool operator== (const Block &other) const noexcept
 Two blocks are considered equal if they have the same UID. More...
 
bool operator!= (const Block &other) const noexcept
 Two blocks are considered equal if they have the same UID. More...
 
virtual Type getType () const =0
 Returns the type of this device. More...
 
virtual juce::String getDeviceDescription () const =0
 Returns a human-readable description of this device type. More...
 
virtual float getBatteryLevel () const =0
 Returns the battery level in the range 0.0 to 1.0. More...
 
virtual bool isBatteryCharging () const =0
 Returns true if the battery is charging. More...
 
virtual bool isConnected () const =0
 Returns true if this block is connected and active. More...
 
virtual bool isMasterBlock () const =0
 Returns true if this block is directly connected to the application, as opposed to only being connected to a different block via a connection port. More...
 
virtual int getWidth () const =0
 Returns the width of the device in logical device units. More...
 
virtual int getHeight () const =0
 Returns the height of the device in logical device units. More...
 
virtual bool isHardwareBlock () const =0
 Returns true if the device is a physical hardware block (i.e. More...
 
virtual float getMillimetersPerUnit () const =0
 Returns the length of one logical device unit as physical millimeters. More...
 
virtual LEDGridgetLEDGrid () const =0
 If this block has a grid of LEDs, this will return an object to control it. More...
 
virtual LEDRowgetLEDRow () const =0
 If this block has a row of LEDs, this will return an object to control it. More...
 
virtual juce::Array< StatusLight * > getStatusLights () const =0
 If this block has any status LEDs, this will return an array of objects to control them. More...
 
virtual TouchSurfacegetTouchSurface () const =0
 If this block has a pressure-sensitive surface, this will return an object to access its data. More...
 
virtual juce::Array< ControlButton * > getButtons () const =0
 If this block has any control buttons, this will return an array of objects to control them. More...
 
virtual bool supportsGraphics () const =0
 This returns true if the block supports generating graphics by drawing into a JUCE Graphics context. More...
 
virtual juce::Array< ConnectionPortgetPorts () const =0
 Returns a list of the connectors that this device has. More...
 
virtual juce::Result setProgram (Program *)=0
 Sets the Program to run on this block. More...
 
virtual ProgramgetProgram () const =0
 Returns a pointer to the currently loaded program. More...
 
virtual void sendProgramEvent (const ProgramEventMessage &)=0
 Sends a message to the currently loaded program. More...
 
virtual void addProgramEventListener (ProgramEventListener *)
 Adds a new listener for custom program events from the block. More...
 
virtual void removeProgramEventListener (ProgramEventListener *)
 Removes a listener for custom program events from the block. More...
 
virtual uint32 getMemorySize ()=0
 Returns the size of the data block that setDataByte and other functions can write to. More...
 
virtual void setDataByte (size_t offset, uint8 value)=0
 Sets a single byte on the littlefoot heap. More...
 
virtual void setDataBytes (size_t offset, const void *data, size_t num)=0
 Sets multiple bytes on the littlefoot heap. More...
 
virtual void setDataBits (uint32 startBit, uint32 numBits, uint32 value)=0
 Sets multiple bits on the littlefoot heap. More...
 
virtual uint8 getDataByte (size_t offset)=0
 Gets a byte from the littlefoot heap. More...
 
virtual void saveProgramAsDefault ()=0
 Sets the current program as the block's default state. More...
 
virtual uint32 getMaxConfigIndex ()=0
 Returns the maximum number of config items available. More...
 
virtual bool isValidUserConfigIndex (uint32 item)=0
 Determine if this is a valid config item index. More...
 
virtual int32 getLocalConfigValue (uint32 item)=0
 Get local config item value. More...
 
virtual void setLocalConfigValue (uint32 item, int32 value)=0
 Set local config item value. More...
 
virtual void setLocalConfigRange (uint32 item, int32 min, int32 max)=0
 Set local config item range. More...
 
virtual void setLocalConfigItemActive (uint32 item, bool isActive)=0
 Set if config item is active or not. More...
 
virtual bool isLocalConfigItemActive (uint32 item)=0
 Determine if config item is active or not. More...
 
virtual ConfigMetaData getLocalConfigMetaData (uint32 item)=0
 Get config item metadata. More...
 
virtual void requestFactoryConfigSync ()=0
 Request sync of factory config with block. More...
 
virtual void resetConfigListActiveStatus ()=0
 Reset all items active status. More...
 
virtual void factoryReset ()=0
 Perform factory reset on Block. More...
 
virtual void blockReset ()=0
 Reset this Block. More...
 
virtual bool setName (const juce::String &name)=0
 Set Block name. More...
 
virtual void setLogger (std::function< void(const String &)> loggingCallback)=0
 Allows the user to provide a function that will receive log messages from the block. More...
 
virtual bool sendFirmwareUpdatePacket (const uint8 *data, uint8 size, std::function< void(uint8, uint32)> packetAckCallback)=0
 Sends a firmware update packet to a block, and waits for a reply. More...
 
virtual void setConfigChangedCallback (std::function< void(Block &, const ConfigMetaData &, uint32)>)=0
 Provides a callback that will be called when a config changes. More...
 
virtual void addDataInputPortListener (DataInputPortListener *)
 Adds a new listener for the data input port. More...
 
virtual void removeDataInputPortListener (DataInputPortListener *)
 Removes a listener for the data input port. More...
 
virtual void sendMessage (const void *messageData, size_t messageSize)=0
 Sends a message to the block. More...
 
- Public Member Functions inherited from juce::ReferenceCountedObject
void incReferenceCount () noexcept
 Increments the object's reference count. More...
 
void decReferenceCount () noexcept
 Decreases the object's reference count. More...
 
bool decReferenceCountWithoutDeleting () noexcept
 Decreases the object's reference count. More...
 
int getReferenceCount () const noexcept
 Returns the object's current reference count. More...
 

Public Attributes

const juce::String serialNumber
 The Block's serial number. More...
 
juce::String versionNumber
 The Block's version number. More...
 
juce::String name
 The Block's name. More...
 
const UID uid
 This Block's UID. More...
 

Protected Member Functions

 Block (const juce::String &serialNumberToUse)
 
 Block (const juce::String &serial, const juce::String &version, const juce::String &name)
 
- Protected Member Functions inherited from juce::ReferenceCountedObject
 ReferenceCountedObject ()
 Creates the reference-counted object (with an initial ref count of zero). More...
 
 ReferenceCountedObject (const ReferenceCountedObject &) noexcept
 Copying from another object does not affect this one's reference-count. More...
 
 ReferenceCountedObject (ReferenceCountedObject &&) noexcept
 Copying from another object does not affect this one's reference-count. More...
 
ReferenceCountedObjectoperator= (const ReferenceCountedObject &) noexcept
 Copying from another object does not affect this one's reference-count. More...
 
ReferenceCountedObjectoperator= (ReferenceCountedObject &&) noexcept
 Copying from another object does not affect this one's reference-count. More...
 
virtual ~ReferenceCountedObject ()
 Destructor. More...
 
void resetReferenceCount () noexcept
 Resets the reference count to zero without deleting the object. More...
 

Protected Attributes

juce::ListenerList< DataInputPortListenerdataInputPortListeners
 
juce::ListenerList< ProgramEventListenerprogramEventListeners
 

Detailed Description

Represents an individual BLOCKS device.

Member Typedef Documentation

◆ Ptr

The Block class is reference-counted, so always use a Block::Ptr when you are keeping references to them.

◆ Array

The Block class is reference-counted, so Block::Array is useful when you are storing lists of them.

◆ UID

This type is used for the unique block identifier.

◆ Timestamp

This type is used for timestamping events.

It represents a number of milliseconds since the block device was booted.

Member Enumeration Documentation

◆ Type

The different block types.

See also
Block::getType()
Enumerator
unknown 

Unknown block type.

lightPadBlock 

Lightpad block type.

liveBlock 

Live control block type.

loopBlock 

Loop control block type.

developerControlBlock 

Developer control block type.

touchBlock 

Touch control block type.

seaboardBlock 

Seaboard block type.

Constructor & Destructor Documentation

◆ ~Block()

virtual juce::Block::~Block ( )
virtual

Destructor.

◆ Block() [1/2]

juce::Block::Block ( const juce::String serialNumberToUse)
protected

◆ Block() [2/2]

juce::Block::Block ( const juce::String serial,
const juce::String version,
const juce::String name 
)
protected

Member Function Documentation

◆ operator==()

bool juce::Block::operator== ( const Block other) const
noexcept

Two blocks are considered equal if they have the same UID.

◆ operator!=()

bool juce::Block::operator!= ( const Block other) const
noexcept

◆ getType()

virtual Type juce::Block::getType ( ) const
pure virtual

Returns the type of this device.

See also
Block::Type

Referenced by operator!=().

◆ getDeviceDescription()

virtual juce::String juce::Block::getDeviceDescription ( ) const
pure virtual

Returns a human-readable description of this device type.

Referenced by operator!=().

◆ getBatteryLevel()

virtual float juce::Block::getBatteryLevel ( ) const
pure virtual

Returns the battery level in the range 0.0 to 1.0.

Referenced by operator!=().

◆ isBatteryCharging()

virtual bool juce::Block::isBatteryCharging ( ) const
pure virtual

Returns true if the battery is charging.

Referenced by operator!=().

◆ isConnected()

virtual bool juce::Block::isConnected ( ) const
pure virtual

Returns true if this block is connected and active.

Referenced by operator!=().

◆ isMasterBlock()

virtual bool juce::Block::isMasterBlock ( ) const
pure virtual

Returns true if this block is directly connected to the application, as opposed to only being connected to a different block via a connection port.

See also
ConnectionPort

Referenced by operator!=().

◆ getWidth()

virtual int juce::Block::getWidth ( ) const
pure virtual

Returns the width of the device in logical device units.

Referenced by operator!=().

◆ getHeight()

virtual int juce::Block::getHeight ( ) const
pure virtual

Returns the height of the device in logical device units.

Referenced by operator!=().

◆ isHardwareBlock()

virtual bool juce::Block::isHardwareBlock ( ) const
pure virtual

Returns true if the device is a physical hardware block (i.e.

not a virtual block).

Referenced by operator!=().

◆ getMillimetersPerUnit()

virtual float juce::Block::getMillimetersPerUnit ( ) const
pure virtual

Returns the length of one logical device unit as physical millimeters.

Referenced by operator!=().

◆ getLEDGrid()

virtual LEDGrid* juce::Block::getLEDGrid ( ) const
pure virtual

If this block has a grid of LEDs, this will return an object to control it.

Note that the pointer that is returned belongs to this object, and the caller must neither delete it or use it after the lifetime of this Block object has finished. If there are no LEDs, then this method will return nullptr.

Referenced by operator!=().

◆ getLEDRow()

virtual LEDRow* juce::Block::getLEDRow ( ) const
pure virtual

If this block has a row of LEDs, this will return an object to control it.

Note that the pointer that is returned belongs to this object, and the caller must neither delete it or use it after the lifetime of this Block object has finished. If there are no LEDs, then this method will return nullptr.

Referenced by operator!=().

◆ getStatusLights()

virtual juce::Array<StatusLight*> juce::Block::getStatusLights ( ) const
pure virtual

If this block has any status LEDs, this will return an array of objects to control them.

Note that the objects in the array belong to this Block object, and the caller must neither delete them or use them after the lifetime of this Block object has finished.

Referenced by operator!=().

◆ getTouchSurface()

virtual TouchSurface* juce::Block::getTouchSurface ( ) const
pure virtual

If this block has a pressure-sensitive surface, this will return an object to access its data.

Note that the pointer returned does is owned by this object, and the caller must neither delete it or use it after the lifetime of this Block object has finished. If the device is not touch-sensitive, then this method will return nullptr.

Referenced by operator!=().

◆ getButtons()

virtual juce::Array<ControlButton*> juce::Block::getButtons ( ) const
pure virtual

If this block has any control buttons, this will return an array of objects to control them.

Note that the objects in the array belong to this Block object, and the caller must neither delete them or use them after the lifetime of this Block object has finished.

Referenced by operator!=().

◆ supportsGraphics()

virtual bool juce::Block::supportsGraphics ( ) const
pure virtual

This returns true if the block supports generating graphics by drawing into a JUCE Graphics context.

This should only be true for virtual on-screen blocks; hardware blocks will instead use the LED Grid for visuals.

Referenced by operator!=().

◆ getPorts()

virtual juce::Array<ConnectionPort> juce::Block::getPorts ( ) const
pure virtual

Returns a list of the connectors that this device has.

◆ setProgram()

virtual juce::Result juce::Block::setProgram ( Program )
pure virtual

Sets the Program to run on this block.

The supplied Program's lifetime will be managed by this class, so do not use the Program in other places in your code.

◆ getProgram()

virtual Program* juce::Block::getProgram ( ) const
pure virtual

Returns a pointer to the currently loaded program.

◆ sendProgramEvent()

virtual void juce::Block::sendProgramEvent ( const ProgramEventMessage )
pure virtual

Sends a message to the currently loaded program.

To receive the message the program must provide a littlefoot function called handleMessage with the following form:

void handleMessage (int param1, int param2, int param3)
{
// Do something with the two integer parameters that the app has sent...
}

◆ addProgramEventListener()

virtual void juce::Block::addProgramEventListener ( ProgramEventListener )
virtual

Adds a new listener for custom program events from the block.

Referenced by juce::Block::ProgramEventListener::~ProgramEventListener().

◆ removeProgramEventListener()

virtual void juce::Block::removeProgramEventListener ( ProgramEventListener )
virtual

Removes a listener for custom program events from the block.

Referenced by juce::Block::ProgramEventListener::~ProgramEventListener().

◆ getMemorySize()

virtual uint32 juce::Block::getMemorySize ( )
pure virtual

Returns the size of the data block that setDataByte and other functions can write to.

Referenced by juce::Block::ProgramEventListener::~ProgramEventListener().

◆ setDataByte()

virtual void juce::Block::setDataByte ( size_t  offset,
uint8  value 
)
pure virtual

Sets a single byte on the littlefoot heap.

Referenced by juce::Block::ProgramEventListener::~ProgramEventListener().

◆ setDataBytes()

virtual void juce::Block::setDataBytes ( size_t  offset,
const void *  data,
size_t  num 
)
pure virtual

Sets multiple bytes on the littlefoot heap.

Referenced by juce::Block::ProgramEventListener::~ProgramEventListener().

◆ setDataBits()

virtual void juce::Block::setDataBits ( uint32  startBit,
uint32  numBits,
uint32  value 
)
pure virtual

Sets multiple bits on the littlefoot heap.

Referenced by juce::Block::ProgramEventListener::~ProgramEventListener().

◆ getDataByte()

virtual uint8 juce::Block::getDataByte ( size_t  offset)
pure virtual

Gets a byte from the littlefoot heap.

Referenced by juce::Block::ProgramEventListener::~ProgramEventListener().

◆ saveProgramAsDefault()

virtual void juce::Block::saveProgramAsDefault ( )
pure virtual

Sets the current program as the block's default state.

Referenced by juce::Block::ProgramEventListener::~ProgramEventListener().

◆ getMaxConfigIndex()

virtual uint32 juce::Block::getMaxConfigIndex ( )
pure virtual

Returns the maximum number of config items available.

◆ isValidUserConfigIndex()

virtual bool juce::Block::isValidUserConfigIndex ( uint32  item)
pure virtual

Determine if this is a valid config item index.

◆ getLocalConfigValue()

virtual int32 juce::Block::getLocalConfigValue ( uint32  item)
pure virtual

Get local config item value.

◆ setLocalConfigValue()

virtual void juce::Block::setLocalConfigValue ( uint32  item,
int32  value 
)
pure virtual

Set local config item value.

◆ setLocalConfigRange()

virtual void juce::Block::setLocalConfigRange ( uint32  item,
int32  min,
int32  max 
)
pure virtual

Set local config item range.

◆ setLocalConfigItemActive()

virtual void juce::Block::setLocalConfigItemActive ( uint32  item,
bool  isActive 
)
pure virtual

Set if config item is active or not.

◆ isLocalConfigItemActive()

virtual bool juce::Block::isLocalConfigItemActive ( uint32  item)
pure virtual

Determine if config item is active or not.

◆ getLocalConfigMetaData()

virtual ConfigMetaData juce::Block::getLocalConfigMetaData ( uint32  item)
pure virtual

Get config item metadata.

◆ requestFactoryConfigSync()

virtual void juce::Block::requestFactoryConfigSync ( )
pure virtual

Request sync of factory config with block.

◆ resetConfigListActiveStatus()

virtual void juce::Block::resetConfigListActiveStatus ( )
pure virtual

Reset all items active status.

◆ factoryReset()

virtual void juce::Block::factoryReset ( )
pure virtual

Perform factory reset on Block.

◆ blockReset()

virtual void juce::Block::blockReset ( )
pure virtual

Reset this Block.

◆ setName()

virtual bool juce::Block::setName ( const juce::String name)
pure virtual

Set Block name.

◆ setLogger()

virtual void juce::Block::setLogger ( std::function< void(const String &)>  loggingCallback)
pure virtual

Allows the user to provide a function that will receive log messages from the block.

◆ sendFirmwareUpdatePacket()

virtual bool juce::Block::sendFirmwareUpdatePacket ( const uint8 data,
uint8  size,
std::function< void(uint8, uint32)>  packetAckCallback 
)
pure virtual

Sends a firmware update packet to a block, and waits for a reply.

Returns an error code.

◆ setConfigChangedCallback()

virtual void juce::Block::setConfigChangedCallback ( std::function< void(Block &, const ConfigMetaData &, uint32)>  )
pure virtual

Provides a callback that will be called when a config changes.

◆ addDataInputPortListener()

virtual void juce::Block::addDataInputPortListener ( DataInputPortListener )
virtual

Adds a new listener for the data input port.

Referenced by juce::Block::DataInputPortListener::~DataInputPortListener().

◆ removeDataInputPortListener()

virtual void juce::Block::removeDataInputPortListener ( DataInputPortListener )
virtual

Removes a listener for the data input port.

Referenced by juce::Block::DataInputPortListener::~DataInputPortListener().

◆ sendMessage()

virtual void juce::Block::sendMessage ( const void *  messageData,
size_t  messageSize 
)
pure virtual

Sends a message to the block.

Referenced by juce::Block::DataInputPortListener::~DataInputPortListener().

Member Data Documentation

◆ serialNumber

const juce::String juce::Block::serialNumber

The Block's serial number.

◆ versionNumber

juce::String juce::Block::versionNumber

The Block's version number.

◆ name

juce::String juce::Block::name

The Block's name.

◆ uid

const UID juce::Block::uid

This Block's UID.

This will be globally unique, and remains constant for a particular device.

◆ dataInputPortListeners

juce::ListenerList<DataInputPortListener> juce::Block::dataInputPortListeners
protected

◆ programEventListeners

juce::ListenerList<ProgramEventListener> juce::Block::programEventListeners
protected

The documentation for this class was generated from the following file: