6#include "dsp/file_audio_source.h"
8#include "utils/units.h"
10#include <boost/unordered/concurrent_flat_map.hpp>
35 std::function<std::filesystem::path (
bool backup)>;
36 using SampleRateGetter = std::function<units::sample_rate_t ()>;
41 SampleRateGetter sr_getter);
60 -> FileAudioSourceUuidReference;
67 [[nodiscard]] std::filesystem::path
68 get_clip_path (
const dsp::FileAudioSource::Uuid &
id,
bool is_backup)
const;
116 friend void init_from (
118 const AudioPool &other,
121 friend void to_json (nlohmann::json &j,
const AudioPool &pool);
122 friend void from_json (
const nlohmann::json &j, AudioPool &pool);
125 SampleRateGetter sample_rate_getter_;
135 boost::unordered::concurrent_flat_map<FileAudioSource::Uuid, utils::hash::HashT>
136 last_known_file_hashes_;
142struct fmt::formatter<zrythm::dsp::AudioPool> : fmt::formatter<std::string_view>
144 template <
typename FormatContext>
147 std::stringstream ss;
148 ss <<
"\nAudio Pool:\n";
149 pool.for_each_clip ([&] (
const auto &clip) {
150 auto pool_path = pool.
get_clip_path (clip.get_uuid (),
false);
152 "[Clip {}] {}: {}\n", clip.get_uuid (), clip.get_name (), pool_path);
155 return fmt::formatter<std::string_view>::format (
156 fmt::format (
"{}", ss.str ()), ctx);
Audio clips for the pool.
Abstract interface for a UUID-keyed object registry.
A manager for a registry of FileAudioSource inside a project.
std::filesystem::path get_clip_path(const dsp::FileAudioSource::Uuid &id, bool is_backup) const
Gets the path of a clip matching name from the pool.
std::function< std::filesystem::path(bool backup)> ProjectPoolPathGetter
Returns a path that will be used to manage audio files in.
void remove_unused(bool backup)
Removes and frees (and removes the files for) all clips not used by the project or undo stacks.
void init_loaded()
Initializes the audio pool after deserialization.
void write_to_disk(bool is_backup)
Writes all the clips to disk.
auto duplicate_clip(const FileAudioSource::Uuid &clip_id, bool write_file) -> FileAudioSourceUuidReference
Duplicates the clip with the given ID and returns the duplicate.
void write_clip(const FileAudioSource *clip, bool parts, bool backup)
Writes the clip to the pool as a wav file.
void reload_clip_frame_bufs()
Loads the frame buffers of clips currently in use in the project from their files and frees the buffe...