3#include <pulp/signal/detail/modular_sequencing_common.hpp>
53template <
typename SampleType =
float>
68 SampleType
cv = SampleType{0};
73 sample_rate_ = sample_rate > 0.0 ? sample_rate : sample_rate_;
77 width_ = std::clamp(w, 1,
kMaxDim);
78 height_ = std::clamp(h, 1,
kMaxDim);
79 if (x_ >= width_) x_ = 0;
80 if (y_ >= height_) y_ = 0;
82 int width()
const {
return width_; }
83 int height()
const {
return height_; }
87 std::isfinite(
static_cast<double>(volts)))
119 held_ = SampleType{0};
124 int x()
const {
return x_; }
125 int y()
const {
return y_; }
128 bool gate()
const {
return gate_; }
129 SampleType
cv()
const {
return held_; }
131 Frame
process(
bool run_high,
bool reset_edge,
bool x_clock_edge,
bool y_clock_edge) {
136 return Frame{held_,
false};
140 if (x_clock_edge || y_clock_edge) {
141 const int prev_x = cell_x_;
142 const int prev_y = cell_y_;
151 x_ = (x_ + 1) % width_;
152 if (x_ == 0) y_ = (y_ + 1) % height_;
155 if (x_clock_edge) x_ = (x_ + 1) % width_;
156 if (y_clock_edge) y_ = (y_ + 1) % height_;
160 cell_x_ = wrap(x_ + x_offset_, width_);
161 cell_y_ = wrap(y_ + y_offset_, height_);
162 held_ = value_[cell_y_][cell_x_];
163 if (cell_x_ != prev_x || cell_y_ != prev_y) gate_ =
true;
166 return Frame{held_, gate_};
170 static int wrap(
int v,
int m) {
172 return r < 0 ? r + m : r;
175 double sample_rate_ = 44100.0;
187 bool started_ =
false;
189 SampleType held_ = SampleType{0};
The 2-D (Cartesian) sequencer.
Definition cartesian_walk.hpp:54
int height() const
Definition cartesian_walk.hpp:83
int y() const
Definition cartesian_walk.hpp:125
void prepare(double sample_rate)
Definition cartesian_walk.hpp:72
bool gate() const
Definition cartesian_walk.hpp:128
Frame process(bool run_high, bool reset_edge, bool x_clock_edge, bool y_clock_edge)
Definition cartesian_walk.hpp:131
static constexpr int kMaxDim
Definition cartesian_walk.hpp:58
SampleType cv() const
Definition cartesian_walk.hpp:129
void apply_reset_edge()
Verb 2: both counters home, gate low, output CV held.
Definition cartesian_walk.hpp:108
static constexpr int latency_samples()
Definition cartesian_walk.hpp:122
int x() const
Definition cartesian_walk.hpp:124
int cell_y() const
Definition cartesian_walk.hpp:127
int cell_x() const
Definition cartesian_walk.hpp:126
void set_offsets(int x_cv, int y_cv)
Integer CV offsets added to each axis counter.
Definition cartesian_walk.hpp:100
void set_value(int x, int y, SampleType volts)
Definition cartesian_walk.hpp:85
static constexpr int kMaxOffset
Definition cartesian_walk.hpp:65
static constexpr int kDefaultDim
Definition cartesian_walk.hpp:59
void set_access(CartesianAccess mode)
Definition cartesian_walk.hpp:94
int width() const
Definition cartesian_walk.hpp:82
void set_size(int w, int h)
Definition cartesian_walk.hpp:76
SampleType value(int x, int y) const
Definition cartesian_walk.hpp:90
CartesianAccess access() const
Definition cartesian_walk.hpp:95
void reset()
Definition cartesian_walk.hpp:117
Definition additive_bank.hpp:218
CartesianAccess
How a CartesianWalkT's two axes relate.
Definition cartesian_walk.hpp:13
@ row_major
X advances on its clock; an X wrap carries into Y, like reading text.
Definition cartesian_walk.hpp:17
@ independent
X and Y advance only on their own clocks and never on each other's.
Definition cartesian_walk.hpp:20
CartesianWalkT< double > CartesianWalk64
Definition cartesian_walk.hpp:193
CartesianWalkT< float > CartesianWalk
Definition cartesian_walk.hpp:192
Definition cartesian_walk.hpp:67
SampleType cv
Definition cartesian_walk.hpp:68
bool gate
Definition cartesian_walk.hpp:69