MixerToy: do an initialisation run on the mixer

The Interpolating mixer has internal state which must be setup by a
previous frame (we assume 0 for the first frame). Since we work on
exactly a period of the wave here, sending the same data twice works as
it should.
This commit is contained in:
Adrien Destugues 2014-12-08 18:51:47 +01:00
parent 258fbe371b
commit dab42bf05b

View File

@ -266,6 +266,12 @@ MainWindow::MessageReceived(BMessage* message)
Interpolate sampler(media_raw_audio_format::B_AUDIO_FLOAT, Interpolate sampler(media_raw_audio_format::B_AUDIO_FLOAT,
media_raw_audio_format::B_AUDIO_FLOAT); media_raw_audio_format::B_AUDIO_FLOAT);
// First call initializes the "old sample" in the interpolator.
// Since we do the interpolation on exactly one period of the
// sound wave, this works.
sampler.Resample(fWaveView->waves[1].Raw(), sizeof(float), irate,
fWaveView->waves[2].Raw(), sizeof(float), orate, 1);
sampler.Resample(fWaveView->waves[1].Raw(), sizeof(float), irate, sampler.Resample(fWaveView->waves[1].Raw(), sizeof(float), irate,
fWaveView->waves[2].Raw(), sizeof(float), orate, 1); fWaveView->waves[2].Raw(), sizeof(float), orate, 1);
} else { } else {