Zrythm v2.0.0-alpha.1
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
zrythm::dsp::FileAudioSource Class Referencefinal

Audio clips for the pool. More...

#include <src/dsp/file_audio_source.h>

Inheritance diagram for zrythm::dsp::FileAudioSource:
Collaboration diagram for zrythm::dsp::FileAudioSource:

Public Types

using BitDepth = zrythm::utils::audio::BitDepth
using AudioFile = zrythm::utils::audio::AudioFile
using channels_t = uint_fast8_t
Public Types inherited from zrythm::utils::UuidIdentifiableObject< FileAudioSource >
using uuid_base_type
 Exposes the CRTP parameter for concept checking.

Public Member Functions

 FileAudioSource (QObject *parent=nullptr)
 FileAudioSource (const std::filesystem::path &full_path, units::sample_rate_t project_sample_rate, QObject *parent=nullptr)
 Creates an audio clip from a file.
 FileAudioSource (const utils::audio::AudioBuffer &buf, utils::audio::BitDepth bit_depth, units::sample_rate_t project_sample_rate, units::bpm_t source_bpm, const utils::Utf8String &name, QObject *parent=nullptr)
 Creates an audio clip by copying the given buffer.
 FileAudioSource (const float *arr, units::sample_u64_t nframes, channels_t channels, zrythm::utils::audio::BitDepth bit_depth, units::sample_rate_t project_sample_rate, units::bpm_t source_bpm, const utils::Utf8String &name, QObject *parent=nullptr)
 Creates an audio clip by copying the given interleaved float array.
Q_SIGNAL void samplesChanged ()
 Emitted when the source samples change.
auto get_bit_depth () const
auto get_name () const
auto source_bpm () const
 The clip's permanent source BPM (its intrinsic musical tempo).
const auto & get_samples () const
auto get_samplerate () const
void set_name (const utils::Utf8String &name)
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, units::sample_u64_t start_frame)
 Replaces the clip's frames starting from start_frame with frames.
void replace_frames_from_interleaved (const float *frames, units::sample_u64_t start_frame, units::sample_u64_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 init_from_file (const std::filesystem::path &full_path, units::sample_rate_t project_sample_rate, std::optional< units::bpm_t > bpm_to_set)
 Initializes members from an audio file.
Public Member Functions inherited from zrythm::utils::UuidIdentifiableObject< FileAudioSource >
 UuidIdentifiableObject (QObject *parent=nullptr)
auto get_uuid () const
Public Member Functions inherited from zrythm::utils::UuidIdentifiableBase
 UuidIdentifiableBase (QObject *parent=nullptr)
 UuidIdentifiableBase (const QUuid &id, QObject *parent=nullptr)
QUuid raw_uuid () const

Friends

void init_from (FileAudioSource &obj, const FileAudioSource &other, utils::ObjectCloneType clone_type)
void to_json (nlohmann::json &j, const FileAudioSource &clip)
void from_json (const nlohmann::json &j, FileAudioSource &clip)

Additional Inherited Members

Protected Member Functions inherited from zrythm::utils::UuidIdentifiableBase
void set_raw_uuid (const QUuid &id)

Detailed Description

Audio clips for the pool.

These should be loaded in the project's sample rate.

Definition at line 25 of file file_audio_source.h.

Member Typedef Documentation

◆ AudioFile

using zrythm::dsp::FileAudioSource::AudioFile = zrythm::utils::audio::AudioFile

Definition at line 32 of file file_audio_source.h.

◆ BitDepth

using zrythm::dsp::FileAudioSource::BitDepth = zrythm::utils::audio::BitDepth

Definition at line 31 of file file_audio_source.h.

◆ channels_t

using zrythm::dsp::FileAudioSource::channels_t = uint_fast8_t

Definition at line 33 of file file_audio_source.h.

Constructor & Destructor Documentation

◆ FileAudioSource() [1/3]

zrythm::dsp::FileAudioSource::FileAudioSource ( const std::filesystem::path & full_path,
units::sample_rate_t project_sample_rate,
QObject * parent = nullptr )

Creates an audio clip from a file.

The clip's source BPM (bpm_) is read from the file's metadata; if the file carries no BPM metadata it is left as 0 (unknown) and musical mode cannot be applied until the BPM is supplied. The basename of the file is used as the clip name.

Exceptions
ZrythmExceptionon error.

◆ FileAudioSource() [2/3]

zrythm::dsp::FileAudioSource::FileAudioSource ( const utils::audio::AudioBuffer & buf,
utils::audio::BitDepth bit_depth,
units::sample_rate_t project_sample_rate,
units::bpm_t source_bpm,
const utils::Utf8String & name,
QObject * parent = nullptr )

Creates an audio clip by copying the given buffer.

Parameters
source_bpmThe clip's permanent source BPM. For material captured in-project (e.g. recording) this is the project tempo at capture time; for duplicated clips, the original's BPM.
nameA name for this clip.

◆ FileAudioSource() [3/3]

zrythm::dsp::FileAudioSource::FileAudioSource ( const float * arr,
units::sample_u64_t nframes,
channels_t channels,
zrythm::utils::audio::BitDepth bit_depth,
units::sample_rate_t project_sample_rate,
units::bpm_t source_bpm,
const utils::Utf8String & name,
QObject * parent = nullptr )
inline

Creates an audio clip by copying the given interleaved float array.

Parameters
arrInterleaved array.
nframesNumber of frames per channel.
channelsNumber of channels.
nameA name for this clip.

Definition at line 77 of file file_audio_source.h.

Member Function Documentation

◆ clear_frames()

void zrythm::dsp::FileAudioSource::clear_frames ( )
inline

Unloads the clip's frames from memory.

Definition at line 163 of file file_audio_source.h.

◆ expand_with_frames()

void zrythm::dsp::FileAudioSource::expand_with_frames ( const utils::audio::AudioBuffer & frames)

Expands (appends to the end) the frames in the clip by the given frames.

Parameters
framesNon-interleaved frames.

◆ get_bit_depth()

auto zrythm::dsp::FileAudioSource::get_bit_depth ( ) const
inline

Definition at line 108 of file file_audio_source.h.

◆ get_name()

auto zrythm::dsp::FileAudioSource::get_name ( ) const
inline

Definition at line 109 of file file_audio_source.h.

◆ get_num_channels()

auto zrythm::dsp::FileAudioSource::get_num_channels ( ) const
inline

Definition at line 169 of file file_audio_source.h.

◆ get_num_frames()

auto zrythm::dsp::FileAudioSource::get_num_frames ( ) const
inline

Definition at line 170 of file file_audio_source.h.

◆ get_samplerate()

auto zrythm::dsp::FileAudioSource::get_samplerate ( ) const
inline

Definition at line 120 of file file_audio_source.h.

◆ get_samples()

const auto & zrythm::dsp::FileAudioSource::get_samples ( ) const
inline

Definition at line 119 of file file_audio_source.h.

◆ init_from_file()

void zrythm::dsp::FileAudioSource::init_from_file ( const std::filesystem::path & full_path,
units::sample_rate_t project_sample_rate,
std::optional< units::bpm_t > bpm_to_set )

Initializes members from an audio file.

Parameters
full_pathPath to the file.
bpm_to_setOptional source BPM to use instead of the file's metadata BPM. Used when reloading a project to preserve the previously stored value. If nullopt (or <= 0), the BPM read from file metadata is kept (0 if the file carries none).
Exceptions
ZrythmExceptionon I/O error.

◆ replace_frames()

void zrythm::dsp::FileAudioSource::replace_frames ( const utils::audio::AudioBuffer & src_frames,
units::sample_u64_t start_frame )

Replaces the clip's frames starting from start_frame with frames.

Warning
Not realtime safe.
Parameters
src_framesFrames to copy.
start_frameFrame to start copying to (src_frames are always copied from the start).

◆ replace_frames_from_interleaved()

void zrythm::dsp::FileAudioSource::replace_frames_from_interleaved ( const float * frames,
units::sample_u64_t start_frame,
units::sample_u64_t num_frames_per_channel,
channels_t channels )

Replaces the clip's frames starting from start_frame with frames.

Warning
Not realtime safe.
Parameters
framesFrames, interleaved.
start_frameFrame to start copying to (src_frames are always copied from the start).

◆ set_name()

void zrythm::dsp::FileAudioSource::set_name ( const utils::Utf8String & name)
inline

Definition at line 122 of file file_audio_source.h.

◆ source_bpm()

auto zrythm::dsp::FileAudioSource::source_bpm ( ) const
inline

The clip's permanent source BPM (its intrinsic musical tempo).

Set once at construction: from file metadata for file-loaded clips, or from the value supplied by the caller (e.g. the project tempo at recording time) for buffer-backed clips. Used to compute musical-mode stretch ratios. A value of 0 means "unknown" — musical mode cannot be applied.

Definition at line 118 of file file_audio_source.h.


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