Skip to content

Commit

Permalink
Add cassert include within Sample
Browse files Browse the repository at this point in the history
  • Loading branch information
sakertooth committed Aug 28, 2023
1 parent 622405e commit cb42f0a
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/core/Sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include <QPainter>
#include <QRect>
#include <cassert>

namespace lmms {

Expand Down Expand Up @@ -113,7 +114,9 @@ auto swap(Sample& first, Sample& second) -> void

bool Sample::play(sampleFrame* dst, PlaybackState* state, int numFrames, float desiredFrequency, Loop loopMode) const
{
assert(m_buffer != nullptr && m_buffer->sampleRate() > 0);
assert(m_buffer != nullptr);
if (numFrames <= 0 || desiredFrequency <= 0 ||
m_buffer->size() <= 0 || m_buffer->sampleRate() <= 0) { return false; }

const auto lock = std::shared_lock{m_mutex};
const auto resampleRatio
Expand Down Expand Up @@ -385,7 +388,8 @@ auto Sample::playSampleRange(PlaybackState* state, sampleFrame* dst, int numFram
return true;
}

auto Sample::playSampleRangeLoop(PlaybackState* state, sampleFrame* dst, int numFrames, float resampleRatio) const -> bool
auto Sample::playSampleRangeLoop(PlaybackState* state, sampleFrame* dst, int numFrames, float resampleRatio) const
-> bool
{
if (numFrames <= 0) { return false; }
if (state->m_frameIndex >= m_loopEndFrame) { state->m_frameIndex = m_loopStartFrame; }
Expand Down Expand Up @@ -414,7 +418,8 @@ auto Sample::playSampleRangeLoop(PlaybackState* state, sampleFrame* dst, int num
return true;
}

auto Sample::playSampleRangePingPong(PlaybackState* state, sampleFrame* dst, int numFrames, float resampleRatio) const -> bool
auto Sample::playSampleRangePingPong(PlaybackState* state, sampleFrame* dst, int numFrames, float resampleRatio) const
-> bool
{
if (numFrames <= 0) { return false; }
if (state->m_frameIndex >= m_loopEndFrame)
Expand Down Expand Up @@ -474,8 +479,10 @@ auto Sample::copyBufferForward(sampleFrame* dst, int initialPosition, int advanc

auto Sample::copyBufferBackward(sampleFrame* dst, int initialPosition, int advanceAmount) const -> void
{
m_reversed ? std::reverse_copy(m_buffer->rbegin() + initialPosition - advanceAmount, m_buffer->rbegin() + initialPosition, dst)
: std::reverse_copy(m_buffer->begin() + initialPosition - advanceAmount, m_buffer->begin() + initialPosition, dst);
m_reversed ? std::reverse_copy(
m_buffer->rbegin() + initialPosition - advanceAmount, m_buffer->rbegin() + initialPosition, dst)
: std::reverse_copy(
m_buffer->begin() + initialPosition - advanceAmount, m_buffer->begin() + initialPosition, dst);
}

auto Sample::getLoopedIndex(int index, int startFrame, int endFrame) const -> int
Expand Down

0 comments on commit cb42f0a

Please sign in to comment.