44 void flushBuffer() { memset(&buffer[0], 0, bufferLength *
sizeof(T)); }
71 bufferLength = _bufferLengthPowerOfTwo;
74 wrapMask = bufferLength - 1;
77 buffer.reset(
new T[bufferLength]);
88 buffer[index] = input;
95 T output = buffer[readIndex++];
98 readIndex &= wrapMask;
109 return buffer[index];
114 std::unique_ptr<T[]> buffer =
nullptr;
115 unsigned int readIndex = 0;
116 unsigned int bufferLength = 1024;
117 unsigned int wrapMask = 1023;
218 double probPct = wn * 100.0;
230 void setNULLStep(
bool _isNULLStep) {
isNULLStep = _isNULLStep; }
268 void resetJumpTable()
283 std::random_device rd;
284 std::mt19937 g(rd());
285 std::shuffle(v.begin(), v.end(), g);
334 void initNextStep(uint32_t jumpIndex, uint32_t loopDirectionIndex,
bool applyProbability =
false)
336 bool forwardBackward = loopDirectionIndex ==
enumToInt(LoopDirection::kForwardBackward);
348 if (nextStep.getIsNULLStep())
371 bool loadNextStep(uint32_t loopDirectionIndex,
bool applyProbability =
false)
373 bool forwardBackward = loopDirectionIndex ==
enumToInt(LoopDirection::kForwardBackward);
390 if (nextStep.getIsNULLStep())
495 if (!nextStep.getIsNULLStep())
541 uint32_t next = baseIndex + 1;
549 uint32_t next = baseIndex - 1;
574 memcpy(timingLaneMeter, wssm.timingLaneMeter,
MAX_SEQ_STEPS *
sizeof(uint32_t));
575 memcpy(waveLaneMeter, wssm.waveLaneMeter,
MAX_SEQ_STEPS *
sizeof(uint32_t));
576 memcpy(pitchLaneMeter, wssm.pitchLaneMeter,
MAX_SEQ_STEPS *
sizeof(uint32_t));
577 memcpy(stepSeqLaneMeter, wssm.stepSeqLaneMeter,
MAX_SEQ_STEPS *
sizeof(uint32_t));
581 uint32_t timingLaneMeter[
MAX_SEQ_STEPS] = { 0, 0, 0, 0, 0, 0, 0, 0 };
582 uint32_t waveLaneMeter[
MAX_SEQ_STEPS] = { 0, 0, 0, 0, 0, 0, 0, 0 };
583 uint32_t pitchLaneMeter[
MAX_SEQ_STEPS] = { 0, 0, 0, 0, 0, 0, 0, 0 };
584 uint32_t stepSeqLaneMeter[
MAX_SEQ_STEPS] = { 0, 0, 0, 0, 0, 0, 0, 0 };
587 enum class soloType { SOLO_OFF, SOLO_0, SOLO_1, SOLO_2, SOLO_3, SOLO_4, SOLO_5, SOLO_6, SOLO_7 };
609 bool haltSequencer =
false;
613 double timeStretch = 1.0;
614 bool interpolateStepSeqMod =
false;
615 bool randomizeStepOrder =
false;
616 bool randomizePitchOrder =
false;
617 bool randomizeWaveOrder =
false;
618 bool randomizeSSModOrder =
false;
623 uint32_t timingLoopDirIndex =
enumToInt(LoopDirection::kForward);
640 uint32_t modLoopDirIndex[NUM_MOD_LANES] = {
enumToInt(LoopDirection::kForward),
enumToInt(LoopDirection::kForward),
enumToInt(LoopDirection::kForward) };
644 double waveLaneValue[
MAX_SEQ_STEPS] = { 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0 };
645 double waveLaneProbability_pct[
MAX_SEQ_STEPS] = { 100.0,100.0,100.0,100.0,100.0,100.0,100.0,100.0 };
649 double pitchLaneProbability_pct[
MAX_SEQ_STEPS] = { 100.0,100.0,100.0,100.0,100.0,100.0,100.0,100.0 };
653 double stepSeqProbability_pct[
MAX_SEQ_STEPS] = { 100.0,100.0,100.0,100.0,100.0,100.0,100.0,100.0 };
751 std::shared_ptr<WaveSequencerParameters> _parameters,
752 uint32_t blockSize = 64);
758 virtual bool reset(
double _sampleRate)
override;
759 virtual bool update()
override;
760 virtual bool render(uint32_t samplesToProcess = 1)
override;
772 std::shared_ptr<WaveSequencerParameters>
parameters =
nullptr;
785 bool initialStep =
false;
Lane()
Definition: sequencer.h:263
void shuffleJumpTable()
for randomizing the sequence in the table
Definition: sequencer.h:280
int32_t getJumpTableValue(uint32_t index)
Definition: sequencer.h:529
#define enumToInt(ENUM)
macro helper to cast a typed enum to an int
Definition: synthfunctions.h:251
void createCircularBufferPowerOfTwo(unsigned int _bufferLengthPowerOfTwo)
Create a buffer based on a target maximum in SAMPLESwhere the size is pre-calculated as a power of tw...
Definition: sequencer.h:65
uint32_t setCurrentTimingXFadeSamples()
Set the current cross fade time in samples.
Definition: sequencer.cpp:224
uint32_t timingLoopStart
Definition: sequencer.h:621
Lane stepSeqLane
step sequemcer lane
Definition: sequencer.h:781
void initNextStep(uint32_t jumpIndex, uint32_t loopDirectionIndex, bool applyProbability=false)
Initialize timing of the NEXT step; needed only at startup.
Definition: sequencer.h:334
int32_t nextStepIndex
current next step
Definition: sequencer.h:235
~JumpTable()
empty constructor
Definition: sequencer.h:38
uint32_t currentLEDStep
next in sequence
Definition: sequencer.h:522
double getStepValue()
getter current value
Definition: sequencer.h:210
void initCurrentStep(uint32_t jumpIndex)
Initialize timing of the FIRST lane step; needed only at startup.
Definition: sequencer.h:322
int32_t nextStepIndex
always know next step index
Definition: sequencer.h:559
Lane pitchLane
pitch lane
Definition: sequencer.h:780
uint32_t stepDurationSamplesRunning
running count of step samples
Definition: sequencer.h:189
Lane waveLane
waveform lane
Definition: sequencer.h:779
int32_t getPreviousStepIndex()
get the pprevious index
Definition: sequencer.h:207
T readBufferCircular()
read output of delay line
Definition: sequencer.h:93
NoiseGenerator noiseGen
for probability
Definition: sequencer.h:788
void setCurrentStepFromNextStep()
Next step becomes the current step.
Definition: sequencer.h:357
double stepValue
value of step
Definition: sequencer.h:237
double samplesPerMSec
for step counting
Definition: sequencer.h:792
int32_t jumpTable[MAX_SEQ_STEPS]
table of lane step index values
Definition: sequencer.h:555
uint32_t modLoopStart[NUM_MOD_LANES]
Definition: sequencer.h:638
void updateLEDMeterWithNextStep()
Update the LED meter index with next stap index.
Definition: sequencer.h:480
double sampleRate
sample rate
Definition: sequencer.h:791
void updateStepProbability()
Definition: sequencer.h:214
double currentStepValue
always know current step value
Definition: sequencer.h:562
double waveLaneAmp_dB[MAX_SEQ_STEPS]
Definition: sequencer.h:643
virtual ~WaveSequencer()
Definition: sequencer.h:755
Simple object that generates white, gaussian white or pink noise.
Definition: synthbase.h:495
const uint32_t WRAP_MASK
Definition: synthconstants.h:86
Holds all the information needed for one step of one lane in the wave sequencer.
Definition: sequencer.h:132
uint32_t stepMode
for individual modes of operation; e.g. timing has note and rest modes
Definition: sequencer.h:238
Definition: addosccore.cpp:4
const uint32_t MAX_SEQ_STEPS
Definition: synthconstants.h:84
void updateLEDMeterWithCurrentStep()
Update the LED meter index with current stap index.
Definition: sequencer.h:470
void clearStatusArray()
clear out LED (flashing light) status array
Definition: sequencer.cpp:209
virtual bool doNoteOn(MIDINoteEvent ¬eEvent) override
Note on handler that must:
Definition: sequencer.cpp:440
uint32_t calcPreviousIndex(uint32_t baseIndex)
Definition: sequencer.h:546
uint32_t calcNextIndex(uint32_t baseIndex)
Definition: sequencer.h:538
NoteDuration
emumearation of musical durations, shortest to longest
Definition: synthfunctions.h:1765
void updateLaneLoopPoints()
Lane loop points may have changed; this updates the start/end points.
Definition: sequencer.cpp:253
virtual bool doNoteOff(MIDINoteEvent ¬eEvent) override
Note off handler; nothing to do here.
Definition: sequencer.cpp:542
~Lane()
empty destructor
Definition: sequencer.h:266
double stepDurationMilliSec
current duration in mSec
Definition: sequencer.h:190
void updateStepDurationSamples(uint32_t _stepDurationSamples)
change the step duration time in samples
Definition: sequencer.h:172
uint32_t jumpTableIndex
current index in jump table
Definition: sequencer.h:560
T readBuffer(int index)
read an arbitrary location that is index samples old
Definition: sequencer.h:106
Crossfades two values (from A to B) and then holds B for some amount of time.
Definition: synthbase.h:283
virtual bool update() override
Updates the selected core; sets GLOBAL engine variable unisonDetuneCents that may have changed since ...
Definition: sequencer.cpp:110
void updateLaneLoopPoints()
for update to next set of points (forward or backwards)
Definition: sequencer.h:295
int32_t getNextStepIndex()
get the next index
Definition: sequencer.h:204
double xfadeDurationMilliSec
current crossfade in mSec
Definition: sequencer.h:197
double unipolar(double value)
calculates the unipolar [0.0, +1.0] value FROM a bipolar [-1.0, +1.0] value
Definition: synthfunctions.h:1075
Definition: sequencer.h:567
int32_t previousStepIndex
current previous step
Definition: sequencer.h:236
int32_t currentStepIndex
always know current step index
Definition: sequencer.h:558
void updateStepXFadeSamples(uint32_t _xfadeDurationSamples)
change the step cross-fade time in samples
Definition: sequencer.h:181
uint32_t xfadeDurationSamplesRunning
running count of crossfade samples
Definition: sequencer.h:196
void flushBuffer()
flush jump table by resetting all values to 0.0
Definition: sequencer.h:44
double xfadeDurationMilliSec[MAX_SEQ_STEPS]
Definition: sequencer.h:633
Abstract base class that encapsulates functionality of a module; used with the Module-Core paradigm...
Definition: synthbase.h:1600
NoteDuration xfadeDurationNote
current crossfade duration as note rhythm
Definition: sequencer.h:198
void reset()
reset the read-index to head of buffer
Definition: sequencer.h:50
void writeBuffer(uint32_t index, T input)
write a value into the buffer; this overwrites the previous oldest value in the buffer ...
Definition: sequencer.h:85
double stepSeqValue[MAX_SEQ_STEPS]
Definition: sequencer.h:652
void setXFadeHoldParams(uint32_t xfadeInTimeSamples)
Set the current hold time in samples.
Definition: sequencer.cpp:237
void initStepTiming()
initialize the step and crossfade durations
Definition: sequencer.h:162
WaveSequencer(std::shared_ptr< MidiInputData > _midiInputData, std::shared_ptr< WaveSequencerParameters > _parameters, uint32_t blockSize=64)
Constructs Wave Sequencer Object.
Definition: sequencer.cpp:27
uint32_t stepDurationSamples
this is what we use for the crossfader operaiton
Definition: sequencer.h:233
JumpTable()
empty constructor
Definition: sequencer.h:37
Definition: sequencer.h:260
bool isNULLStep
allow for NULL (non-playing) steps
Definition: sequencer.h:239
XHoldFader xHoldFader
for crossfading waveforms and values
Definition: sequencer.h:784
WaveSequencerStatusMeters statusMeters
set of meters for outbound monitoring of lane status
Definition: sequencer.h:608
void setPreviousStepIndex(int32_t _previousStepIndex)
set the pprevious index
Definition: sequencer.h:208
LaneStep currentStep
current
Definition: sequencer.h:520
GUI Parameters for wave sequencer object.
Definition: sequencer.h:605
uint32_t getNextStepIndex(uint32_t &jumpTableIndex, bool forwardBackward, bool &hitLoopPoint)
Find index of next step.
Definition: sequencer.h:409
uint32_t currentLEDStepDuration
on-time of current LED
Definition: sequencer.h:523
WaveSequencer module.
Definition: sequencer.h:746
double stepDurationMilliSec[MAX_SEQ_STEPS]
Definition: sequencer.h:626
double BPM
Definition: sequencer.h:612
bool forwardDirection
forward flag
Definition: sequencer.h:516
NoteDuration stepDurationNote
current step duration as note rhythm
Definition: sequencer.h:191
void setStepValue(double _stepValue)
setter current value
Definition: sequencer.h:211
Lane timingLane
timing lane
Definition: sequencer.h:778
void updateStepValues()
Update values of current step and next step as long as they are non-null.
Definition: sequencer.h:490
uint32_t endPoint
end loop point
Definition: sequencer.h:515
LaneStep laneStep[MAX_SEQ_STEPS]
array of lane steps for this lane
Definition: sequencer.h:519
double doWhiteNoise()
Function generate white noise.
Definition: synthbase.cpp:842
double pitchLaneValue[MAX_SEQ_STEPS]
Definition: sequencer.h:648
void setNextStepIndex(int32_t _nextStepIndex)
set the next index
Definition: sequencer.h:205
uint32_t sampleCounter
for LED timing
Definition: sequencer.h:775
double probability_Pct
probability of this step playing
Definition: sequencer.h:202
uint32_t startPoint
start loop point
Definition: sequencer.h:514
uint32_t xfadeDurationSamples
this is what we use for the crossfader operaiton
Definition: sequencer.h:234
hard-coded arrays of FIR filter coefficients for the sample rate conversion objects (Interpolator and...
double nextStepValue
always know next step value
Definition: sequencer.h:563
void createCircularBuffer(unsigned int _bufferLength)
Create a buffer based on a target maximum in SAMPLES do NOT call from realtime audio thread; do this ...
Definition: sequencer.h:56
A customized circular buffer for the wave sequencer object. This is identical to the CircularBuffer o...
Definition: sequencer.h:34
std::shared_ptr< WaveSequencerParameters > parameters
Definition: sequencer.h:772
bool loadNextStep(uint32_t loopDirectionIndex, bool applyProbability=false)
Load next step;.
Definition: sequencer.h:371
void setRandomizeSteps(bool _randomizeSteps)
Enable re-shuffling of jump table.
Definition: sequencer.h:502
virtual bool reset(double _sampleRate) override
Resets object to initialized state.
Definition: sequencer.cpp:88
bool randomizeSteps
flag to randomize steps
Definition: sequencer.h:564
Information about a MIDI note event (note on or note off).
Definition: synthstructures.h:212
See also Designing Software Synthesizers in C++ 2nd Ed. by Will Pirkle.
void initStepTiming(uint32_t stepIndex)
Initialize timing of a lane step.
Definition: sequencer.h:314
virtual bool render(uint32_t samplesToProcess=1) override
Crank through one iteration of the sequencer over one block of data.
Definition: sequencer.cpp:283