Skip to content

Commit 483c107

Browse files
committed
Join the size_t crew
1 parent 6a5050d commit 483c107

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

include/signalsmith-basics/freq-shifter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ struct FreqShifterSTFX : public BaseEffect {
9191
// In general, this may alias at the high end when shifting up
9292
// but our Hilbert has a 20kHz lowpass, so that's enough
9393
// room for our maximum +1000Hz shift
94-
Complex y = shiftAfter*hilbert(x*shiftBefore, c);
94+
Complex y = shiftAfter*hilbert(x*shiftBefore, int(c));
9595
io.output[c][i] = gainDry*x + gainWet*y.real();
9696
}
9797

include/stfx/stfx-library.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -178,20 +178,20 @@ namespace stfx {
178178
}
179179
public:
180180
// Block length in samples
181-
int length;
181+
const size_t length;
182182

183-
Block(int length, double fadeStart, double fadeStep, bool firstBlockAfterReset, bool wantsMeters, bool &metersChecked) : fadeStart(fadeStart), fadeStep(fadeStep), blockFade(1.0/length), firstBlockAfterReset(firstBlockAfterReset), metersRequested(wantsMeters), metersChecked(metersChecked), length(length) {}
183+
Block(size_t length, double fadeStart, double fadeStep, bool firstBlockAfterReset, bool wantsMeters, bool &metersChecked) : fadeStart(fadeStart), fadeStep(fadeStep), blockFade(1.0/length), firstBlockAfterReset(firstBlockAfterReset), metersRequested(wantsMeters), metersChecked(metersChecked), length(length) {}
184184
// Not copyable, because that's probably a mistake
185185
Block(const Block &) = delete;
186186
Block & operator =(const Block&) = delete;
187187

188188
/// Fade ratio at a given sample index
189-
double fade(int i) const {
189+
double fade(double i) const {
190190
return fadeStart + i*fadeStep;
191191
}
192192
/// Mix two values according to the fade ratio
193193
template<class Value=double>
194-
Value fade(int i, Value from, Value to) const {
194+
Value fade(double i, Value from, Value to) const {
195195
return from + (to - from)*fade(i);
196196
}
197197

@@ -240,14 +240,14 @@ namespace stfx {
240240
BlockAutomation(const LinearSegment &smoothed) : LinearSegment(smoothed) {}
241241

242242
// For this implementation, we just provide a linear segment and no update events.
243-
static constexpr int size() {
243+
static constexpr size_t size() {
244244
return 0;
245245
}
246246
struct DoNothingEvent {
247-
int offset = 0;
247+
size_t offset = 0;
248248
void operator()() {}
249249
};
250-
DoNothingEvent operator [](int) {
250+
DoNothingEvent operator [](size_t) {
251251
return DoNothingEvent();
252252
}
253253
};
@@ -262,8 +262,8 @@ namespace stfx {
262262
/// Blocks can be processed in sub-blocks, which are split up by events.
263263
/// This method may return a different sub-block type (which will also have `.split()` and `.forEach()` methods).
264264
template<class EventList>
265-
const Block & split(EventList &&list, int count) const {
266-
for (int i = 0; i < count; ++i) list[i]();
265+
const Block & split(EventList &&list, size_t count) const {
266+
for (size_t i = 0; i < count; ++i) list[i]();
267267
return *this;
268268
}
269269
template<class EventList, class ...Others>
@@ -450,9 +450,9 @@ namespace stfx {
450450

451451
struct Config {
452452
double sampleRate = 48000;
453-
int inputChannels = 2, outputChannels = 2;
454-
std::vector<int> auxInputs, auxOutputs;
455-
int maxBlockSize = 256;
453+
size_t inputChannels = 2, outputChannels = 2;
454+
std::vector<size_t> auxInputs, auxOutputs;
455+
size_t maxBlockSize = 256;
456456

457457
bool operator ==(const Config &other) const {
458458
return sampleRate == other.sampleRate
@@ -476,14 +476,14 @@ namespace stfx {
476476
return false;
477477
}
478478
/// Attempts to find a valid configuration by iteration
479-
bool configurePersistent(int attempts=10) {
480-
for (int i = 0; i < attempts; ++i) {
479+
bool configurePersistent(size_t attempts=10) {
480+
for (size_t i = 0; i < attempts; ++i) {
481481
if (configure()) return true;
482482
}
483483
return false;
484484
}
485485
/// Returns true if the effect was successfully configured with _exactly_ these parameters
486-
bool configure(double sampleRate, int maxBlockSize, int channels=2, int outputChannels=-1) {
486+
bool configure(double sampleRate, size_t maxBlockSize, size_t channels=2, size_t outputChannels=-1) {
487487
if (outputChannels < 0) outputChannels = channels;
488488
config.sampleRate = sampleRate;
489489
config.inputChannels = channels;
@@ -508,14 +508,14 @@ namespace stfx {
508508
}
509509

510510
template<class Buffers>
511-
void process(Buffers &&buffers, int blockLength) {
511+
void process(Buffers &&buffers, size_t blockLength) {
512512
process(buffers, buffers, blockLength);
513513
}
514514

515-
/// Wraps the common `process(float** inputs, float** outputs, int length)` call into the `.processSTFX(io, config, block)`.
515+
/// Wraps the common `process(float** inputs, float** outputs, size_t length)` call into the `.processSTFX(io, config, block)`.
516516
/// It actually accepts any objects which support `inputs[channel][index]`, so you could write adapters for interleaved buffers etc.
517517
template<class Inputs, class Outputs>
518-
void process(Inputs &&inputs, Outputs &&outputs, int blockLength) {
518+
void process(Inputs &&inputs, Outputs &&outputs, size_t blockLength) {
519519
// How long should the parameter fade take?
520520
double fadeSamples = EffectClass::paramFadeMs()*0.001*config.sampleRate;
521521
// Fade position at the end of the block

0 commit comments

Comments
 (0)