Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
engine.h File Reference

The audio engine. More...

#include "zrythm-config.h"
#include "dsp/control_room.h"
#include "dsp/exporter.h"
#include "dsp/ext_port.h"
#include "dsp/hardware_processor.h"
#include "dsp/pan.h"
#include "dsp/pool.h"
#include "dsp/sample_processor.h"
#include "dsp/transport.h"
#include "utils/types.h"
#include "zix/sem.h"
Include dependency graph for engine.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  AudioEngineEvent
 Audio engine event. More...
 
struct  AudioEnginePositionInfo
 
struct  AudioEngine
 The audio engine. More...
 
struct  EngineState
 

Macros

#define BLOCK_LENGTH   4096
 
#define MIDI_BUF_SIZE   1024
 
#define MIDI_IN_NUM_EVENTS   AUDIO_ENGINE->midi_in->midi_events->num_events
 
#define AUDIO_ENGINE   (PROJECT->audio_engine)
 
#define MANUAL_PRESS_EVENTS    (AUDIO_ENGINE->midi_editor_manual_press->midi_events)
 
#define DENORMAL_PREVENTION_VAL(engine_)   (engine_->denormal_prevention_val)
 
#define engine_is_in_active_project(self)   (self->project == PROJECT)
 
#define engine_set_run(engine, _run)   g_atomic_int_set (&(engine)->run, _run)
 Set whether engine should process (true) or skip (false).
 
#define engine_get_run(engine)   g_atomic_int_get (&(engine)->run)
 
#define engine_has_handled_buffer_size_change(engine)    ((engine)->audio_backend != AudioBackend::AUDIO_BACKEND_JACK || ((engine)->audio_backend == AudioBackend::AUDIO_BACKEND_JACK && g_atomic_int_get (&(engine)->handled_jack_buffer_size_change) == 1))
 
#define ENGINE_MAX_EVENTS   100
 
#define engine_queue_push_back_event(q, x)   mpmc_queue_push_back (q, (void *) x)
 
#define engine_queue_dequeue_event(q, x)   mpmc_queue_dequeue (q, (void **) x)
 
#define ENGINE_EVENTS_PUSH(et, _arg, _uint_arg, _float_arg)
 Push events.
 
#define engine_is_port_own(self, port)
 Returns 1 if the port is an engine port or control room port, otherwise 0.
 

Typedefs

typedef struct WindowsMmeDevice WindowsMmeDevice
 

Enumerations

enum class  AudioEngineEventType { AUDIO_ENGINE_EVENT_BUFFER_SIZE_CHANGE , AUDIO_ENGINE_EVENT_SAMPLE_RATE_CHANGE }
 Audio engine event type. More...
 
enum class  AudioEngineBufferSize {
  AUDIO_ENGINE_BUFFER_SIZE_16 , AUDIO_ENGINE_BUFFER_SIZE_32 , AUDIO_ENGINE_BUFFER_SIZE_64 , AUDIO_ENGINE_BUFFER_SIZE_128 ,
  AUDIO_ENGINE_BUFFER_SIZE_256 , AUDIO_ENGINE_BUFFER_SIZE_512 , AUDIO_ENGINE_BUFFER_SIZE_1024 , AUDIO_ENGINE_BUFFER_SIZE_2048 ,
  AUDIO_ENGINE_BUFFER_SIZE_4096
}
 Buffer sizes to be used in combo boxes. More...
 
enum class  AudioEngineSamplerate {
  AUDIO_ENGINE_SAMPLERATE_22050 , AUDIO_ENGINE_SAMPLERATE_32000 , AUDIO_ENGINE_SAMPLERATE_44100 , AUDIO_ENGINE_SAMPLERATE_48000 ,
  AUDIO_ENGINE_SAMPLERATE_88200 , AUDIO_ENGINE_SAMPLERATE_96000 , AUDIO_ENGINE_SAMPLERATE_192000
}
 Samplerates to be used in comboboxes. More...
 
enum class  AudioBackend {
  AUDIO_BACKEND_DUMMY , AUDIO_BACKEND_DUMMY_LIBSOUNDIO , AUDIO_BACKEND_ALSA , AUDIO_BACKEND_ALSA_LIBSOUNDIO ,
  AUDIO_BACKEND_ALSA_RTAUDIO , AUDIO_BACKEND_JACK , AUDIO_BACKEND_JACK_LIBSOUNDIO , AUDIO_BACKEND_JACK_RTAUDIO ,
  AUDIO_BACKEND_PULSEAUDIO , AUDIO_BACKEND_PULSEAUDIO_LIBSOUNDIO , AUDIO_BACKEND_PULSEAUDIO_RTAUDIO , AUDIO_BACKEND_COREAUDIO_LIBSOUNDIO ,
  AUDIO_BACKEND_COREAUDIO_RTAUDIO , AUDIO_BACKEND_SDL , AUDIO_BACKEND_WASAPI_LIBSOUNDIO , AUDIO_BACKEND_WASAPI_RTAUDIO ,
  AUDIO_BACKEND_ASIO_RTAUDIO
}
 
enum class  BounceMode { BounceMode::BOUNCE_OFF , BounceMode::BOUNCE_ON , BounceMode::BOUNCE_INHERIT }
 Mode used when bouncing, either during exporting or when bouncing tracks or regions to audio. More...
 
enum class  MidiBackend {
  MIDI_BACKEND_DUMMY , MIDI_BACKEND_ALSA , MIDI_BACKEND_ALSA_RTMIDI , MIDI_BACKEND_JACK ,
  MIDI_BACKEND_JACK_RTMIDI , MIDI_BACKEND_WINDOWS_MME , MIDI_BACKEND_WINDOWS_MME_RTMIDI , MIDI_BACKEND_COREMIDI_RTMIDI ,
  MIDI_BACKEND_WINDOWS_UWP_RTMIDI
}
 
enum class  AudioEngineJackTransportType { AUDIO_ENGINE_JACK_TIMEBASE_MASTER , AUDIO_ENGINE_JACK_TRANSPORT_CLIENT , AUDIO_ENGINE_NO_JACK_TRANSPORT }
 

Functions

 __attribute__ ((unused)) static const char *audio_backend_str[]
 
void engine_realloc_port_buffers (AudioEngine *self, nframes_t buf_size)
 
COLD NONNULL_ARGS (1) void automation_tracklist_init_loaded(AutomationTracklist *self
 Inits a loaded AutomationTracklist.
 
COLD WARN_UNUSED_RESULT AudioEngineengine_new (Project *project)
 Create a new audio engine.
 
void engine_wait_for_pause (AudioEngine *self, EngineState *state, bool force_pause, bool with_fadeout)
 
void engine_resume (AudioEngine *self, EngineState *state)
 
void engine_wait_n_cycles (AudioEngine *self, int n)
 Waits for n processing cycles to finish.
 
void engine_append_ports (AudioEngine *self, GPtrArray *ports)
 
void engine_pre_setup (AudioEngine *self)
 Sets up the audio engine before the project is initialized/loaded.
 
void engine_setup (AudioEngine *self)
 Sets up the audio engine after the project is initialized/loaded.
 
COLD void engine_activate (AudioEngine *self, bool activate)
 Activates the audio engine to start processing and receiving events.
 
void engine_update_frames_per_tick (AudioEngine *self, const int beats_per_bar, const bpm_t bpm, const sample_rate_t sample_rate, bool thread_check, bool update_from_ticks, bool bpm_change)
 Updates frames per tick based on the time sig, the BPM, and the sample rate.
 
int engine_process_events (AudioEngine *self)
 GSourceFunc to be added using idle add.
 
NONNULL HOT bool engine_process_prepare (AudioEngine *self, nframes_t nframes)
 To be called by each implementation to prepare the structures before processing.
 
NONNULL HOT int engine_process (AudioEngine *self, const nframes_t total_frames_to_process)
 Processes current cycle.
 
NONNULL HOT void engine_post_process (AudioEngine *self, const nframes_t roll_nframes, const nframes_t nframes)
 To be called after processing for common logic.
 
NONNULL void engine_fill_out_bufs (AudioEngine *self, const nframes_t nframes)
 Called to fill in the external buffers at the end of the processing cycle.
 
int engine_buffer_size_enum_to_int (AudioEngineBufferSize buffer_size)
 Returns the int value corresponding to the given AudioEngineBufferSize.
 
int engine_samplerate_enum_to_int (AudioEngineSamplerate samplerate)
 Returns the int value corresponding to the given AudioEngineSamplerate.
 
void engine_set_buffer_size (AudioEngine *self, uint32_t buf_size)
 Request the backend to set the buffer size.
 
const char * engine_audio_backend_to_string (AudioBackend backend)
 Returns the audio backend as a string.
 
AudioBackend engine_audio_backend_from_string (const char *str)
 
MidiBackend engine_midi_backend_from_string (const char *str)
 
void engine_reset_bounce_mode (AudioEngine *self)
 Reset the bounce mode on the engine, all tracks and regions to OFF.
 
void engine_set_default_backends (bool reset_to_dummy)
 Detects the best backends on the system and sets them to GSettings.
 
COLD NONNULL AudioEngineengine_clone (const AudioEngine *src)
 Clones the audio engine.
 
COLD NONNULL void engine_free (AudioEngine *self)
 Closes any connections and free's data.
 

Variables

COLD Projectproject
 
COLD Project GError ** error
 

Detailed Description

The audio engine.

Definition in file engine.h.

Typedef Documentation

◆ WindowsMmeDevice

typedef struct WindowsMmeDevice WindowsMmeDevice

Definition at line 59 of file engine.h.