27 void reset (
size_t numChannels)
32 size_t getNumChannels()
const
34 return samples.
size();
37 template<
typename Buffer>
38 void push (
const Buffer& buffer)
40 pushSingleFrame (buffer.getEnd (1));
43 void trigger (
size_t numFramesToFade_)
45 numFramesToFade = numFramesToFade_;
46 currentFadeFrameCountDown = numFramesToFade;
55 template<
typename Buffer>
56 void apply (Buffer&& buffer, FadeType fadeType)
58 if (currentFadeFrameCountDown == 0 || numFramesToFade == 0)
61 const auto numFrames =
static_cast<size_t> (buffer.getNumFrames());
62 const auto numChannels = buffer.getNumChannels();
63 const size_t numThisTime =
std::min (numFrames, currentFadeFrameCountDown);
65 for (choc::buffer::ChannelCount channel = 0; channel < numChannels; ++channel)
67 const auto dest = buffer.getIterator (channel).sample;
68 const auto lastSample = samples[
static_cast<size_t> (channel)];
69 auto channelCurrentFadeFrameCountDown = currentFadeFrameCountDown;
71 for (
size_t i = 0; i < numThisTime; ++i)
73 const auto frameNum = numFramesToFade - channelCurrentFadeFrameCountDown;
74 auto alpha = frameNum /
static_cast<float> (numFramesToFade);
75 assert (alpha >= 0.0f && alpha <= 1.0f);
77 if (fadeType == FadeType::fadeOut)
78 dest[i] = dest[i] + (lastSample * (1.0f - alpha));
79 else if (fadeType == FadeType::crossfade)
80 dest[i] = (alpha * dest[i]) + (lastSample * (1.0f - alpha));
82 --channelCurrentFadeFrameCountDown;
86 assert ((
static_cast<int> (currentFadeFrameCountDown) -
static_cast<int> (numThisTime)) >= 0);
87 currentFadeFrameCountDown -= numThisTime;
90 template<
typename Buffer>
91 void applyAt (Buffer& buffer, choc::buffer::FrameCount frameNum, FadeType fadeType)
93 apply (buffer.getFrameRange (choc::buffer::FrameRange { .start = frameNum, .end = buffer.getNumFrames() - frameNum }),
99 size_t numFramesToFade = 0, currentFadeFrameCountDown = 0;
101 template<
typename Buffer>
102 void pushSingleFrame (
const Buffer& buffer)
104 const auto numChannels = buffer.getNumChannels();
106 assert (buffer.getNumFrames() == 1u);
108 for (
auto chan = 0u; chan < numChannels; ++chan)
109 samples[
static_cast<size_t> (chan)] = buffer.getSample (chan, 0);
122 public SharedTimer::Listener
142 struct SlotClipStatus;
151 MidiMessageArray::MPESourceID midiSourceID = MidiMessageArray::createUniqueMPESourceID();
152 ScopedListener playSlotsUpdaterListener { track->edit.engine.getBackToArrangerUpdateTimer(), *
this };
158 void sortPlayingOrQueuedClipsFirst();
159 void updatePlaySlotsState();
164 struct SlotClipStatus
166 bool anyClipsPlaying =
false;
167 bool anyClipsQueued =
false;
177 void sharedTimerCallback()
override;
Struct to describe a single iteration of a process call.