Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
timeline_data_cache.h
1// SPDX-FileCopyrightText: © 2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "utils/types.h"
7#include "utils/units.h"
8
9#include "juce_wrapper.h"
10
11namespace zrythm::dsp
12{
13
22{
23public:
24 using IntervalType = std::pair<units::sample_t, units::sample_t>;
25
26 virtual ~TimelineDataCache ();
27
31 virtual void clear () = 0;
32
38 virtual void remove_sequences_matching_interval (IntervalType interval) = 0;
39
46 virtual void finalize_changes () = 0;
47
53 virtual bool has_content () const = 0;
54};
55
63{
64public:
72 IntervalType interval,
73 const juce::MidiMessageSequence &sequence);
74
80 const juce::MidiMessageSequence &get_midi_events () const
81 {
82 return merged_midi_events_;
83 }
84
85 // Implementation of base class methods
86 void clear () override;
87 void remove_sequences_matching_interval (IntervalType interval) override;
88 void finalize_changes () override;
89 bool has_content () const override;
90
91private:
98 std::map<IntervalType, juce::MidiMessageSequence> midi_sequences_;
99
106 juce::MidiMessageSequence merged_midi_events_;
107};
108
116{
117public:
126 {
128 juce::AudioSampleBuffer audio_buffer;
129
131 units::sample_t start_sample;
132
134 units::sample_t end_sample;
135 };
136
144 IntervalType interval,
145 const juce::AudioSampleBuffer &audio_buffer);
146
152 const std::vector<AudioRegionEntry> &get_audio_regions () const
153 {
154 return audio_regions_;
155 }
156
157 // Implementation of base class methods
158 void clear () override;
159 void remove_sequences_matching_interval (IntervalType interval) override;
160 void finalize_changes () override;
161 bool has_content () const override;
162
163private:
170 std::vector<AudioRegionEntry> audio_regions_;
171};
172
180{
181public:
190 {
192 std::vector<float> automation_values;
193
195 units::sample_t start_sample;
196
198 units::sample_t end_sample;
199 };
200
208 IntervalType interval,
209 const std::vector<float> &automation_values);
210
216 const std::vector<AutomationCacheEntry> &get_automation_sequences () const
217 {
218 return automation_sequences_;
219 }
220
221 // Implementation of base class methods
222 void clear () override;
223 void remove_sequences_matching_interval (IntervalType interval) override;
224 void finalize_changes () override;
225 bool has_content () const override;
226
227private:
234 std::vector<AutomationCacheEntry> automation_sequences_;
235};
236
237} // namespace zrythm::dsp
Audio-specific timeline data cache.
void add_audio_region(IntervalType interval, const juce::AudioSampleBuffer &audio_buffer)
Adds an audio region for the given interval.
void clear() override
Clears all cached data.
void remove_sequences_matching_interval(IntervalType interval) override
Removes cached data matching the given interval.
const std::vector< AudioRegionEntry > & get_audio_regions() const
Gets the cached audio regions.
bool has_content() const override
Checks if the cache has any content.
void finalize_changes() override
Finalizes changes and prepares cached data for access.
Automation-specific timeline data cache.
void add_automation_sequence(IntervalType interval, const std::vector< float > &automation_values)
Adds an automation sequence for the given interval.
void remove_sequences_matching_interval(IntervalType interval) override
Removes cached data matching the given interval.
bool has_content() const override
Checks if the cache has any content.
void clear() override
Clears all cached data.
void finalize_changes() override
Finalizes changes and prepares cached data for access.
const std::vector< AutomationCacheEntry > & get_automation_sequences() const
Gets the cached automation sequences.
MIDI-specific timeline data cache.
const juce::MidiMessageSequence & get_midi_events() const
Gets the cached MIDI events.
void add_midi_sequence(IntervalType interval, const juce::MidiMessageSequence &sequence)
Adds a MIDI sequence for the given interval.
void remove_sequences_matching_interval(IntervalType interval) override
Removes cached data matching the given interval.
bool has_content() const override
Checks if the cache has any content.
void finalize_changes() override
Finalizes changes and prepares cached data for access.
void clear() override
Clears all cached data.
Base class for timeline data caches.
virtual bool has_content() const =0
Checks if the cache has any content.
virtual void clear()=0
Clears all cached data.
virtual void remove_sequences_matching_interval(IntervalType interval)=0
Removes cached data matching the given interval.
virtual void finalize_changes()=0
Finalizes changes and prepares cached data for access.
units::sample_t end_sample
End position in samples.
juce::AudioSampleBuffer audio_buffer
Copy of the audio sample buffer.
units::sample_t start_sample
Start position in samples.
std::vector< float > automation_values
Automation values for the parameter.