From f14d8bc82e335c9de8d34e2cd0c49bc198443b56 Mon Sep 17 00:00:00 2001 From: pschatzmann Date: Sun, 8 Oct 2023 12:14:02 +0200 Subject: [PATCH] readSamples, writeSamples return samples --- src/AudioTools/AudioTypes.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/AudioTools/AudioTypes.h b/src/AudioTools/AudioTypes.h index 2d22ca6b2d..0e406e2785 100644 --- a/src/AudioTools/AudioTypes.h +++ b/src/AudioTools/AudioTypes.h @@ -317,7 +317,8 @@ size_t readSamples(Stream* p_stream, T* data, int samples){ open -= read; total += read; } - return samples; + // convert bytes to samples + return samples / sizeof(T); } /// guaranteed to return the requested data @@ -328,12 +329,13 @@ size_t writeSamples(Print* p_out, T* data, int samples, int maxSamples=512){ int total = 0; // copy missing data while (open>0){ - int to_write = MIN(open, (int) maxSamples*sizeof(T)); + int to_write = min(open, static_cast(maxSamples*sizeof(T))); int written = p_out->write(p_result+total, to_write ); open -= written; total += written; } - return samples; + // convert bytes to samples + return total / sizeof(T); }