Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
|
#include <DigitalChannelManager.h>
Public Member Functions | |
void | setCallback (void(*newCallback)(bool, unsigned int, void *)) |
void | setCallbackArgument (unsigned int channel, void *arg) |
void | processInput (uint32_t *array, unsigned int length) |
void | processOutput (uint32_t *array, unsigned int length) |
bool | isSignalRate (unsigned int channel) |
bool | isMessageRate (unsigned int channel) |
bool | isInput (unsigned int channel) |
bool | isOutput (unsigned int channel) |
void | setValue (unsigned int channel, bool value) |
void | unmanage (unsigned int channel) |
void | manage (unsigned int channel, bool direction, bool isMessageRate) |
void | setVerbose (bool isVerbose) |
This class manages the digital channels.
Each channel can be set as either signal or message rate. When set as message rate: inputs are parsed when calling processInput() and a callback is invoked when they change state, outputs are set via calls to setValue() and then written to the output array when calling processOutput().
When set at signal rate: the DigitalChannelManager only sets the pin direction.
Throughout the class we keep track of message/signal rate and input/output in separate variables, so that we always know if a channel is managed by the DigitalChannelManager or not. This way, managed and unmanaged channels can be freely mixed in the code.
For the reasons above, isSignalRate(channel) is not the same as !isMessageRate(channel) and isInput(channel) is not the same as !isOutput(channel)
|
inline |
Set the callback.
The callback will be called when one of the managed message-rate input bits changes state. The callback's signature is void (stateChangedCallback)(bool value, unsigned int delay, void arg) where value
is the new value of the channel, delay
is the sample in the most recent block when the status changed, and arg
is an additional argument passed to the callback, which can be set for each channel using setCallbackArgument()
|
inline |
Sets the argument for the callback.
Typically an argument will allow the callback to identify the channel that changed state.
channel | is the channel for which the argument is set |
arg | is the argument that will be passed to the callback for that channel |
|
inline |
Process the input signals.
Parses the input array and looks for state changes in the bits managed as message-rate inputs and invokes the appropriate callbacks.
array | the array of input values |
length | the length of the array |
|
inline |
Process the output signals.
Processes the output array and appropriately sets the bits managed as message-rate outputs. Bits marked as input and unmanaged bits are left alone.
It also updates the channel directions.
array | the array of input values |
length | the length of the array |
|
inline |
Inquires if the channel is managed as signal-rate.
channel | the channel which is inquired. |
|
inline |
Inquires if the channel is managed as message-rate.
channel | the channel which is inquired. |
|
inline |
Inquires if the channel is managed as input.
channel | the channel which is inquired. |
|
inline |
Inquires if the channel is managed as output.
channel | the channel which is inquired. |
|
inline |
Sets the output value for a channel.
channel | the channel to set. |
value | the value to set. |
|
inline |
Stops managing a channel.
channel | the channel number |
|
inline |
Manages a channel.
Starts managing a channel with given direction and rate. It can be called repeatedly on a given channel to change direction and/or rate.
channel | the channel to manage. |
direction | |
isMessageRate | whether the channel should be managed at audio rate (false ) or message rate (true ) |