Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
zrythm::structure::arrangement::RegionRenderer Class Referencefinal

A class that converts region data to serialized formats. More...

#include <src/structure/arrangement/region_renderer.h>

Static Public Member Functions

static void serialize_to_sequence (const MidiRegion &region, juce::MidiMessageSequence &events, std::optional< std::pair< double, double > > timeline_range_ticks=std::nullopt)
 Serializes a MIDI region to a MIDI message sequence.
static void serialize_to_sequence (const ChordRegion &region, juce::MidiMessageSequence &events, std::optional< std::pair< double, double > > timeline_range_ticks=std::nullopt)
 Serializes a Chord region to a MIDI message sequence.
static void serialize_to_buffer (const AudioRegion &region, juce::AudioSampleBuffer &buffer, std::optional< std::pair< double, double > > timeline_range_ticks=std::nullopt)
 Serializes an Audio region to an audio sample buffer.
static void serialize_to_automation_values (const AutomationRegion &region, std::vector< float > &values, std::optional< std::pair< double, double > > timeline_range_ticks=std::nullopt)
 Serializes an Automation region to sample-accurate automation values.

Detailed Description

A class that converts region data to serialized formats.

This class provides methods to serialize both MIDI and Audio regions, handling looped playback and various constraints.

Definition at line 20 of file region_renderer.h.

Member Function Documentation

◆ serialize_to_automation_values()

void zrythm::structure::arrangement::RegionRenderer::serialize_to_automation_values ( const AutomationRegion & region,
std::vector< float > & values,
std::optional< std::pair< double, double > > timeline_range_ticks = std::nullopt )
static

Serializes an Automation region to sample-accurate automation values.

The output buffer always represents the full region length, with index 0 corresponding to the region's start position. Automation point positions are relative to the region start.

Values between automation points are interpolated using the curve algorithm defined on each automation point. The last automation point fills all remaining samples with its value.

Playback behavior:

  • Starts from clip start (position 0 in output buffer)
  • Plays until loop end, then loops back to loop start
  • Automation points before loop start appear only once
  • Automation points within loop range (loop_start to loop_end) appear in each loop iteration

Constraints (start/end) are global timeline positions and are applied by setting values outside the constraint range to -1.0. The output buffer size is always the full region length, regardless of constraints.

Parameters
regionThe Automation region to serialize
[out]valuesOutput vector of normalized automation values (sample-accurate). Values are resized to the full region length. Negative values (-1.0) indicate no automation present.
startOptional global timeline start position in ticks for constraints
endOptional global timeline end position in ticks for constraints

◆ serialize_to_buffer()

void zrythm::structure::arrangement::RegionRenderer::serialize_to_buffer ( const AudioRegion & region,
juce::AudioSampleBuffer & buffer,
std::optional< std::pair< double, double > > timeline_range_ticks = std::nullopt )
static

Serializes an Audio region to an audio sample buffer.

Audio regions are always serialized as they would be played in the timeline (with loops and clip start). The buffer always starts at the region's audio data without any leading silence.

Parameters
regionThe Audio region to serialize
bufferOutput audio sample buffer
startOptional timeline start position in ticks
endOptional timeline end position in ticks
builtin_fade_framesNumber of frames to use for built-in fades

◆ serialize_to_sequence() [1/2]

void zrythm::structure::arrangement::RegionRenderer::serialize_to_sequence ( const ChordRegion & region,
juce::MidiMessageSequence & events,
std::optional< std::pair< double, double > > timeline_range_ticks = std::nullopt )
static

Serializes a Chord region to a MIDI message sequence.

Note
Event timings will be set in ticks.
Parameters
regionThe Chord region to serialize
eventsOutput MIDI message sequence
startOptional timeline start position in ticks
endOptional timeline end position in ticks
add_region_startAdd region start offset to positions
as_playedSerialize as it would be played in the timeline (with loops and clip start)

◆ serialize_to_sequence() [2/2]

void zrythm::structure::arrangement::RegionRenderer::serialize_to_sequence ( const MidiRegion & region,
juce::MidiMessageSequence & events,
std::optional< std::pair< double, double > > timeline_range_ticks = std::nullopt )
static

Serializes a MIDI region to a MIDI message sequence.

Note
Event timings will be set in ticks.
Parameters
regionThe MIDI region to serialize
eventsOutput MIDI message sequence
startOptional timeline start position in ticks
endOptional timeline end position in ticks
add_region_startAdd region start offset to positions (false)
as_playedSerialize as it would be played in the timeline (with loops and clip start) (true)

The documentation for this class was generated from the following file: