From 48c14ec277729efcc1f127b5cd9482341ceb3f1c Mon Sep 17 00:00:00 2001 From: diablo2049 Date: Sun, 21 Aug 2022 10:45:04 +0800 Subject: [PATCH 1/5] fix dsf source bug fix the unexpected peaks in the end of the destination files, when source is dsf format --- ReSampler.cpp | 16 ++++++++++++++-- ReSampler.h | 2 +- dsf.h | 6 +++++- 3 files changed, 20 insertions(+), 4 deletions(-) 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 From 1e584eb861bc8289e2745044fe7e27ade50ed3ac Mon Sep 17 00:00:00 2001 From: diablo2049 Date: Sun, 21 Aug 2022 11:05:49 +0800 Subject: [PATCH 2/5] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 18c9fe7a..7984448e 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ +## 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. + +The reason is ReSampler v2.1.0 uses "Size of this chunk" info in Data Chuck of DSF files to calculate input sample count,but the result is not consist with "Sample count" info in Fmt Chuck. +To solve this problem,Version 2.1.1 uses "Sample count" info in Fmt Chuck to calculate the correct input sample count. ## 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. From a999d8ff3110722977f11571e19b3b0485f168bb Mon Sep 17 00:00:00 2001 From: diablo2049 <111498229+diablo2049@users.noreply.github.com> Date: Wed, 24 Aug 2022 21:41:54 +0800 Subject: [PATCH 3/5] Update README.md --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 7984448e..b8355291 100644 --- a/README.md +++ b/README.md @@ -1,9 +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. - -The reason is ReSampler v2.1.0 uses "Size of this chunk" info in Data Chuck of DSF files to calculate input sample count,but the result is not consist with "Sample count" info in Fmt Chuck. -To solve this problem,Version 2.1.1 uses "Sample count" info in Fmt Chuck to calculate the correct input sample count. +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. From 0c98ac524efa056787d7b59a8026b0e42244c398 Mon Sep 17 00:00:00 2001 From: diablo2049 <111498229+diablo2049@users.noreply.github.com> Date: Wed, 24 Aug 2022 21:42:55 +0800 Subject: [PATCH 4/5] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b8355291..f4a06ab4 100644 --- a/README.md +++ b/README.md @@ -1,7 +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. +*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. From 70c786fa3948146a3e144e1e28cdf24bf3b10f75 Mon Sep 17 00:00:00 2001 From: diablo2049 <111498229+diablo2049@users.noreply.github.com> Date: Wed, 24 Aug 2022 21:43:34 +0800 Subject: [PATCH 5/5] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f4a06ab4..dc63adfa 100644 --- a/README.md +++ b/README.md @@ -1,7 +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. +* 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.