Workbench Library  0.1b
Config

Configuration settings and utility functions for Workbench audio and MIDI applications. More...

Data Structures

struct  Config
 Defines the structure for configuration settings. More...
 

Macros

#define DEFAULT_IN_CHANNELS_COUNT    1
 Defines the default number of audio input channels.
 
#define DEFAULT_OUT_CHANNELS_COUNT    2
 Defines the default number of audio output channels.
 
#define FLAGS(FLAG)
 Defines a list of feature flags and their bitwise representations. More...
 
#define CONFIG(FIELD)
 Defines configuration fields and their default values using the X-macro technique. More...
 

Enumerations

enum  flag_bits { FLAGS =(WORKBENCH_FLAG_ENUMERATE) }
 Enumeration of flag bits for feature flags.
 
enum  flags { FLAGS =(WORKBENCH_FLAG_ENUMERATE) }
 Enumeration of feature flags.
 

Functions

Configconfig_init (int argc, char **argv, AudioCallback audio_cb, MidiCallback midi_cb, void *user_data)
 Initializes the configuration with the specified audio and MIDI callbacks. More...
 
void config_deinit ()
 
void config_print ()
 Prints the current configuration settings to the standard output.
 
Configconfig_get ()
 Retrieves the current configuration. More...
 
uint8_t get_log_level ()
 Retrieves the log level. More...
 

Detailed Description

Configuration settings and utility functions for Workbench audio and MIDI applications.

This header file defines the configuration structure and related macros for managing audio and MIDI settings in Workbench applications. It includes default values, flag enumerations, and function prototypes for initializing and managing the configuration.

Macro Definition Documentation

◆ CONFIG

#define CONFIG (   FIELD)
Value:
FIELD(char *, midi_input, NULL) \
FIELD(char *, midi_output, NULL) \
FIELD(int, midi_output_latecncy, 0) \
FIELD(int, midi_buffer_size, 1024) \
FIELD(char *, audio_input, NULL) \
FIELD(char *, audio_output, NULL) \
FIELD(double, sample_rate, 44100.0) \
FIELD(uint32_t, block_size, 512U) \
FIELD(uint32_t, audio_flags, 0U) \
FIELD(int, in_channel_count, DEFAULT_IN_CHANNELS_COUNT) \
FIELD(int, out_channel_count, DEFAULT_OUT_CHANNELS_COUNT) \
FIELD(double, suggested_latency, -1.0) \
FIELD(uint32_t, flags, 0U) \
FIELD(uint8_t, log_level, 4)
#define DEFAULT_IN_CHANNELS_COUNT
Defines the default number of audio input channels.
Definition: workbench.h:183
#define DEFAULT_OUT_CHANNELS_COUNT
Defines the default number of audio output channels.
Definition: workbench.h:185
flags
Enumeration of feature flags.
Definition: workbench.h:215

Defines configuration fields and their default values using the X-macro technique.

The CONFIG macro uses the X-macro technique to define a list of configuration fields along with their types and default values. By passing a FIELD macro to CONFIG, you can generate different pieces of code, such as structure definitions, initializers, or setters, based on the same set of configuration fields.

Parameters
FIELDA macro that takes three parameters: type, name, and default value of a field.

Example Usage: To define a structure with the configuration fields:

#define WORKBENCH_CONFIG_DEFINE_STRUCT(type, name, default) type name;
typedef struct {
#undef WORKBENCH_CONFIG_DEFINE_STRUCT
#define CONFIG(FIELD)
Defines configuration fields and their default values using the X-macro technique.
Definition: workbench.h:248
Defines the structure for configuration settings.
Definition: workbench.h:287
#define WORKBENCH_CONFIG_DEFINE_STRUCT(type, field, default)
Macro to define a field in the configuration structure.
Definition: workbench_config.h:26

To generate setter functions for the configuration fields:

#define WORKBENCH_CONFIG_DEFINE_SETTERS(type, name, default) \
void set_##name(type value) { config.name = value; }
#undef WORKBENCH_CONFIG_DEFINE_SETTERS
#define WORKBENCH_CONFIG_DEFINE_SETTERS(type, field, default)
Macro to define setter function declarations for configuration fields.
Definition: workbench_config.h:59

◆ FLAGS

#define FLAGS (   FLAG)
Value:
FLAG(DISABLE_MIDI) \
FLAG(DISABLE_AUDIO) \
FLAG(DISABLE_MIDI_IN) \
FLAG(DISABLE_MIDI_OUT) \
FLAG(DISABLE_AUDIO_IN) \
FLAG(DISABLE_AUDIO_OUT)

Defines a list of feature flags and their bitwise representations.

The FLAGS macro is used to list various feature flags that can be enabled or disabled in the configuration. Each feature flag corresponds to a specific functionality (e.g., MIDI, audio) and has associated enable/disable options for input and output.

See also
ENUMERATE
DEFINE

Function Documentation

◆ config_get()

Config* config_get ( )

Retrieves the current configuration.

Returns
A pointer to the current configuration structure.

◆ config_init()

Config* config_init ( int  argc,
char **  argv,
AudioCallback  audio_cb,
MidiCallback  midi_cb,
void *  user_data 
)

Initializes the configuration with the specified audio and MIDI callbacks.

Parameters
audio_cbThe audio callback function.
midi_cbThe MIDI callback function.
user_dataA pointer to the cistom user data.
Returns
A pointer to the initialized configuration structure.

◆ get_log_level()

uint8_t get_log_level ( )

Retrieves the log level.

Log level determines the verbosity of the logging. The higher the value, the more verbose the logging:

  • 0: No logging
  • 1: Error logging
  • 2: Warning and Error logging
  • 3: Info, Warning, and Error logging
  • 4: Debug, Info, Warning, and Error logging
Returns
An integer value from zero to four.