Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
|
A manager for a registry of FileAudioSource inside a project. More...
#include <src/dsp/audio_pool.h>
Public Types | |
using | ProjectPoolPathGetter = std::function<fs::path (bool backup)> |
Returns a path that will be used to manage audio files in. |
Public Member Functions | |
AudioPool (dsp::FileAudioSourceRegistry &file_audio_source_registry, ProjectPoolPathGetter path_getter, SampleRateGetter sr_getter) | |
void | init_loaded () |
Initializes the audio pool after deserialization. | |
auto | duplicate_clip (const FileAudioSource::Uuid &clip_id, bool write_file) -> FileAudioSourceUuidReference |
Duplicates the clip with the given ID and returns the duplicate. | |
fs::path | get_clip_path (const dsp::FileAudioSource::Uuid &id, bool is_backup) const |
Gets the path of a clip matching name from the pool. | |
void | write_clip (const FileAudioSource::Uuid &clip_id, bool parts, bool backup) |
Writes the clip to the pool as a wav file. | |
void | remove_unused (bool backup) |
Removes and frees (and removes the files for) all clips not used by the project or undo stacks. | |
void | reload_clip_frame_bufs () |
Loads the frame buffers of clips currently in use in the project from their files and frees the buffers of clips not currently in use. | |
void | write_to_disk (bool is_backup) |
Writes all the clips to disk. | |
auto | get_clip_ptrs () const |
Friends | |
void | init_from (AudioPool &obj, const AudioPool &other, utils::ObjectCloneType clone_type) |
void | to_json (nlohmann::json &j, const AudioPool &pool) |
void | from_json (const nlohmann::json &j, AudioPool &pool) |
A manager for a registry of FileAudioSource inside a project.
An audio pool is a pool of audio files and their corresponding float arrays in memory that are referenced by regions.
Instead of associating audio files with regions, all audio files (and their edited counterparts after some hard editing like stretching) are saved in the pool.
Definition at line 25 of file audio_pool.h.
using zrythm::dsp::AudioPool::ProjectPoolPathGetter = std::function<fs::path (bool backup)> |
Returns a path that will be used to manage audio files in.
backup | Whether this path is for a backup project (as opposed to the main project). |
Definition at line 34 of file audio_pool.h.
auto zrythm::dsp::AudioPool::duplicate_clip | ( | const FileAudioSource::Uuid & | clip_id, |
bool | write_file ) -> FileAudioSourceUuidReference |
Duplicates the clip with the given ID and returns the duplicate.
write_file | Whether to also write the file. |
ZrythmException | If the file could not be written. |
|
nodiscard |
Gets the path of a clip matching name from the pool.
is_backup | Whether writing to a backup project. |
|
inline |
Definition at line 125 of file audio_pool.h.
void zrythm::dsp::AudioPool::init_loaded | ( | ) |
Initializes the audio pool after deserialization.
ZrythmException | if an error occurred. |
void zrythm::dsp::AudioPool::reload_clip_frame_bufs | ( | ) |
Loads the frame buffers of clips currently in use in the project from their files and frees the buffers of clips not currently in use.
This should be called whenever there is a relevant change in the project (eg, object added/removed).
ZrythmException | If any file could not be read. |
void zrythm::dsp::AudioPool::remove_unused | ( | bool | backup | ) |
Removes and frees (and removes the files for) all clips not used by the project or undo stacks.
backup | Whether to remove from backup directory. |
ZrythmException | If any file could not be removed. |
void zrythm::dsp::AudioPool::write_clip | ( | const FileAudioSource::Uuid & | clip_id, |
bool | parts, | ||
bool | backup ) |
Writes the clip to the pool as a wav file.
parts | If true, only write new data. |
backup | Whether writing to a backup project. |
ZrythmException | on error. |
void zrythm::dsp::AudioPool::write_to_disk | ( | bool | is_backup | ) |
Writes all the clips to disk.
Used when saving a project elsewhere.
is_backup | Whether this is a backup project. |
ZrythmException | If any file could not be written. |
|
friend |
Definition at line 145 of file audio_pool.h.
|
friend |
Definition at line 141 of file audio_pool.h.