From 8a6b77690006e95ff044c679486b2d0d57d2ac97 Mon Sep 17 00:00:00 2001 From: Steph Prince <40640337+stephprince@users.noreply.github.com> Date: Fri, 6 Sep 2024 16:54:56 -0700 Subject: [PATCH] add notes to data transform utils --- src/Utils.hpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Utils.hpp b/src/Utils.hpp index 43a00412..5c75f98c 100644 --- a/src/Utils.hpp +++ b/src/Utils.hpp @@ -72,10 +72,21 @@ inline std::shared_ptr createIO(const std::string& type, } } +/** + * @brief Method to convert float values to uint16 values. This method + * was adapted from JUCE AudioDataConverters using a default value of + * destBytesPerSample = 2. + * @param source The source float data to convert + * @param dest The destination for the converted uint16 data + * @param numSamples The number of samples to convert + */ inline void convertFloatToInt16LE(const float* source, void* dest, int numSamples) { + // TODO - several steps in this function may be unnecessary for our use + // case. Consider simplifying the intermediate cast to char and the + // final cast to uint16_t. auto maxVal = static_cast(0x7fff); auto intData = static_cast(dest); @@ -89,6 +100,12 @@ inline void convertFloatToInt16LE(const float* source, } } +/** + * @brief Method to scale float values and convert to int16 values + * @param numSamples The number of samples to convert + * @param conversion_factor The conversion factor to scale the data + * @param data The data to convert + */ inline std::unique_ptr transformToInt16(SizeType numSamples, float conversion_factor, const float* data)