Skip to content

Commit

Permalink
readSamples, writeSamples return samples
Browse files Browse the repository at this point in the history
  • Loading branch information
pschatzmann committed Oct 8, 2023
1 parent cf4e067 commit f14d8bc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/AudioTools/AudioTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<int>(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);
}


Expand Down

0 comments on commit f14d8bc

Please sign in to comment.