Skip to content

Commit

Permalink
Fix garbage in exported audio caused by resampling (LMMS#5552)
Browse files Browse the repository at this point in the history
This makes AudioDevice::resample return the actual number of generated samples.
  • Loading branch information
thmueller64 authored Jul 10, 2020
1 parent 3ab0103 commit e2bbce8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion include/AudioDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class AudioDevice
const fpp_t _frames );

// resample given buffer from samplerate _src_sr to samplerate _dst_sr
void resample( const surroundSampleFrame * _src,
fpp_t resample( const surroundSampleFrame * _src,
const fpp_t _frames,
surroundSampleFrame * _dst,
const sample_rate_t _src_sr,
Expand Down
11 changes: 5 additions & 6 deletions src/core/audio/AudioDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,8 @@ fpp_t AudioDevice::getNextBuffer( surroundSampleFrame * _ab )
// resample if necessary
if( mixer()->processingSampleRate() != m_sampleRate )
{
resample( b, frames, _ab, mixer()->processingSampleRate(),
m_sampleRate );
frames = frames * m_sampleRate /
mixer()->processingSampleRate();
frames = resample( b, frames, _ab, mixer()->processingSampleRate(),
m_sampleRate );
}
else
{
Expand Down Expand Up @@ -184,15 +182,15 @@ void AudioDevice::renamePort( AudioPort * )



void AudioDevice::resample( const surroundSampleFrame * _src,
fpp_t AudioDevice::resample( const surroundSampleFrame * _src,
const fpp_t _frames,
surroundSampleFrame * _dst,
const sample_rate_t _src_sr,
const sample_rate_t _dst_sr )
{
if( m_srcState == NULL )
{
return;
return _frames;
}
m_srcData.input_frames = _frames;
m_srcData.output_frames = _frames;
Expand All @@ -206,6 +204,7 @@ void AudioDevice::resample( const surroundSampleFrame * _src,
printf( "AudioDevice::resample(): error while resampling: %s\n",
src_strerror( error ) );
}
return static_cast<fpp_t>(m_srcData.output_frames_gen);
}


Expand Down

0 comments on commit e2bbce8

Please sign in to comment.