Merge pull request #1150 from manongjohn/fix_sound_rendering_badly

Fix mixing multiple audio + rendering 32bit float sound
This commit is contained in:
manongjohn 2023-04-06 22:33:35 -04:00 committed by GitHub
commit 9cfb5933e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 6 deletions

View file

@ -37,7 +37,8 @@ TSoundTrack::TSoundTrack(TUINT32 sampleRate, int bitPerSample, int channelCount,
, m_sampleCount(sampleCount) , m_sampleCount(sampleCount)
, m_channelCount(channelCount) , m_channelCount(channelCount)
, m_parent(0) , m_parent(0)
, m_bufferOwner(true) { , m_bufferOwner(true)
, m_sampleType(sampleType) {
m_buffer = (UCHAR *)malloc(sampleCount * m_sampleSize); m_buffer = (UCHAR *)malloc(sampleCount * m_sampleSize);
if (!m_buffer) return; if (!m_buffer) return;

View file

@ -212,7 +212,8 @@ void Ffmpeg::saveSoundTrack(TSoundTrack *st) {
m_audioPath = getFfmpegCache().getQString() + "//" + m_audioPath = getFfmpegCache().getQString() + "//" +
QString::fromStdString(m_path.getName()) + "tempOut.raw"; QString::fromStdString(m_path.getName()) + "tempOut.raw";
m_audioFormat = "s" + QString::number(m_bitsPerSample); m_audioFormat = ((st->getSampleType() == TSound::FLOAT) ? "f" : "s") +
QString::number(m_bitsPerSample);
if (m_bitsPerSample > 8) m_audioFormat = m_audioFormat + "le"; if (m_bitsPerSample > 8) m_audioFormat = m_audioFormat + "le";
std::string strPath = m_audioPath.toStdString(); std::string strPath = m_audioPath.toStdString();

View file

@ -1082,12 +1082,8 @@ TSoundTrackP TXshSoundColumn::getOverallSoundTrack(int fromFrame, int toFrame,
if (s1 > 0 && s1 >= s0) { if (s1 > 0 && s1 >= s0) {
soundTrack = soundTrack->extract(s0, s1); soundTrack = soundTrack->extract(s0, s1);
if (format.m_sampleType != TSound::FLOAT)
overallSoundTrack->copy( overallSoundTrack->copy(
soundTrack, int((levelStartFrame - fromFrame) * samplePerFrame)); soundTrack, int((levelStartFrame - fromFrame) * samplePerFrame));
else
overallSoundTrack->copy(
soundTrack, double((levelStartFrame - fromFrame) * samplePerFrame));
} }
} }
return overallSoundTrack; return overallSoundTrack;