Zrythm v2.0.0-DEV
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

Public Member Functions

 FileAudioSource (QObject *parent=nullptr)
 FileAudioSource (const fs::path &full_path, units::sample_rate_t project_sample_rate, bpm_t current_bpm, 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, bpm_t current_bpm, const utils::Utf8String &name, QObject *parent=nullptr)
 Creates an audio clip by copying the given buffer.
 FileAudioSource (const float *arr, unsigned_frame_t nframes, channels_t channels, zrythm::utils::audio::BitDepth bit_depth, units::sample_rate_t project_sample_rate, bpm_t current_bpm, const utils::Utf8String &name, QObject *parent=nullptr)
 Creates an audio clip by copying the given interleaved float array.
 FileAudioSource (channels_t channels, unsigned_frame_t nframes, units::sample_rate_t project_sample_rate, bpm_t current_bpm, const utils::Utf8String &name, QObject *parent=nullptr)
 Create an audio clip while recording.
Q_SIGNAL void samplesChanged ()
 Emitted when the source samples change.
auto get_bit_depth () const
auto get_name () const
auto get_bpm () const
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, 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 init_from_file (const fs::path &full_path, units::sample_rate_t project_sample_rate, std::optional< bpm_t > bpm_to_set)
 Initializes members from an audio file.
Public Member Functions inherited from zrythm::utils::UuidIdentifiableObject< FileAudioSource >
UuidIdentifiableObject & operator= (const UuidIdentifiableObject &other)=default
auto get_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)

Detailed Description

Audio clips for the pool.

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

Definition at line 22 of file file_audio_source.h.

Member Typedef Documentation

◆ AudioFile

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

Definition at line 30 of file file_audio_source.h.

◆ BitDepth

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

Definition at line 29 of file file_audio_source.h.

Constructor & Destructor Documentation

◆ FileAudioSource() [1/5]

zrythm::dsp::FileAudioSource::FileAudioSource ( QObject * parent = nullptr)
inline

Definition at line 33 of file file_audio_source.h.

◆ FileAudioSource() [2/5]

zrythm::dsp::FileAudioSource::FileAudioSource ( const fs::path & full_path,
units::sample_rate_t project_sample_rate,
bpm_t current_bpm,
QObject * parent = nullptr )

Creates an audio clip from a file.

The basename of the file will be used as the name of the clip.

Parameters
current_bpmCurrent BPM from TempoTrack. bpm_ will be set to this. FIXME: should this be optional? does "current" BPM make sense?
Exceptions
ZrythmExceptionon error.

◆ FileAudioSource() [3/5]

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

Creates an audio clip by copying the given buffer.

Parameters
bufBuffer to copy.
nameA name for this clip.

◆ FileAudioSource() [4/5]

zrythm::dsp::FileAudioSource::FileAudioSource ( const float * arr,
unsigned_frame_t nframes,
channels_t channels,
zrythm::utils::audio::BitDepth bit_depth,
units::sample_rate_t project_sample_rate,
bpm_t current_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 73 of file file_audio_source.h.

◆ FileAudioSource() [5/5]

zrythm::dsp::FileAudioSource::FileAudioSource ( channels_t channels,
unsigned_frame_t nframes,
units::sample_rate_t project_sample_rate,
bpm_t current_bpm,
const utils::Utf8String & name,
QObject * parent = nullptr )

Create an audio clip while recording.

The frames will keep getting reallocated until the recording is finished.

Parameters
nframesNumber of frames to allocate. This should be the current cycle's frames when called during recording.

Member Function Documentation

◆ clear_frames()

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

Unloads the clip's frames from memory.

Definition at line 167 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 120 of file file_audio_source.h.

◆ get_bpm()

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

Definition at line 122 of file file_audio_source.h.

◆ get_name()

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

Definition at line 121 of file file_audio_source.h.

◆ get_num_channels()

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

Definition at line 173 of file file_audio_source.h.

◆ get_num_frames()

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

Definition at line 174 of file file_audio_source.h.

◆ get_samplerate()

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

Definition at line 124 of file file_audio_source.h.

◆ get_samples()

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

Definition at line 123 of file file_audio_source.h.

◆ init_from_file()

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

Initializes members from an audio file.

Parameters
full_pathPath to the file.
bpm_to_setBPM of the clip to set (File BPM or 0 will be used if nullopt).
Exceptions
ZrythmExceptionon I/O error.

◆ replace_frames()

void zrythm::dsp::FileAudioSource::replace_frames ( const utils::audio::AudioBuffer & src_frames,
unsigned_frame_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,
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.

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 126 of file file_audio_source.h.

◆ from_json

void from_json ( const nlohmann::json & j,
FileAudioSource & clip )
friend

Definition at line 208 of file file_audio_source.h.

◆ to_json

void to_json ( nlohmann::json & j,
const FileAudioSource & clip )
friend

Definition at line 200 of file file_audio_source.h.


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