mirror of
https://gitlab.com/ecodis/exhale.git
synced 2025-02-15 02:50:47 +01:00
fixes for issue #21
This commit is contained in:
parent
7688ab502e
commit
7ebdd6308a
@ -458,10 +458,11 @@ unsigned BasicWavReader::read (int32_t* const frameBuf, const uint16_t frameCoun
|
||||
{
|
||||
m_bytesRead = unsigned (m_bytesRead + m_bytesRemaining);
|
||||
framesRead = m_bytesRead / m_waveFrameSize;
|
||||
if (framesRead < framesTotal) memset (&frameBuf[framesRead * m_waveChannels], 0, (framesTotal - framesRead) * m_waveChannels * sizeof (int32_t));
|
||||
}
|
||||
m_chunkLength += m_bytesRead;
|
||||
|
||||
if (framesRead < framesTotal) eaExtrapolate (frameBuf, framesRead, framesTotal, m_waveChannels); // fade-out, for gapless playback on more content
|
||||
|
||||
return framesRead;
|
||||
}
|
||||
|
||||
|
@ -926,6 +926,10 @@ int main (const int argc, char* argv[])
|
||||
else
|
||||
if (enableResampler) eaApplyDownsampler (inPcmData, inPcmRsmp, frameLength, numChannels, true);
|
||||
}
|
||||
// extrapolate samples in padding region of first frame since exhaleLib can't
|
||||
// take over this job when inPadLength > 0. Improves gapless playback.
|
||||
else if (inPadLength > 0) eaExtrapolate (inPcmData, inPadLength, frameLength, numChannels, true); // fade-in
|
||||
|
||||
// signal 1-frame skip and PCM priming
|
||||
outAuData[0] = 1 | zeroDelayForSbrEncoding * (uint8_t) __min (254, (firstLength - inPadLength) << (resampShift + 1));
|
||||
#endif
|
||||
@ -1356,28 +1360,13 @@ int main (const int argc, char* argv[])
|
||||
mainFinish:
|
||||
|
||||
// free all dynamic memory
|
||||
if (inPcmData != nullptr)
|
||||
{
|
||||
free ((void*) inPcmData);
|
||||
inPcmData = nullptr;
|
||||
}
|
||||
if (inPcmRsmp != nullptr)
|
||||
{
|
||||
free ((void*) inPcmRsmp);
|
||||
inPcmRsmp = nullptr;
|
||||
}
|
||||
MFREE (inPcmData);
|
||||
MFREE (inPcmRsmp);
|
||||
#if EA_USE_WORK_DIR
|
||||
if (currPath != nullptr)
|
||||
{
|
||||
free ((void*) currPath);
|
||||
currPath = nullptr;
|
||||
}
|
||||
MFREE (currPath);
|
||||
#endif
|
||||
if (outAuData != nullptr)
|
||||
{
|
||||
free ((void*) outAuData);
|
||||
outAuData = nullptr;
|
||||
}
|
||||
MFREE (outAuData);
|
||||
|
||||
// close input file
|
||||
if (inFileHandle != -1)
|
||||
{
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
0 ICON "exhaleApp.ico"
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,1,8
|
||||
FILEVERSION 1,1,8,1
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* exhaleAppPch.cpp - pre-compiled source file for source code of exhale application
|
||||
* written by C. R. Helmrich, last modified in 2020 - see License.htm for legal notices
|
||||
* written by C. R. Helmrich, last modified in 2021 - see License.htm for legal notices
|
||||
*
|
||||
* The copyright in this software is being made available under the exhale Copyright License
|
||||
* and comes with ABSOLUTELY NO WARRANTY. This software may be subject to other third-
|
||||
@ -16,6 +16,25 @@ static const unsigned supportedSamplingRates[16] = {
|
||||
57600, 38400, 19200 // BL USAC
|
||||
};
|
||||
|
||||
// public extrapolation function
|
||||
void eaExtrapolate (int32_t* const pcmBuffer, const uint16_t pcmOffset, // start/end of PCM fades
|
||||
const uint16_t frameSize, const uint16_t numChannels, const bool fadeIn /*= false*/)
|
||||
{
|
||||
const int32_t delta = (fadeIn ? -1 : 1) * numChannels;
|
||||
const uint16_t size = (fadeIn ? pcmOffset : frameSize - pcmOffset);
|
||||
|
||||
if ((pcmOffset == 0 && fadeIn) || (pcmOffset >= frameSize) || !pcmBuffer) return;
|
||||
|
||||
for (uint16_t ch = 0; ch < numChannels; ch++)
|
||||
{
|
||||
int32_t* chPcmBuf = pcmBuffer + ch + (pcmOffset - (fadeIn ? 0 : 1)) * numChannels;
|
||||
int32_t result32 = (pcmOffset == 0 ? 0 : *chPcmBuf << 8); // input is known to be 24-bit PCM
|
||||
const int32_t s32 = result32 / size;
|
||||
|
||||
for (uint16_t i = size; i > 0; i--) *(chPcmBuf += delta) = ((result32 -= s32) + 128) >> 8;
|
||||
}
|
||||
}
|
||||
|
||||
// public sampling rate function
|
||||
bool isSamplingRateSupported (const unsigned samplingRate)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* exhaleAppPch.h - pre-compiled header file for source code of exhale application
|
||||
* written by C. R. Helmrich, last modified in 2020 - see License.htm for legal notices
|
||||
* written by C. R. Helmrich, last modified in 2021 - see License.htm for legal notices
|
||||
*
|
||||
* The copyright in this software is being made available under the exhale Copyright License
|
||||
* and comes with ABSOLUTELY NO WARRANTY. This software may be subject to other third-
|
||||
@ -45,6 +45,13 @@
|
||||
#if !defined (fwprintf_s) && !defined (__MINGW32__)
|
||||
# define fwprintf_s fwprintf
|
||||
#endif
|
||||
#ifndef MFREE
|
||||
# define MFREE(x) if (x != nullptr) { free ((void*) x); x = nullptr; }
|
||||
#endif
|
||||
|
||||
// public extrapolation function
|
||||
void eaExtrapolate (int32_t* const pcmBuffer, const uint16_t pcmOffset,
|
||||
const uint16_t frameSize, const uint16_t numChannels, const bool fadeIn = false);
|
||||
|
||||
// public sampling rate function
|
||||
bool isSamplingRateSupported (const unsigned samplingRate);
|
||||
|
Loading…
x
Reference in New Issue
Block a user