6#include "engine/session/clip.h"
7#include "utils/types.h"
26 using ProjectPoolPathGetter = std::function<fs::path (
bool backup)>;
28 AudioPool (ProjectPoolPathGetter path_getter, SampleRateGetter sr_getter);
72 bool is_backup)
const;
99 const AudioClip::Uuid &clip_id,
100 bool free_and_remove_file,
145 friend void init_from (
147 const AudioPool &other,
151 static constexpr auto kClipsKey =
"clips"sv;
152 friend void to_json (nlohmann::json &j,
const AudioPool &pool);
153 friend void from_json (
const nlohmann::json &j, AudioPool &pool);
158 SampleRateGetter sample_rate_getter_;
159 ProjectPoolPathGetter project_pool_path_getter_;
164 QHash<AudioClip::Uuid, std::shared_ptr<AudioClip>> clips_;
Audio clips for the pool.
Lightweight UTF-8 string wrapper with safe conversions.
AudioClip * get_clip(const AudioClip::Uuid &clip_id)
Returns the clip for the given ID.
fs::path get_clip_path(const AudioClip &clip, bool is_backup) const
Gets the path of the given clip from the pool.
void write_clip(AudioClip &clip, bool parts, bool backup)
Writes the clip to the pool as a wav file.
auto duplicate_clip(const AudioClip::Uuid &clip_id, bool write_file) -> AudioClip::Uuid
Duplicates the clip with the given ID and returns the duplicate.
void reload_clip_frame_bufs()
Loads the frame buffers of clips currently in use in the project from their files and frees the buffe...
void write_to_disk(bool is_backup)
Writes all the clips to disk.
void register_clip(std::shared_ptr< AudioClip > clip)
Takes ownership of the given clip.
fs::path get_clip_path_from_name(const utils::Utf8String &name, bool use_flac, bool is_backup) const
Gets the path of a clip matching name from the pool.
void init_loaded()
Initializes the audio pool after deserialization.
void ensure_unique_clip_name(AudioClip &clip)
Ensures that the name of the clip is unique.
void remove_unused(bool backup)
Removes and frees (and removes the files for) all clips not used by the project or undo stacks.
void remove_clip(const AudioClip::Uuid &clip_id, bool free_and_remove_file, bool backup)
Removes the clip with the given ID from the pool and optionally frees it (and removes the file).