Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
zrythm::dsp::AudioPool Struct Referencefinal

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)

Detailed Description

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.

Member Typedef Documentation

◆ ProjectPoolPathGetter

using zrythm::dsp::AudioPool::ProjectPoolPathGetter = std::function<fs::path (bool backup)>

Returns a path that will be used to manage audio files in.

Parameters
backupWhether this path is for a backup project (as opposed to the main project).

Definition at line 34 of file audio_pool.h.

Member Function Documentation

◆ duplicate_clip()

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.

Parameters
write_fileWhether to also write the file.
Returns
The ID in the pool.
Exceptions
ZrythmExceptionIf the file could not be written.

◆ get_clip_path()

fs::path zrythm::dsp::AudioPool::get_clip_path ( const dsp::FileAudioSource::Uuid & id,
bool is_backup ) const
nodiscard

Gets the path of a clip matching name from the pool.

Parameters
is_backupWhether writing to a backup project.

◆ get_clip_ptrs()

auto zrythm::dsp::AudioPool::get_clip_ptrs ( ) const
inline

Definition at line 125 of file audio_pool.h.

◆ init_loaded()

void zrythm::dsp::AudioPool::init_loaded ( )

Initializes the audio pool after deserialization.

Exceptions
ZrythmExceptionif an error occurred.

◆ reload_clip_frame_bufs()

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).

Exceptions
ZrythmExceptionIf any file could not be read.

◆ remove_unused()

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.

Parameters
backupWhether to remove from backup directory.
Exceptions
ZrythmExceptionIf any file could not be removed.

◆ write_clip()

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.

Parameters
partsIf true, only write new data.
See also
FileAudioSource.frames_written.
Parameters
backupWhether writing to a backup project.
Exceptions
ZrythmExceptionon error.

◆ write_to_disk()

void zrythm::dsp::AudioPool::write_to_disk ( bool is_backup)

Writes all the clips to disk.

Used when saving a project elsewhere.

Parameters
is_backupWhether this is a backup project.
Exceptions
ZrythmExceptionIf any file could not be written.

◆ from_json

void from_json ( const nlohmann::json & j,
AudioPool & pool )
friend

Definition at line 145 of file audio_pool.h.

◆ to_json

void to_json ( nlohmann::json & j,
const AudioPool & pool )
friend

Definition at line 141 of file audio_pool.h.


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