From dab42bf05b6f701f35564bd8f1cde771e97f78f1 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Mon, 8 Dec 2014 18:51:47 +0100 Subject: [PATCH] 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. --- src/tests/add-ons/media/media-add-ons/mixer/main.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/tests/add-ons/media/media-add-ons/mixer/main.cpp b/src/tests/add-ons/media/media-add-ons/mixer/main.cpp index 3caf843891..b30edb48bb 100644 --- a/src/tests/add-ons/media/media-add-ons/mixer/main.cpp +++ b/src/tests/add-ons/media/media-add-ons/mixer/main.cpp @@ -266,6 +266,12 @@ MainWindow::MessageReceived(BMessage* message) Interpolate sampler(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, fWaveView->waves[2].Raw(), sizeof(float), orate, 1); } else {