Browse Source

Generate file preview for bigger files too

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.3.0-RC1
falkTX 3 years ago
parent
commit
f449238d92
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
1 changed files with 19 additions and 1 deletions
  1. +19
    -1
      source/native-plugins/audio-base.hpp

+ 19
- 1
source/native-plugins/audio-base.hpp View File

@@ -347,7 +347,7 @@ public:
const uint pollTempSize = poolNumFrames * fFileNfo.channels; const uint pollTempSize = poolNumFrames * fFileNfo.channels;
uint resampleTempSize = 0; uint resampleTempSize = 0;


carla_zeroFloats(previewData, 300);
readFilePreview(previewDataSize, previewData);


fPool.create(poolNumFrames, true); fPool.create(poolNumFrames, true);


@@ -490,6 +490,24 @@ public:
return true; return true;
} }


void readFilePreview(const uint32_t previewDataSize, float* previewData)
{
carla_zeroFloats(previewData, previewDataSize);

const uint fileNumFrames = static_cast<uint>(fFileNfo.frames);
const float fileNumFramesF = static_cast<float>(fileNumFrames);
const float previewDataSizeF = static_cast<float>(previewDataSize);

for (uint i=0; i<previewDataSize; ++i)
{
const float posF = static_cast<float>(i)/previewDataSizeF * fileNumFramesF;
const uint pos = carla_fixedValue(0U, fileNumFrames-2U, static_cast<uint>(posF + 0.5f));

ad_seek(fFilePtr, pos);
ad_read(fFilePtr, previewData + i, 2);
}
}

void readEntireFileIntoPool(const bool needsResample) void readEntireFileIntoPool(const bool needsResample)
{ {
CARLA_SAFE_ASSERT_RETURN(fPool.numFrames > 0,); CARLA_SAFE_ASSERT_RETURN(fPool.numFrames > 0,);


Loading…
Cancel
Save