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

A processor to be used in the routing graph for playing samples independent of the timeline. More...

#include <src/gui/dsp/sample_processor.h>

Inheritance diagram for SampleProcessor:
Collaboration diagram for SampleProcessor:

Public Types

using Position = zrythm::dsp::Position
 
using PluginConfiguration = zrythm::plugins::PluginConfiguration
 

Public Member Functions

 SampleProcessor (AudioEngine *engine)
 
bool is_in_active_project () const
 
void init_after_cloning (const SampleProcessor &other, ObjectCloneType clone_type) override
 Initializes the cloned object.
 
void init_loaded (AudioEngine *engine)
 
void load_instrument_if_empty ()
 Loads the instrument from the settings.
 
void prepare_process (nframes_t nframes)
 Clears the buffers.
 
void process_block (EngineProcessTimeInfo time_nfo) override
 Process the samples for the given number of frames.
 
utils::Utf8String get_node_name () const override
 Returns a human friendly name of the node.
 
nframes_t get_single_playback_latency () const override
 Returns the latency of only the given processable, without adding the previous/next latencies.
 
void remove_sample_playback (SamplePlayback &sp)
 Removes a SamplePlayback from the array.
 
void queue_metronome_countin ()
 Queues a metronomem tick at the given offset.
 
void queue_metronome (Metronome::Type type, nframes_t offset)
 Queues a metronomem tick at the given local offset.
 
void queue_sample_from_file (const char *path)
 Adds a sample to play to the queue from a file path.
 
void queue_file (const FileDescriptor &file)
 Adds a file (audio or MIDI) to the queue.
 
void queue_chord_preset (const ChordPreset &chord_pset)
 Adds a chord preset to the queue.
 
void stop_file_playback ()
 Stops playback of files (auditioning).
 
void disconnect ()
 
TempoTrackget_tempo_track () const
 Get the tempo track from the actual project, using audio_engine_.
 
void find_and_queue_metronome (Position start_pos, Position end_pos, nframes_t loffset)
 Finds all metronome events (beat and bar changes) within the given range and adds them to the queue.
 
- Public Member Functions inherited from ICloneable< SampleProcessor >
std::unique_ptr< SampleProcessorclone_unique (ObjectCloneType clone_type=ObjectCloneType::Snapshot, Args &&... args) const
 
std::shared_ptr< SampleProcessorclone_shared (ObjectCloneType clone_type=ObjectCloneType::Snapshot, Args &&... args) const
 
SampleProcessorclone_raw_ptr (ObjectCloneType clone_type=ObjectCloneType::Snapshot, Args &&... args) const
 
SampleProcessorclone_qobject (QObject *parent, ObjectCloneType clone_type=ObjectCloneType::Snapshot, Args &&... args) const
 
QScopedPointer< SampleProcessorclone_unique_qobject (QObject *parent, ObjectCloneType clone_type=ObjectCloneType::Snapshot, Args &&... args) const
 
- Public Member Functions inherited from zrythm::dsp::graph::IProcessable
virtual void clear_external_buffer (nframes_t block_length)
 
virtual bool needs_external_buffer_clear_on_early_return () const
 

Data Fields

std::vector< SamplePlaybackcurrent_samples_
 An array of samples currently being played.
 
std::unique_ptr< Tracklisttracklist_
 Tracklist for file auditioning.
 
std::unique_ptr< zrythm::plugins::PluginConfigurationinstrument_setting_
 Instrument for MIDI auditioning.
 
std::unique_ptr< dsp::MidiEventsmidi_events_
 
std::unique_ptr< Faderfader_
 Fader connected to the main output.
 
Position playhead_
 Playhead for the tracklist (used when auditioning files).
 
Position file_end_pos_
 Position the file ends at.
 
bool roll_ = false
 Whether to roll or not.
 
AudioEngineaudio_engine_ = nullptr
 Pointer to owner audio engine, if any.
 
std::binary_semaphore rebuilding_sem_ { 1 }
 Semaphore to be locked while rebuilding the sample processor tracklist and graph.
 
- Data Fields inherited from ICloneable< SampleProcessor >
friend Derived
 

Friends

void to_json (nlohmann::json &j, const SampleProcessor &sp)
 
void from_json (const nlohmann::json &j, SampleProcessor &sp)
 

Detailed Description

A processor to be used in the routing graph for playing samples independent of the timeline.

Also used for auditioning files.

Definition at line 35 of file sample_processor.h.

Member Typedef Documentation

◆ PluginConfiguration

◆ Position

Member Function Documentation

◆ find_and_queue_metronome()

void SampleProcessor::find_and_queue_metronome ( Position start_pos,
Position end_pos,
nframes_t loffset )

Finds all metronome events (beat and bar changes) within the given range and adds them to the queue.

Parameters
end_posEnd position, exclusive.
loffsetLocal offset (this is where start_pos starts at).

◆ get_node_name()

utils::Utf8String SampleProcessor::get_node_name ( ) const
inlineoverridevirtual

Returns a human friendly name of the node.

Implements zrythm::dsp::graph::IProcessable.

Definition at line 74 of file sample_processor.h.

◆ get_single_playback_latency()

nframes_t SampleProcessor::get_single_playback_latency ( ) const
inlineoverridevirtual

Returns the latency of only the given processable, without adding the previous/next latencies.

Reimplemented from zrythm::dsp::graph::IProcessable.

Definition at line 79 of file sample_processor.h.

◆ get_tempo_track()

TempoTrack * SampleProcessor::get_tempo_track ( ) const

Get the tempo track from the actual project, using audio_engine_.

Returns
The tempo track, or nullptr if not found.

◆ init_after_cloning()

void SampleProcessor::init_after_cloning ( const SampleProcessor & other,
ObjectCloneType clone_type )
overridevirtual

Initializes the cloned object.

Note
Only final classes should implement this.
Exceptions
ZrythmExceptionIf the object could not be cloned.

Implements ICloneable< SampleProcessor >.

◆ load_instrument_if_empty()

void SampleProcessor::load_instrument_if_empty ( )

Loads the instrument from the settings.

To be called when the engine is activated, once.

◆ process_block()

void SampleProcessor::process_block ( EngineProcessTimeInfo time_nfo)
overridevirtual

Process the samples for the given number of frames.

Reimplemented from zrythm::dsp::graph::IProcessable.

◆ queue_metronome()

void SampleProcessor::queue_metronome ( Metronome::Type type,
nframes_t offset )

Queues a metronomem tick at the given local offset.

Realtime function.

◆ queue_metronome_countin()

void SampleProcessor::queue_metronome_countin ( )

Queues a metronomem tick at the given offset.

Used for countin.

Friends And Related Symbol Documentation

◆ from_json

void from_json ( const nlohmann::json & j,
SampleProcessor & sp )
friend

Definition at line 150 of file sample_processor.h.

◆ to_json

void to_json ( nlohmann::json & j,
const SampleProcessor & sp )
friend

Definition at line 146 of file sample_processor.h.

Field Documentation

◆ audio_engine_

AudioEngine* SampleProcessor::audio_engine_ = nullptr

Pointer to owner audio engine, if any.

Definition at line 191 of file sample_processor.h.

◆ current_samples_

std::vector<SamplePlayback> SampleProcessor::current_samples_

An array of samples currently being played.

Definition at line 163 of file sample_processor.h.

◆ fader_

std::unique_ptr<Fader> SampleProcessor::fader_

Fader connected to the main output.

Definition at line 174 of file sample_processor.h.

◆ file_end_pos_

Position SampleProcessor::file_end_pos_

Position the file ends at.

Once this position is reached, SampleProcessor.roll will be set to false.

Definition at line 185 of file sample_processor.h.

◆ instrument_setting_

std::unique_ptr<zrythm::plugins::PluginConfiguration> SampleProcessor::instrument_setting_

Instrument for MIDI auditioning.

Definition at line 169 of file sample_processor.h.

◆ midi_events_

std::unique_ptr<dsp::MidiEvents> SampleProcessor::midi_events_

Definition at line 171 of file sample_processor.h.

◆ playhead_

Position SampleProcessor::playhead_

Playhead for the tracklist (used when auditioning files).

Definition at line 177 of file sample_processor.h.

◆ rebuilding_sem_

std::binary_semaphore SampleProcessor::rebuilding_sem_ { 1 }

Semaphore to be locked while rebuilding the sample processor tracklist and graph.

Definition at line 195 of file sample_processor.h.

◆ roll_

bool SampleProcessor::roll_ = false

Whether to roll or not.

Definition at line 188 of file sample_processor.h.

◆ tracklist_

std::unique_ptr<Tracklist> SampleProcessor::tracklist_

Tracklist for file auditioning.

Definition at line 166 of file sample_processor.h.


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