diff --git a/README.md b/README.md index 18c9fe7a..dc63adfa 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +## Version 2.1.1 + +* DSF bug in ReSampler v2.1.0: When resampling from some DSF (DSD audio) sources,there are unexpected peaks at the end of destination audio file. +* Version 2.1.1 : Uses "Sample count" info in Fmt Chuck of DSF file to calculate the correct input sample count,insdead of "Size of this chunk" info in Data Chuck. ## Synopsis ReSampler is a high-performance command-line audio sample rate conversion tool which can convert audio file formats with a variety of different bit-depths and audio channel configurations. diff --git a/ReSampler.cpp b/ReSampler.cpp index 8fa85711..c4daaf74 100644 --- a/ReSampler.cpp +++ b/ReSampler.cpp @@ -775,11 +775,23 @@ bool convert(ConversionInfo& ci) // --- do { // central conversion loop (the heart of the matter ...) + //---by diablo2049--- + sf_count_t lastBlocksize = inputSampleCount - totalSamplesRead; + if (lastBlocksize >= sf_count_t(inputBlockSize)) + { + samplesRead = infile.read(inputBlock.data(), inputBlockSize); + } + else + { + samplesRead = infile.read(inputBlock.data(), size_t(lastBlocksize)); + } - // Grab a block of interleaved samples from file: - samplesRead = infile.read(inputBlock.data(), inputBlockSize); totalSamplesRead += samplesRead; + // Grab a block of interleaved samples from file: + //samplesRead = infile.read(inputBlock.data(), inputBlockSize); + //totalSamplesRead += samplesRead; + // de-interleave into channel buffers size_t i = 0; for (int s = 0; s < samplesRead; s += nChannels) { diff --git a/ReSampler.h b/ReSampler.h index 318cd175..1979449a 100644 --- a/ReSampler.h +++ b/ReSampler.h @@ -40,7 +40,7 @@ namespace ReSampler { -const std::string strVersion("2.1.0"); +const std::string strVersion("2.1.1"); const std::string strUsage("usage: ReSampler -i [-o ] -r [-b ] [-n []]\n"); const std::string strExtraOptions( "--help\n" diff --git a/dsf.h b/dsf.h index ad5ca008..47f0211b 100644 --- a/dsf.h +++ b/dsf.h @@ -352,12 +352,16 @@ namespace ReSampler { } startOfData = static_cast(file.tellg()); - endOfData = dsfDSDChunk.length + dsfFmtChunk.length + dsfDataChunk.length; + //--- by diablo2049 --- + endOfData = sizeof(dsfDSDChunk) + sizeof(dsfFmtChunk) + sizeof(dsfDataChunk) + numSamples / 8; + //endOfData = dsfDSDChunk.length + dsfFmtChunk.length + dsfDataChunk.length; + /* assert( // metadata tag either non-existent or at end of data (dsfDSDChunk.metadataPtr == 0) || (dsfDSDChunk.metadataPtr == endOfData) ); + */ } // readBlocks() : reads blockSize bytes into each channelBuffer for numChannels channels