Skip to content

Commit

Permalink
Change fpp_t usage in SampleFrame to use size_t instead (#7362)
Browse files Browse the repository at this point in the history
  • Loading branch information
sakertooth committed Jul 2, 2024
1 parent 449e669 commit 538572a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions include/SampleFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "lmms_basics.h"

#include <array>
#include <cstddef>


namespace lmms
Expand Down Expand Up @@ -186,15 +187,15 @@ class SampleFrame
std::array<sample_t, DEFAULT_CHANNELS> m_samples;
};

inline void zeroSampleFrames(SampleFrame* buffer, fpp_t frames)
inline void zeroSampleFrames(SampleFrame* buffer, size_t frames)
{
// The equivalent of the following operation which yields compiler warnings
// memset(buffer, 0, sizeof(SampleFrame) * frames);

std::fill(buffer, buffer + frames, SampleFrame());
}

inline SampleFrame getAbsPeakValues(SampleFrame* buffer, fpp_t frames)
inline SampleFrame getAbsPeakValues(SampleFrame* buffer, size_t frames)
{
SampleFrame peaks;

Expand All @@ -206,18 +207,18 @@ inline SampleFrame getAbsPeakValues(SampleFrame* buffer, fpp_t frames)
return peaks;
}

inline void copyToSampleFrames(SampleFrame* target, const float* source, fpp_t frames)
inline void copyToSampleFrames(SampleFrame* target, const float* source, size_t frames)
{
for (fpp_t i = 0; i < frames; ++i)
for (size_t i = 0; i < frames; ++i)
{
target[i].setLeft(source[2*i]);
target[i].setRight(source[2*i + 1]);
}
}

inline void copyFromSampleFrames(float* target, const SampleFrame* source, fpp_t frames)
inline void copyFromSampleFrames(float* target, const SampleFrame* source, size_t frames)
{
for (fpp_t i = 0; i < frames; ++i)
for (size_t i = 0; i < frames; ++i)
{
target[2*i] = source[i].left();
target[2*i + 1] = source[i].right();
Expand Down

0 comments on commit 538572a

Please sign in to comment.