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

An audio pool is a pool of audio files and their corresponding float arrays in memory that are referenced by regions. More...

#include <src/engine/session/pool.h>

Public Types

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

Public Member Functions

 AudioPool (ProjectPoolPathGetter path_getter, SampleRateGetter sr_getter)
 
void init_loaded ()
 Initializes the audio pool after deserialization.
 
void register_clip (std::shared_ptr< AudioClip > clip)
 Takes ownership of the given clip.
 
auto duplicate_clip (const AudioClip::Uuid &clip_id, bool write_file) -> AudioClip::Uuid
 Duplicates the clip with the given ID and returns the duplicate.
 
AudioClipget_clip (const AudioClip::Uuid &clip_id)
 Returns the clip for the given ID.
 
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.
 
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.
 
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).
 
void remove_unused (bool backup)
 Removes and frees (and removes the files for) all clips not used by the project or undo stacks.
 
void ensure_unique_clip_name (AudioClip &clip)
 Ensures that the name of the clip is unique.
 
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.
 
void print () 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

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 23 of file pool.h.

Member Typedef Documentation

◆ ProjectPoolPathGetter

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

Definition at line 26 of file pool.h.

Member Function Documentation

◆ duplicate_clip()

auto AudioPool::duplicate_clip ( const AudioClip::Uuid & clip_id,
bool write_file ) -> AudioClip::Uuid

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.

◆ ensure_unique_clip_name()

void AudioPool::ensure_unique_clip_name ( AudioClip & clip)

Ensures that the name of the clip is unique.

The clip must not be part of the pool yet.

If the clip name is not unique, it will be replaced by a unique name.

◆ get_clip_path()

fs::path AudioPool::get_clip_path ( const AudioClip & clip,
bool is_backup ) const

Gets the path of the given clip from the pool.

Parameters
is_backupWhether writing to a backup project.

◆ get_clip_path_from_name()

fs::path AudioPool::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.

Parameters
use_flacWhether to look for a FLAC file instead of a wav file.
is_backupWhether writing to a backup project.

◆ init_loaded()

void AudioPool::init_loaded ( )

Initializes the audio pool after deserialization.

Exceptions
ZrythmExceptionif an error occurred.

◆ register_clip()

void AudioPool::register_clip ( std::shared_ptr< AudioClip > clip)

Takes ownership of the given clip.

Changes the name of the clip if another clip with the same name already exists.

◆ reload_clip_frame_bufs()

void 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_clip()

void AudioPool::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).

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

◆ remove_unused()

void 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 AudioPool::write_clip ( AudioClip & clip,
bool parts,
bool backup )

Writes the clip to the pool as a wav file.

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

◆ write_to_disk()

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

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