Skip to content

Commit

Permalink
Remove SamplePlayer::fillBuffer() method
Browse files Browse the repository at this point in the history
  • Loading branch information
gvnnz committed Jul 27, 2023
1 parent f7d45ae commit 301e465
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
15 changes: 4 additions & 11 deletions src/core/channels/samplePlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ void SamplePlayer::render(const Channel& ch, Render renderInfo, bool seqIsRunnin
/* Both modes: 1st = [abcdefghijklmnopq]
No need for fancy render() here. You don't want the chance to trigger
onLastFrame() at this point which would invalidate the rewind (a listener
might stop the rendering): fillBuffer() is just enough. Just notify
might stop the rendering): waveReader.fill() is just enough. Just notify
waveReader this is the last read before rewind. */

tracker = fillBuffer(*ch.sampleChannel->getWave(), buf, tracker, end, 0, pitch, resampler).used;
tracker = waveReader.fill(*ch.sampleChannel->getWave(), buf, tracker, end, 0, pitch, resampler).used;
resampler.last();

/* Mode::REWIND: 2nd = [abcdefghi|abcdfefg]
Expand Down Expand Up @@ -94,7 +94,7 @@ Frame SamplePlayer::render(const Channel& ch, mcl::AudioBuffer& buf, Frame track

/* First pass rendering. */

WaveReader::Result res = fillBuffer(wave, buf, tracker, end, offset, pitch, resampler);
WaveReader::Result res = waveReader.fill(wave, buf, tracker, end, offset, pitch, resampler);
tracker += res.used;

/* Second pass rendering: if tracker has looped, special care is needed. If
Expand All @@ -110,7 +110,7 @@ Frame SamplePlayer::render(const Channel& ch, mcl::AudioBuffer& buf, Frame track
onLastFrame(ch, /*natural=*/true, seqIsRunning);

if (shouldLoop(mode, status) && res.generated < buf.countFrames())
tracker += fillBuffer(wave, buf, tracker, end, res.generated, pitch, resampler).used;
tracker += waveReader.fill(wave, buf, tracker, end, res.generated, pitch, resampler).used;
}

return tracker;
Expand All @@ -130,13 +130,6 @@ void SamplePlayer::stop(const Channel& ch, mcl::AudioBuffer& buf, Frame offset,

/* -------------------------------------------------------------------------- */

WaveReader::Result SamplePlayer::fillBuffer(const Wave& wave, mcl::AudioBuffer& buf, Frame start, Frame end, Frame offset, float pitch, const Resampler& resampler) const
{
return waveReader.fill(wave, buf, start, end, offset, pitch, resampler);
}

/* -------------------------------------------------------------------------- */

bool SamplePlayer::shouldLoop(SamplePlayerMode mode, ChannelStatus status) const
{
return (mode == SamplePlayerMode::LOOP_BASIC ||
Expand Down
3 changes: 1 addition & 2 deletions src/core/channels/samplePlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ class SamplePlayer final

void stop(const Channel&, mcl::AudioBuffer&, Frame offset, bool seqIsRunning) const;

WaveReader::Result fillBuffer(const Wave&, mcl::AudioBuffer&, Frame start, Frame end, Frame offset, float pitch, const Resampler&) const;
bool shouldLoop(SamplePlayerMode, ChannelStatus) const;
bool shouldLoop(SamplePlayerMode, ChannelStatus) const;
};
} // namespace giada::m

Expand Down

0 comments on commit 301e465

Please sign in to comment.