|
Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
|
Main Bela public API. More...
#include <stdint.h>#include <unistd.h>#include <stdbool.h>#include <stdio.h>#include <GPIOcontrol.h>#include <time.h>#include <Utilities.h>Go to the source code of this file.
Classes | |
| struct | _BelaHwConfig |
| struct | BelaContext |
| Structure holding audio and sensor settings and pointers to I/O data buffers. More... | |
| struct | BelaChannelGain |
| struct | BelaChannelGainArray |
| struct | BelaInitSettings |
| Structure containing initialisation parameters for the real-time audio control system. More... | |
| struct | BelaCpuData |
Macros | |
| #define | BELA_MAJOR_VERSION 1 |
| #define | BELA_MINOR_VERSION 13 |
| #define | BELA_BUGFIX_VERSION 0 |
| #define | BELA_AUDIO_PRIORITY 95 |
| #define | DEFAULT_LINE_OUT_LEVEL 0.0 |
| #define | DEFAULT_PGA_GAIN 16 |
| #define | DEFAULT_HP_LEVEL -6.0 |
| #define | BELA_FLAG_INTERLEAVED (1 << 0) |
| #define | BELA_FLAG_ANALOG_OUTPUTS_PERSIST (1 << 1) |
| #define | BELA_FLAG_DETECT_UNDERRUNS (1 << 2) |
| #define | BELA_FLAG_OFFLINE (1 << 3) |
Typedefs | |
| typedef struct _BelaHwConfig | BelaHwConfig |
| typedef void * | AuxiliaryTask |
Enumerations | |
| enum | BelaHw { BelaHw_NoHw = -1 , BelaHw_Bela , BelaHw_BelaMini , BelaHw_Salt , BelaHw_CtagFace , BelaHw_CtagBeast , BelaHw_CtagFaceBela , BelaHw_CtagBeastBela , BelaHw_BelaMiniMultiAudio , BelaHw_BelaMiniMultiTdm , BelaHw_BelaMultiTdm , BelaHw_BelaMiniMultiI2s , BelaHw_BelaEs9080 , BelaHw_BelaRevC , BelaHw_Batch } |
| enum | BelaHwDetectMode { BelaHwDetectMode_Scan , BelaHwDetectMode_Cache , BelaHwDetectMode_CacheOnly , BelaHwDetectMode_User , BelaHwDetectMode_UserOnly } |
| enum | { INPUT = 0 , OUTPUT = 1 } |
Functions | |
| int | rt_printf (const char *format,...) |
| int | rt_fprintf (FILE *stream, const char *format,...) |
| int | rt_vprintf (const char *format, va_list ap) |
| int | rt_vfprintf (FILE *stream, const char *format, va_list ap) |
| BelaHwConfig * | Bela_HwConfig_new (BelaHw hw) |
| void | Bela_HwConfig_delete (BelaHwConfig *cfg) |
| bool | setup (BelaContext *context, void *userData) |
| User-defined initialisation function which runs before audio rendering begins. | |
| void | render (BelaContext *context, void *userData) |
| User-defined callback function to process audio and sensor data. | |
| void | cleanup (BelaContext *context, void *userData) |
| User-defined cleanup function which runs when the program finishes. | |
| BelaInitSettings * | Bela_InitSettings_alloc () |
| Allocate the data structure containing settings for Bela. | |
| void | Bela_InitSettings_free (BelaInitSettings *settings) |
| De-allocate the data structure containing settings for Bela. | |
| void | Bela_defaultSettings (BelaInitSettings *settings) |
| Initialise the data structure containing settings for Bela. | |
| void | Bela_userSettings (BelaInitSettings *settings) |
| Initialise the data structure containing settings for Bela. | |
| 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. | |
| void | Bela_usage () |
| Print usage information for Bela standard options. | |
| void | Bela_getVersion (int *major, int *minor, int *bugfix) |
| Get the version of Bela you are running. | |
| void | Bela_setVerboseLevel (int level) |
| Set level of verbose (debugging) printing. | |
| BelaHw | Bela_detectHw (BelaHwDetectMode mode) |
| Detect what hardware we are running on. | |
| int | Bela_initAudio (BelaInitSettings *settings, void *userData) |
| Initialise audio and sensor rendering environment. | |
| int | Bela_startAudio () |
| Begin processing audio and sensor data. | |
| int | Bela_runInSameThread () |
| Begin processing audio and sensor data in the same thread as the caller. | |
| void | Bela_stopAudio () |
| Stop processing audio and sensor data. | |
| void | Bela_cleanupAudio () |
| Clean up resources from audio and sensor processing. | |
| void | Bela_setUserData (void *newUserData) |
| Set the userData variable, which is passed to setup(), render() and cleanup(). | |
| void | Bela_requestStop () |
| Tell the Bela program to stop. | |
| int | Bela_stopRequested () |
| Check whether the program should stop. | |
| int | Bela_cpuMonitoringInit (int count) |
| BelaCpuData * | Bela_cpuMonitoringGet () |
| void | Bela_cpuTic (BelaCpuData *data) |
| void | Bela_cpuToc (BelaCpuData *data) |
| int | Bela_setLineOutLevel (int channel, float decibel) |
| Set the level of the audio line out. | |
| int | Bela_setDacLevel (int channel, float decibels) |
| Set the level of the audio DAC. | |
| int | Bela_setDACLevel (float decibels) |
| int | Bela_setAdcLevel (int channel, float decibels) |
| Set the level of the audio ADC. | |
| int | Bela_setADCLevel (float decibels) |
| int | Bela_setAudioInputGain (int channel, float decibels) |
| Set the gain of the audio input preamplifier. | |
| int | Bela_setPgaGain (float decibels, int channel) |
| int | Bela_setHpLevel (int channel, float decibels) |
| Set the level of the onboard headphone amplifier. | |
| int | Bela_setHeadphoneLevel (float decibels) |
| int | Bela_muteSpeakers (int mute) |
| Mute or unmute the onboard speaker amplifiers. | |
| AuxiliaryTask | Bela_createAuxiliaryTask (void(*callback)(void *), int priority, const char *name, void *arg=NULL) |
| Create a new auxiliary task. | |
| int | Bela_scheduleAuxiliaryTask (AuxiliaryTask task) |
| Run an auxiliary task which has previously been created. | |
| AuxiliaryTask | Bela_runAuxiliaryTask (void(*callback)(void *), int priority=0, void *arg=nullptr) |
| Create and start an AuxiliaryTask. | |
| int | Bela_startAuxiliaryTask (AuxiliaryTask task) |
| Initialize an auxiliary task so that it can be scheduled. | |
| int | Bela_startAllAuxiliaryTasks () |
| void | Bela_stopAllAuxiliaryTasks () |
| void | Bela_deleteAllAuxiliaryTasks () |
| static float | audioRead (BelaContext *context, int frame, int channel) |
| Read an audio input, specifying the frame number (when to read) and the channel. | |
| static float | audioReadNI (BelaContext *context, int frame, int channel) |
| Non-interleaved version of audioRead(). | |
| 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. | |
| static void | audioWriteNI (BelaContext *context, int frame, int channel, float value) |
| Non-interleaved version of audioWrite(). | |
| static float | analogRead (BelaContext *context, int frame, int channel) |
| Read an analog input, specifying the frame number (when to read) and the channel. | |
| static float | analogReadNI (BelaContext *context, int frame, int channel) |
| Non-interleaved version of analogRead(). | |
| 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. | |
| static void | analogWriteNI (BelaContext *context, int frame, int channel, float value) |
| Non-interleaved version of analogWrite(). | |
| 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. | |
| static void | analogWriteOnceNI (BelaContext *context, int frame, int channel, float value) |
| Non-interleaved version of analogWriteNI(). | |
| static int | digitalRead (BelaContext *context, int frame, int channel) |
| Read a digital input, specifying the frame number (when to read) and the pin. | |
| 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. | |
| 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. | |
| static void | pinMode (BelaContext *context, int frame, int channel, int mode) |
| Set the direction of a digital pin to input or output. | |
| static void | pinModeOnce (BelaContext *context, int frame, int channel, int mode) |
| Set the direction of a digital pin to input or output. | |
| static float | multiplexerAnalogRead (BelaContext *context, int input, int muxChannel) |
| Read an audio input, specifying the frame number (when to read) and the channel. | |
| static unsigned int | multiplexerChannelForFrame (BelaContext *context, int frame) |
| Read an audio input, specifying the frame number (when to read) and the channel. | |
Variables | |
| int volatile | gShouldStop |
Main Bela public API.
Central control code for hard real-time audio on BeagleBone Black using PRU and Xenomai Linux extensions. This code began as part of the Hackable Instruments project (EPSRC) at Queen Mary University of London, 2013-14.
(c) 2014-15 Andrew McPherson, Victor Zappi and Giulio Moro, Queen Mary University of London
| #define BELA_FLAG_INTERLEAVED (1 << 0) |
Flag for BelaContext. If set, indicates the audio and analog buffers are interleaved.
| #define BELA_FLAG_ANALOG_OUTPUTS_PERSIST (1 << 1) |
Flag for BelaContext. If set, indicates analog outputs persist for future frames.
| #define BELA_FLAG_DETECT_UNDERRUNS (1 << 2) |
Flag for BelaContext. If set, indicates the user will be warned if an underrun occurs
| #define BELA_FLAG_OFFLINE (1 << 3) |
Flag for BelaContext. If set, it means that render() is called offline, i.e.: the audio time does not correspond to wall clock time.
| enum BelaHw |
A type of Bela hardware.
| enum BelaHwDetectMode |
Arguments to be passed to Bela_detectHw()
| Enumerator | |
|---|---|
| BelaHwDetectMode_Scan | perform an automatic detection by scanning the peripherals and busses available, and cache value in /run/bela/belaconfig |
| BelaHwDetectMode_Cache | read cached value from /run/bela/belaconfig first. If it does not exist, fall back to BelaHwDetectMode_Scan |
| BelaHwDetectMode_CacheOnly | read cached value from /run/bela/belaconfig. If it does not exist, return BelaHw_NoHw |
| BelaHwDetectMode_User | read user-specified value from ~/.bela/belaconfig. If it does not exist, fall back to BelaHwDetectMode_Cache |
| BelaHwDetectMode_UserOnly | read user-specified value from ~/.bela/belaconfig. If it does not exist, return BelaHw_NoHw |
| BelaHwConfig * Bela_HwConfig_new | ( | BelaHw | hw | ) |
Returns the configuration for a given BelaHw or nullptr if hw is invalid.
The returned pointer has to be deleted with Bela_HwConfig_delete().
| void Bela_HwConfig_delete | ( | BelaHwConfig * | cfg | ) |
Use this to delete a pointer returned by Bela_HwConfig_new()