Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
|
Audio clips for the pool. More...
#include <src/engine/session/clip.h>
Public Types | |
using | BitDepth = zrythm::utils::audio::BitDepth |
using | AudioFile = zrythm::utils::audio::AudioFile |
Public Member Functions | |
AudioClip (const fs::path &full_path, sample_rate_t project_sample_rate, bpm_t current_bpm) | |
Creates an audio clip from a file. | |
AudioClip (const utils::audio::AudioBuffer &buf, utils::audio::BitDepth bit_depth, sample_rate_t project_sample_rate, bpm_t current_bpm, const utils::Utf8String &name) | |
Creates an audio clip by copying the given buffer. | |
AudioClip (const float *arr, unsigned_frame_t nframes, channels_t channels, zrythm::utils::audio::BitDepth bit_depth, sample_rate_t project_sample_rate, bpm_t current_bpm, const utils::Utf8String &name) | |
Creates an audio clip by copying the given interleaved float array. | |
AudioClip (channels_t channels, unsigned_frame_t nframes, sample_rate_t project_sample_rate, bpm_t current_bpm, const utils::Utf8String &name) | |
Create an audio clip while recording. | |
void | init_loaded (const fs::path &full_path) |
Inits after loading a Project. | |
std::unique_ptr< AudioClip > | edit_in_ext_program () |
Shows a dialog with info on how to edit a file, with an option to open an app launcher. | |
void | write_to_file (const fs::path &filepath, bool parts) |
Writes the given audio clip data to a file. | |
auto | get_bit_depth () const |
auto | get_name () const |
auto | get_file_hash () const |
auto | get_bpm () const |
const auto & | get_samples () const |
auto | get_last_write_to_file () const |
auto | get_use_flac () const |
void | set_name (const utils::Utf8String &name) |
void | set_file_hash (utils::hash::HashT hash) |
void | expand_with_frames (const utils::audio::AudioBuffer &frames) |
Expands (appends to the end) the frames in the clip by the given frames. | |
void | replace_frames (const utils::audio::AudioBuffer &src_frames, unsigned_frame_t start_frame) |
Replaces the clip's frames starting from start_frame with frames . | |
void | replace_frames_from_interleaved (const float *frames, unsigned_frame_t start_frame, unsigned_frame_t num_frames_per_channel, channels_t channels) |
Replaces the clip's frames starting from start_frame with frames . | |
void | clear_frames () |
Unloads the clip's frames from memory. | |
auto | get_num_channels () const |
auto | get_num_frames () const |
void | finalize_buffered_write () |
Finalizes buffered write to a file (when parts is true in write_to_file()). | |
bool | verify_recorded_file (const fs::path &filepath, sample_rate_t project_sample_rate, bpm_t current_bpm) const |
Used during tests to verify that the recorded file is valid. | |
bool | enough_time_elapsed_since_last_write () const |
Returns whether enough time has elapsed since the last write to file. | |
![]() | |
UuidIdentifiableObject (const Uuid &id) | |
UuidIdentifiableObject (const UuidIdentifiableObject &other)=default | |
UuidIdentifiableObject (UuidIdentifiableObject &&other)=default | |
UuidIdentifiableObject & | operator= (const UuidIdentifiableObject &other)=default |
UuidIdentifiableObject & | operator= (UuidIdentifiableObject &&other)=default |
auto | get_uuid () const |
Static Public Member Functions | |
static bool | should_use_flac (zrythm::utils::audio::BitDepth bd) |
Friends | |
void | init_from (AudioClip &obj, const AudioClip &other, utils::ObjectCloneType clone_type) |
void | to_json (nlohmann::json &j, const AudioClip &clip) |
void | from_json (const nlohmann::json &j, AudioClip &clip) |
Audio clips for the pool.
These should be loaded in the project's sample rate.
AudioClip::AudioClip | ( | const fs::path & | full_path, |
sample_rate_t | project_sample_rate, | ||
bpm_t | current_bpm ) |
Creates an audio clip from a file.
The basename of the file will be used as the name of the clip.
current_bpm | Current BPM from TempoTrack. bpm_ will be set to this. FIXME: should this be optional? does "current" BPM make sense? |
ZrythmException | on error. |
AudioClip::AudioClip | ( | const utils::audio::AudioBuffer & | buf, |
utils::audio::BitDepth | bit_depth, | ||
sample_rate_t | project_sample_rate, | ||
bpm_t | current_bpm, | ||
const utils::Utf8String & | name ) |
Creates an audio clip by copying the given buffer.
buf | Buffer to copy. |
name | A name for this clip. |
|
inline |
AudioClip::AudioClip | ( | channels_t | channels, |
unsigned_frame_t | nframes, | ||
sample_rate_t | project_sample_rate, | ||
bpm_t | current_bpm, | ||
const utils::Utf8String & | name ) |
Create an audio clip while recording.
The frames will keep getting reallocated until the recording is finished.
nframes | Number of frames to allocate. This should be the current cycle's frames when called during recording. |
|
inline |
std::unique_ptr< AudioClip > AudioClip::edit_in_ext_program | ( | ) |
Shows a dialog with info on how to edit a file, with an option to open an app launcher.
When the user closes the dialog, the clip is assumed to have been edited.
The given audio clip will be free'd.
ZrythmException | on error. |
bool AudioClip::enough_time_elapsed_since_last_write | ( | ) | const |
Returns whether enough time has elapsed since the last write to file.
This is used so that writing to file is done in chunks.
void AudioClip::expand_with_frames | ( | const utils::audio::AudioBuffer & | frames | ) |
Expands (appends to the end) the frames in the clip by the given frames.
frames | Non-interleaved frames. |
void AudioClip::init_loaded | ( | const fs::path & | full_path | ) |
Inits after loading a Project.
full_path | Full path to the corresponding audio file in the pool. |
ZrythmException | on error. |
void AudioClip::replace_frames | ( | const utils::audio::AudioBuffer & | src_frames, |
unsigned_frame_t | start_frame ) |
Replaces the clip's frames starting from start_frame
with frames
.
src_frames | Frames to copy. |
start_frame | Frame to start copying to (src_frames are always copied from the start). |
void AudioClip::replace_frames_from_interleaved | ( | const float * | frames, |
unsigned_frame_t | start_frame, | ||
unsigned_frame_t | num_frames_per_channel, | ||
channels_t | channels ) |
Replaces the clip's frames starting from start_frame
with frames
.
frames | Frames, interleaved. |
start_frame | Frame to start copying to (src_frames are always copied from the start). |
|
inline |
|
inline |
|
inlinestatic |
bool AudioClip::verify_recorded_file | ( | const fs::path & | filepath, |
sample_rate_t | project_sample_rate, | ||
bpm_t | current_bpm ) const |
Used during tests to verify that the recorded file is valid.
current_bpm | Current BPM from TempoTrack, used when creating a temporary clip from the filepath. |
void AudioClip::write_to_file | ( | const fs::path & | filepath, |
bool | parts ) |
Writes the given audio clip data to a file.
parts | If true, only write new data. |
ZrythmException | on error. |
|
friend |
|
friend |