Skip to main content

Crate bela_sys

Crate bela_sys 

Source
Expand description

Raw FFI bindings to the Bela core API (libbela) for Bela Gem.

This crate exposes the C surface of the Bela core API (Bela.h): BelaContext, BelaInitSettings, the Bela_* lifecycle and auxiliary-task functions, and rt_printf. Bindings are generated from vendored headers (see vendor/bela/COMMIT for the pinned upstream commit) with cargo xtask bindgen; see the crate README for how to regenerate them. Higher-level C++ libraries (Scope, Trill, Fft, Gui, Midi) are out of scope.

The setup / render / cleanup callbacks are not bound: they are either provided to Bela_initAudio via BelaInitSettings or defined as #[unsafe(no_mangle)] symbols by the linking crate.

Target platform is Bela Gem on PocketBeagle 2 (aarch64-unknown-linux-gnu). For a safe API, use the bela crate instead.

Structs§

BelaChannelGain
BelaChannelGainArray
BelaContext
\ingroup render \brief Structure holding audio and sensor settings and pointers to I/O data buffers.
BelaCpuData
BelaInitSettings
\ingroup control \brief Structure containing initialisation parameters for the real-time audio control system.
_BelaHwConfig
_IO_FILE
_IO_codecvt
_IO_marker
_IO_wide_data
__BindgenOpaqueArray
If Bindgen could only determine the size and alignment of a type, it is represented like this.
option
timespec

Constants§

BELA_AUDIO_PRIORITY
BELA_BUGFIX_VERSION
BELA_FLAG_ANALOG_OUTPUTS_PERSIST
BELA_FLAG_DETECT_UNDERRUNS
BELA_FLAG_INTERLEAVED
BELA_FLAG_OFFLINE
BELA_MAJOR_VERSION
BELA_MINOR_VERSION
BelaHwDetectMode_BelaHwDetectMode_Cache
< read cached value from /run/bela/belaconfig first. If it does not exist, fall back to #BelaHwDetectMode_Scan
BelaHwDetectMode_BelaHwDetectMode_CacheOnly
<read cached value from /run/bela/belaconfig. If it does not exist, return #BelaHw_NoHw
BelaHwDetectMode_BelaHwDetectMode_Scan
< perform an automatic detection by scanning the peripherals and busses available, and cache value in /run/bela/belaconfig
BelaHwDetectMode_BelaHwDetectMode_User
<read user-specified value from ~/.bela/belaconfig. If it does not exist, fall back to #BelaHwDetectMode_Cache
BelaHwDetectMode_BelaHwDetectMode_UserOnly
<read user-specified value from ~/.bela/belaconfig. If it does not exist, return #BelaHw_NoHw
BelaHw_BelaHw_Batch
< Dummy offline
BelaHw_BelaHw_Bela
< Bela
BelaHw_BelaHw_BelaEs9080
< A Bela cape with Es9080 EVB on top, all as audio
BelaHw_BelaHw_BelaMini
< Bela Mini
BelaHw_BelaHw_BelaMiniMultiAudio
< Bela Mini with extra codecs
BelaHw_BelaHw_BelaMiniMultiI2s
< Bela Mini with extra rx and tx I2S data lines.
BelaHw_BelaHw_BelaMiniMultiTdm
< Bela Mini with extra codecs and/or tdm devices
BelaHw_BelaHw_BelaMultiTdm
< Bela with extra codecs and/or tdm devices
BelaHw_BelaHw_BelaRevC
< A Bela cape rev C: Es9080 is used for analog outs
BelaHw_BelaHw_CtagBeast
< Ctag Beast
BelaHw_BelaHw_CtagBeastBela
< Ctag Beast and Bela cape
BelaHw_BelaHw_CtagFace
< Ctag Face
BelaHw_BelaHw_CtagFaceBela
< Ctag Face and Bela cape
BelaHw_BelaHw_NoHw
< No hardware
BelaHw_BelaHw_Salt
< Salt
DEFAULT_HP_LEVEL
DEFAULT_LINE_OUT_LEVEL
DEFAULT_PGA_GAIN

Functions§

Bela_HwConfig_delete
Use this to delete a pointer returned by Bela_HwConfig_new()
Bela_HwConfig_new
Returns the configuration for a given BelaHw or nullptr if hw is invalid.
Bela_InitSettings_alloc
\brief Allocate the data structure containing settings for Bela.
Bela_InitSettings_free
\brief De-allocate the data structure containing settings for Bela.
Bela_cleanupAudio
\brief Clean up resources from audio and sensor processing.
Bela_cpuMonitoringGet
Get stats about internal CPU monitoring.
Bela_cpuMonitoringInit
Set internal CPU monitoring for the audio thread. @param count Number of samples (tic/toc pairs) in a acquisition cycle. Use 0 to disable. @return 0 on success, an error code otherwise.
Bela_cpuTic
Start measuring CPU time. When data->currentCount reaches data->count, a acquisition cycle is completed. data->percentage gives the average CPU busy time during the latest completed acquisition cycle.
Bela_cpuToc
Stop measuring CPU time.
Bela_createAuxiliaryTask
\brief Create a new auxiliary task.
Bela_defaultSettings
\brief Initialise the data structure containing settings for Bela.
Bela_deleteAllAuxiliaryTasks
Bela_detectHw
\brief Detect what hardware we are running on.
Bela_getVersion
\brief Get the version of Bela you are running.
Bela_getopt_long
\brief Get long options from command line argument list, including Bela standard options
Bela_initAudio
\brief Initialise audio and sensor rendering environment.
Bela_muteSpeakers
\brief Mute or unmute the onboard speaker amplifiers.
Bela_printf
Bela_requestStop
\brief Tell the Bela program to stop.
Bela_runInSameThread
\brief Begin processing audio and sensor data in the same thread as the caller.
Bela_scheduleAuxiliaryTask
\brief Run an auxiliary task which has previously been created.
Bela_setADCLevel
DEPRECATED.
Bela_setAdcLevel
\brief Set the level of the audio ADC.
Bela_setAudioInputGain
\brief Set the gain of the audio input preamplifier.
Bela_setDACLevel
DEPRECATED.
Bela_setDacLevel
\brief Set the level of the audio DAC.
Bela_setHeadphoneLevel
DEPRECATED Equivalent to Bela_setHpLevel(-1, decibels);
Bela_setHpLevel
\brief Set the level of the onboard headphone amplifier.
Bela_setLineOutLevel
\brief Set the level of the audio line out.
Bela_setPgaGain
DEPRECATED.
Bela_setUserData
\brief Set the userData variable, which is passed to setup(), render() and cleanup().
Bela_setVerboseLevel
\brief Set level of verbose (debugging) printing.
Bela_startAudio
\brief Begin processing audio and sensor data.
Bela_stopAudio
\brief Stop processing audio and sensor data.
Bela_stopRequested
\brief Check whether the program should stop.
Bela_usage
\brief Print usage information for Bela standard options.
Bela_userSettings
\brief Initialise the data structure containing settings for Bela.
rt_printf

Type Aliases§

AuxiliaryTask
\ingroup auxtask
BelaHw
A type of Bela hardware.
BelaHwConfig
BelaHwDetectMode
Arguments to be passed to Bela_detectHw()
FILE
_IO_lock_t
__gnuc_va_list
__off64_t
__off_t
__syscall_slong_t
__time_t
va_list