Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
|
A processor to be used in the routing graph for playing samples independent of the timeline. More...
#include <src/engine/session/sample_processor.h>
Public Types | |
using | Position = zrythm::dsp::Position |
using | PluginConfiguration = zrythm::plugins::PluginConfiguration |
Public Member Functions | |
SampleProcessor (engine::device_io::AudioEngine *engine) | |
void | init_loaded (engine::device_io::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 () |
const dsp::TempoMap & | get_tempo_map () const |
Get the tempo track from the actual project, using audio_engine_. | |
void | find_and_queue_metronome (signed_frame_t start_pos, signed_frame_t 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 zrythm::dsp::graph::IProcessable | |
virtual void | prepare_for_processing (sample_rate_t sample_rate, nframes_t max_block_length) |
Called to allocate resources required for processing. | |
virtual void | release_resources () |
Called to release resources allocated by prepare_for_processing(). |
Data Fields | |
std::vector< SamplePlayback > | current_samples_ |
An array of samples currently being played. | |
std::unique_ptr< structure::tracks::Tracklist > | tracklist_ |
Tracklist for file auditioning. | |
std::unique_ptr< zrythm::plugins::PluginConfiguration > | instrument_setting_ |
Instrument for MIDI auditioning. | |
std::unique_ptr< dsp::MidiEvents > | midi_events_ |
std::unique_ptr< structure::tracks::Fader > | fader_ |
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. | |
engine::device_io::AudioEngine * | audio_engine_ = nullptr |
Pointer to owner audio engine, if any. | |
moodycamel::LightweightSemaphore | rebuilding_sem_ { 1 } |
Semaphore to be locked while rebuilding the sample processor tracklist and graph. |
Friends | |
void | init_from (SampleProcessor &obj, const SampleProcessor &other, utils::ObjectCloneType clone_type) |
void | to_json (nlohmann::json &j, const SampleProcessor &sp) |
void | from_json (const nlohmann::json &j, SampleProcessor &sp) |
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.
using zrythm::engine::session::SampleProcessor::PluginConfiguration = zrythm::plugins::PluginConfiguration |
Definition at line 39 of file sample_processor.h.
Definition at line 38 of file sample_processor.h.
void zrythm::engine::session::SampleProcessor::find_and_queue_metronome | ( | signed_frame_t | start_pos, |
signed_frame_t | end_pos, | ||
nframes_t | loffset ) |
Finds all metronome events (beat and bar changes) within the given range and adds them to the queue.
end_pos | End position, exclusive. |
loffset | Local offset (this is where start_pos starts at). |
|
inlineoverridevirtual |
Returns a human friendly name of the node.
Implements zrythm::dsp::graph::IProcessable.
Definition at line 71 of file sample_processor.h.
|
inlineoverridevirtual |
Returns the latency of only the given processable, without adding the previous/next latencies.
Reimplemented from zrythm::dsp::graph::IProcessable.
Definition at line 76 of file sample_processor.h.
void zrythm::engine::session::SampleProcessor::load_instrument_if_empty | ( | ) |
Loads the instrument from the settings.
To be called when the engine is activated, once.
|
overridevirtual |
Process the samples for the given number of frames.
Reimplemented from zrythm::dsp::graph::IProcessable.
void zrythm::engine::session::SampleProcessor::queue_metronome | ( | Metronome::Type | type, |
nframes_t | offset ) |
Queues a metronomem tick at the given local offset.
Realtime function.
void zrythm::engine::session::SampleProcessor::queue_metronome_countin | ( | ) |
Queues a metronomem tick at the given offset.
Used for countin.
|
friend |
Definition at line 145 of file sample_processor.h.
|
friend |
Definition at line 141 of file sample_processor.h.
engine::device_io::AudioEngine* zrythm::engine::session::SampleProcessor::audio_engine_ = nullptr |
Pointer to owner audio engine, if any.
Definition at line 186 of file sample_processor.h.
std::vector<SamplePlayback> zrythm::engine::session::SampleProcessor::current_samples_ |
An array of samples currently being played.
Definition at line 158 of file sample_processor.h.
std::unique_ptr<structure::tracks::Fader> zrythm::engine::session::SampleProcessor::fader_ |
Fader connected to the main output.
Definition at line 169 of file sample_processor.h.
Position zrythm::engine::session::SampleProcessor::file_end_pos_ |
Position the file ends at.
Once this position is reached, SampleProcessor.roll will be set to false.
Definition at line 180 of file sample_processor.h.
std::unique_ptr<zrythm::plugins::PluginConfiguration> zrythm::engine::session::SampleProcessor::instrument_setting_ |
Instrument for MIDI auditioning.
Definition at line 164 of file sample_processor.h.
std::unique_ptr<dsp::MidiEvents> zrythm::engine::session::SampleProcessor::midi_events_ |
Definition at line 166 of file sample_processor.h.
Position zrythm::engine::session::SampleProcessor::playhead_ |
Playhead for the tracklist (used when auditioning files).
Definition at line 172 of file sample_processor.h.
moodycamel::LightweightSemaphore zrythm::engine::session::SampleProcessor::rebuilding_sem_ { 1 } |
Semaphore to be locked while rebuilding the sample processor tracklist and graph.
Definition at line 190 of file sample_processor.h.
bool zrythm::engine::session::SampleProcessor::roll_ = false |
Whether to roll or not.
Definition at line 183 of file sample_processor.h.
std::unique_ptr<structure::tracks::Tracklist> zrythm::engine::session::SampleProcessor::tracklist_ |
Tracklist for file auditioning.
Definition at line 161 of file sample_processor.h.