29 #define BELA_MAJOR_VERSION 1
30 #define BELA_MINOR_VERSION 13
31 #define BELA_BUGFIX_VERSION 0
99 int rt_printf(
const char *format, ...);
100 int rt_fprintf(FILE *stream,
const char *format, ...);
101 int rt_vprintf(
const char *format, va_list ap);
102 int rt_vfprintf(FILE *stream,
const char *format, va_list ap);
128 float audioSampleRate;
129 unsigned int audioInChannels;
130 unsigned int audioOutChannels;
131 unsigned int analogInChannels;
132 unsigned int analogOutChannels;
133 unsigned int digitalChannels;
161 #include <GPIOcontrol.h>
166 #define MAX_PRU_FILENAME_LENGTH 256
167 #define MAX_UNUSED_LENGTH 220
168 #define MAX_PROJECTNAME_LENGTH 256
178 #define BELA_AUDIO_PRIORITY 95
191 #define DEFAULT_LINE_OUT_LEVEL 0.0
196 #define DEFAULT_PGA_GAIN 16
201 #define DEFAULT_HP_LEVEL -6.0
207 #define BELA_FLAG_INTERLEAVED (1 << 0) // Set if buffers are interleaved
211 #define BELA_FLAG_ANALOG_OUTPUTS_PERSIST (1 << 1) // Set if analog/digital outputs persist for future buffers
215 #define BELA_FLAG_DETECT_UNDERRUNS (1 << 2) // Set if the user will be displayed a message when an underrun occurs
219 #define BELA_FLAG_OFFLINE (1 << 3)
417 char projectName[MAX_PROJECTNAME_LENGTH];
485 char pruFilename[MAX_PRU_FILENAME_LENGTH];
515 unsigned int audioThreadStackSize;
518 unsigned int auxiliaryTaskStackSize;
546 char unused[MAX_UNUSED_LENGTH];
688 #pragma weak Bela_userSettings
723 int Bela_getopt_long(
int argc,
char *
const argv[],
const char *customShortOptions,
848 #ifndef BELA_DISABLE_CPU_TIME
910 #endif // BELA_DISABLE_CPU_TIME
1110 AuxiliaryTask
Bela_runAuxiliaryTask(
void (*callback)(
void*),
int priority = 0,
void* arg =
nullptr);
1111 #endif // __cplusplus
1131 int Bela_startAllAuxiliaryTasks();
1132 void Bela_stopAllAuxiliaryTasks();
1133 void Bela_deleteAllAuxiliaryTasks();
1138 #ifndef BELA_DONT_INCLUDE_UTILITIES
1139 #include <Utilities.h>
1140 #endif // BELA_DONT_INCLUDE_UTILITIES
1170 #define Bela_setBit(word,bit) ((word) | (1 << (bit)))
1174 #define Bela_clearBit(word,bit) ((word) &~ (1 << (bit)))
1177 #define Bela_getBit(word,bit) (((word) >> (bit)) & 1)
1180 #define Bela_changeBit(word,bit,value) ((Bela_clearBit((word),(bit))) | ((value) << (bit)))
1519 return Bela_getBit(context->
digital[frame], channel + 16);
1529 context->
digital[f] |= 1 << (channel + 16);
1531 context->
digital[f] &= ~(1 << (channel + 16));
1540 context->
digital[frame] |= 1 << (channel + 16);
1542 context->
digital[frame] &= ~(1 << (channel + 16));
1552 context->
digital[f] |= (1 << channel);
1554 context->
digital[f] &= ~(1 << channel);
1563 context->
digital[frame] |= (1 << channel);
1565 context->
digital[frame] &= ~(1 << channel);
float percentage
Average CPU usage during previous acquisition cycle.
Definition: Bela.h:879
char * codecMode
A codec-specific intialisation parameter.
Definition: Bela.h:534
int detectUnderruns
Whether to detect and log underruns.
Definition: Bela.h:487
uint32_t disabledDigitalChannels
A bitmask of disabled digital channels.
Definition: Bela.h:544
Dummy offline.
Definition: Bela.h:123
read user-specified value from ~/.bela/belaconfig. If it does not exist, fall back to BelaHwDetectMod...
Definition: Bela.h:157
Bela Mini with extra codecs and/or tdm devices.
Definition: Bela.h:118
const uint32_t multiplexerChannels
Number of multiplexer channels for each analog input.
Definition: Bela.h:385
Ctag Beast and Bela cape.
Definition: Bela.h:116
const float *const analogIn
Buffer holding analog input samples.
Definition: Bela.h:283
int Bela_stopRequested()
Check whether the program should stop.
static void audioWriteNI(BelaContext *context, int frame, int channel, float value)
Non-interleaved version of audioWrite()
Definition: Bela.h:1473
Bela with extra codecs and/or tdm devices.
Definition: Bela.h:119
long long unsigned int total
Total CPU time (between tic and previous tic) during the current acquisition cycle.
Definition: Bela.h:876
float adcLevel
Level for the audio ADC input. DEPRECATED: use audioInputGains.
Definition: Bela.h:470
int ampMutePin
Pin where amplifier mute can be found.
Definition: Bela.h:528
const uint32_t audioInChannels
The number of audio input channels.
Definition: Bela.h:324
const float digitalSampleRate
Digital sample rate in Hz (currently always 44100.0)
Definition: Bela.h:371
int Bela_setAudioInputGain(int channel, float decibels)
Set the gain of the audio input preamplifier.
const uint32_t analogInChannels
The number of analog input channels.
Definition: Bela.h:346
int Bela_scheduleAuxiliaryTask(AuxiliaryTask task)
Run an auxiliary task which has previously been created.
void Bela_usage()
Print usage information for Bela standard options.
static float analogRead(BelaContext *context, int frame, int channel)
Read an analog input, specifying the frame number (when to read) and the channel. ...
Definition: Bela.h:1480
static float audioReadNI(BelaContext *context, int frame, int channel)
Non-interleaved version of audioRead()
Definition: Bela.h:1462
static void audioWrite(BelaContext *context, int frame, int channel, float value)
Write an audio output, specifying the frame number (when to write) and the channel.
Definition: Bela.h:1469
void Bela_cpuTic(BelaCpuData *data)
float headphoneLevel
Level for the headphone output. DEPRECATED: use headphoneGains.
Definition: Bela.h:474
const uint32_t analogOutChannels
The number of analog output channels.
Definition: Bela.h:351
float gain
Gain in dB.
Definition: Bela.h:425
BelaCpuData * Bela_cpuMonitoringGet()
void Bela_setVerboseLevel(int level)
Set level of verbose (debugging) printing.
const uint32_t multiplexerStartingChannel
Multiplexer channel corresponding to the first analog frame.
Definition: Bela.h:391
static void analogWriteOnceNI(BelaContext *context, int frame, int channel, float value)
Non-interleaved version of analogWriteNI()
Definition: Bela.h:1495
BelaHwConfig * Bela_HwConfig_new(BelaHw hw)
const uint32_t flags
Other audio/sensor settings.
Definition: Bela.h:414
int Bela_setDACLevel(float decibels)
int verbose
Whether to use verbose logging.
Definition: Bela.h:489
int Bela_getopt_long(int argc, char *const argv[], const char *customShortOptions, const struct option *customLongOptions, BelaInitSettings *settings)
Get long options from command line argument list, including Bela standard options.
const uint32_t digitalChannels
Number of digital channels.
Definition: Bela.h:369
perform an automatic detection by scanning the peripherals and busses available, and cache value in /...
Definition: Bela.h:154
int Bela_setAdcLevel(int channel, float decibels)
Set the level of the audio ADC.
const uint32_t digitalFrames
Number of digital frames per period.
Definition: Bela.h:365
void Bela_getVersion(int *major, int *minor, int *bugfix)
Get the version of Bela you are running.
Bela Mini with extra codecs.
Definition: Bela.h:117
int numAudioInChannels
How many audio input channels [ignored].
Definition: Bela.h:455
BelaHw
Definition: Bela.h:107
unsigned int audioExpanderOutputs
Which audio expander settings to use on the input.
Definition: Bela.h:480
void Bela_cpuToc(BelaCpuData *data)
int Bela_setHeadphoneLevel(float decibels)
int pruNumber
Which PRU (0 or 1) the code should run on.
Definition: Bela.h:483
void cleanup(BelaContext *context, void *userData)
User-defined cleanup function which runs when the program finishes.
Definition: render.cpp:96
BelaInitSettings * Bela_InitSettings_alloc()
Allocate the data structure containing settings for Bela.
read cached value from /run/bela/belaconfig first. If it does not exist, fall back to BelaHwDetectMod...
Definition: Bela.h:155
void Bela_requestStop()
Tell the Bela program to stop.
Bela Mini with extra rx and tx I2S data lines.
Definition: Bela.h:120
void Bela_userSettings(BelaInitSettings *settings)
Initialise the data structure containing settings for Bela.
Definition: render.cpp:64
static void analogWriteNI(BelaContext *context, int frame, int channel, float value)
Non-interleaved version of analogWrite()
Definition: Bela.h:1509
static int digitalRead(BelaContext *context, int frame, int channel)
Read a digital input, specifying the frame number (when to read) and the pin.
Definition: Bela.h:1518
static unsigned int multiplexerChannelForFrame(BelaContext *context, int frame)
Read an audio input, specifying the frame number (when to read) and the channel.
Definition: Bela.h:1578
Structure containing initialisation parameters for the real-time audio control system.
Definition: Bela.h:441
float *const audioOut
Buffer holding audio output samples.
Definition: Bela.h:264
int numAudioOutChannels
How many audio out channels [ignored].
Definition: Bela.h:457
char * projectName
Name of running project.
Definition: Bela.h:552
int interleave
Whether audio/analog data should be interleaved.
Definition: Bela.h:505
const uint32_t audioFrames
The number of audio frames per block.
Definition: Bela.h:322
void Bela_HwConfig_delete(BelaHwConfig *cfg)
void Bela_stopAudio()
Stop processing audio and sensor data.
AuxiliaryTask Bela_runAuxiliaryTask(void(*callback)(void *), int priority=0, void *arg=nullptr)
Create and start an AuxiliaryTask.
void Bela_setUserData(void *newUserData)
Set the userData variable, which is passed to setup(), render() and cleanup().
static void digitalWriteOnce(BelaContext *context, int frame, int channel, int value)
Write a digital output, specifying the frame number (when to write) and the pin.
Definition: Bela.h:1538
No hardware.
Definition: Bela.h:109
int Bela_muteSpeakers(int mute)
Mute or unmute the onboard speaker amplifiers.
BelaHw board
User selected board to work with (as opposed to detected hardware).
Definition: Bela.h:549
AuxiliaryTask Bela_createAuxiliaryTask(void(*callback)(void *), int priority, const char *name, void *arg=NULL)
Create a new auxiliary task.
const float analogSampleRate
Analog sample rate in Hz.
Definition: Bela.h:362
Structure holding audio and sensor settings and pointers to I/O data buffers.
Definition: Bela.h:231
const uint32_t audioExpanderEnabled
Flags for whether audio expander is enabled on given analog channels.
Definition: Bela.h:404
A Bela cape rev C: Es9080 is used for analog outs.
Definition: Bela.h:122
bool setup(BelaContext *context, void *userData)
User-defined initialisation function which runs before audio rendering begins.
Definition: render.cpp:51
BelaHw Bela_detectHw(BelaHwDetectMode mode)
Detect what hardware we are running on.
int uniformSampleRate
Whether the analog channels should be resampled to audio sampling rate.
Definition: Bela.h:512
Ctag Face.
Definition: Bela.h:113
int count
Number of samples (tic/toc pairs) in a acquisition cycle. Use 0 to disable.
Definition: Bela.h:873
int numMuxChannels
How many channels to use on the multiplexer capelet, if enabled.
Definition: Bela.h:476
int Bela_initAudio(BelaInitSettings *settings, void *userData)
Initialise audio and sensor rendering environment.
Salt.
Definition: Bela.h:112
int numAnalogOutChannels
How many analog output channels.
Definition: Bela.h:461
int Bela_setLineOutLevel(int channel, float decibel)
Set the level of the audio line out.
Ctag Face and Bela cape.
Definition: Bela.h:115
Bela.
Definition: Bela.h:110
float *const analogOut
Buffer holding analog output samples.
Definition: Bela.h:298
const uint32_t audioOutChannels
The number of audio output channels.
Definition: Bela.h:326
int Bela_setPgaGain(float decibels, int channel)
int Bela_cpuMonitoringInit(int count)
int beginMuted
Whether to begin with the speakers muted.
Definition: Bela.h:466
int numAnalogInChannels
How many analog input channels.
Definition: Bela.h:459
static void analogWriteOnce(BelaContext *context, int frame, int channel, float value)
Write an analog output, specifying the frame number (when to write) and the channel.
Definition: Bela.h:1491
void render(BelaContext *context, void *userData)
User-defined callback function to process audio and sensor data.
Definition: render.cpp:68
BelaHwDetectMode
Definition: Bela.h:152
read cached value from /run/bela/belaconfig. If it does not exist, return BelaHw_NoHw ...
Definition: Bela.h:156
read user-specified value from ~/.bela/belaconfig. If it does not exist, return BelaHw_NoHw ...
Definition: Bela.h:158
uint32_t *const digital
Buffer holding digital input/output samples.
Definition: Bela.h:308
const unsigned int underrunCount
Number of detected underruns.
Definition: Bela.h:420
const uint64_t audioFramesElapsed
Number of elapsed audio frames since the start of rendering.
Definition: Bela.h:379
unsigned int audioExpanderInputs
Which audio expander settings to use on the input.
Definition: Bela.h:478
static void analogWrite(BelaContext *context, int frame, int channel, float value)
Write an analog output, specifying the frame number (when to write) and the channel.
Definition: Bela.h:1503
float dacLevel
Level for the audio DAC output. DEPRECATED: ues lineOutGains.
Definition: Bela.h:468
Bela Mini.
Definition: Bela.h:111
int Bela_setADCLevel(float decibels)
static float audioRead(BelaContext *context, int frame, int channel)
Read an audio input, specifying the frame number (when to read) and the channel.
Definition: Bela.h:1458
void Bela_InitSettings_free(BelaInitSettings *settings)
De-allocate the data structure containing settings for Bela.
const uint32_t analogFrames
The number of analog frames per block.
Definition: Bela.h:341
int highPerformanceMode
Definition: Bela.h:499
int numDigitalChannels
How many channels for the GPIOs.
Definition: Bela.h:463
int stopButtonPin
Definition: Bela.h:494
void * AuxiliaryTask
Definition: Bela.h:561
static float analogReadNI(BelaContext *context, int frame, int channel)
Non-interleaved version of analogRead()
Definition: Bela.h:1484
const float *const multiplexerAnalogIn
Buffer which holds multiplexed analog inputs, when multiplexer capelet is enabled.
Definition: Bela.h:398
int Bela_setDacLevel(int channel, float decibels)
Set the level of the audio DAC.
Ctag Beast.
Definition: Bela.h:114
int Bela_runInSameThread()
Begin processing audio and sensor data in the same thread as the caller.
int channel
Channel number. Negative value means all the channels.
Definition: Bela.h:424
int enableLED
Whether to use the blinking LED to indicate Bela is running.
Definition: Bela.h:491
long long unsigned int busy
Total CPU time spent being busy (between tic and toc) during the current acquisition cycle...
Definition: Bela.h:875
static void pinMode(BelaContext *context, int frame, int channel, int mode)
Set the direction of a digital pin to input or output.
Definition: Bela.h:1548
int Bela_setHpLevel(int channel, float decibels)
Set the level of the onboard headphone amplifier.
int useAnalog
Whether to use the analog input and output.
Definition: Bela.h:451
static void pinModeOnce(BelaContext *context, int frame, int channel, int mode)
Set the direction of a digital pin to input or output.
Definition: Bela.h:1561
const float audioSampleRate
The audio sample rate in Hz (currently always 44100.0)
Definition: Bela.h:328
int Bela_startAudio()
Begin processing audio and sensor data.
int periodSize
Number of audio frames per period ("blocksize").
Definition: Bela.h:449
static void digitalWrite(BelaContext *context, int frame, int channel, int value)
Write a digital output, specifying the frame number (when to write) and the pin.
Definition: Bela.h:1525
int analogOutputsPersist
Whether analog outputs should persist to future frames.
Definition: Bela.h:509
const float *const audioIn
Buffer holding audio input samples.
Definition: Bela.h:249
int useDigital
Whether to use the 16 programmable GPIOs.
Definition: Bela.h:453
static float multiplexerAnalogRead(BelaContext *context, int input, int muxChannel)
Read an audio input, specifying the frame number (when to read) and the channel.
Definition: Bela.h:1571
void Bela_defaultSettings(BelaInitSettings *settings)
Initialise the data structure containing settings for Bela.
int Bela_startAuxiliaryTask(AuxiliaryTask task)
Initialize an auxiliary task so that it can be scheduled.
unsigned int currentCount
Number of tics in current acquisition cycle.
Definition: Bela.h:874
A Bela cape with Es9080 EVB on top, all as audio.
Definition: Bela.h:121
void Bela_cleanupAudio()
Clean up resources from audio and sensor processing.