Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix dsf bug #36

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
16 changes: 14 additions & 2 deletions ReSampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion ReSampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <inputfile> [-o <outputfile>] -r <samplerate> [-b <bitformat>] [-n [<normalization factor>]]\n");
const std::string strExtraOptions(
"--help\n"
Expand Down
6 changes: 5 additions & 1 deletion dsf.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,12 +352,16 @@ namespace ReSampler {
}

startOfData = static_cast<uint64_t>(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
Expand Down