Skip to content

Commit

Permalink
Resample SampleBuffer only once when loading from SampleClip (#6594)
Browse files Browse the repository at this point in the history
The SampleBuffer's sample rate in SampleClip was altered twice during
SampleClip::loadSettings: first when setSampleFile was called,
which set the sample rate of the SampleBuffer to the AudioEngine's
sample rate (good), and a second time when calling setSampleRate,
which set it to the sample rate specified within the project file (bad).
This led to the sample rate of the buffer being different than that of
the project, resulting in it being pitched incorrectly on playback.
  • Loading branch information
sakertooth committed Jan 3, 2023
1 parent d95c897 commit 679d632
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/core/SampleClip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,15 +292,15 @@ void SampleClip::loadSettings( const QDomElement & _this )
if( sampleFile().isEmpty() && _this.hasAttribute( "data" ) )
{
m_sampleBuffer->loadFromBase64( _this.attribute( "data" ) );
if (_this.hasAttribute("sample_rate"))
{
m_sampleBuffer->setSampleRate(_this.attribute("sample_rate").toInt());
}
}
changeLength( _this.attribute( "len" ).toInt() );
setMuted( _this.attribute( "muted" ).toInt() );
setStartTimeOffset( _this.attribute( "off" ).toInt() );

if ( _this.hasAttribute( "sample_rate" ) ) {
m_sampleBuffer->setSampleRate( _this.attribute( "sample_rate" ).toInt() );
}

if( _this.hasAttribute( "color" ) )
{
useCustomClipColor( true );
Expand Down

0 comments on commit 679d632

Please sign in to comment.