tim-janik / beast

Beast - Music Synthesizer and Composer
GNU Lesser General Public License v2.1
83 stars 12 forks source link

Resampler cleanups #125

Closed swesterfeld closed 4 years ago

swesterfeld commented 4 years ago

I cleaned up the resampling code:

Plugins (LadderFilter) for now can use Resampler2::create (..., false) to force using FPU resampling. As soon as the engine guarantees SSE-alignment of input/output blocks, this can be removed.

The old Makefile.am had more "testresampler" style tests, these could be added.

swesterfeld commented 4 years ago

Since this PR wasn't merged yet, I simply force pushed an updated version. Since we have no more C API, I could modernize the C++ API. It should be used like this:

  float input[128];
  float output[256];
  Resampler2 resampler (Resampler2::UP, Resampler2::PREC_96DB);
  resampler.process_block (input, 128, output);

Note that process_block() still needs a virtual function call (like it used to be), but I did some benchmarking before refactoring the API. The performance difference between virtual function call and inlined resampler code is minimal. Like this, I could move all implementation bits back into bseresampler.cc, so bseresampler.hh is really clean and doesn't contain any actual resampling code, and bseresamplerimpl.hh could be removed.

I also re-added the old testresampler tests from the Makefile.am, these are added using TEST_SLOW, so out/tests/suite1 --slow is needed to run the tests. I also re-enabled the standalone testcode, passing args to the standalone main() from suite1 main()

$ testresampler perf # OLD
$ out/tests/suite1 --resampler perf # NEW

Btw, if you are interested in the impact of the block size on performance, here is upsampling with different block sizes (times in ns/sample) upsampling, PREC48_DB.

4 5.1589
8 3.52419
16 3.80419
32 3.079
64 2.48795
128 2.25006
256 2.09908
512 2.019

I recommend merging this PR first, then I can update the LadderFilter PR (https://github.com/tim-janik/beast/pull/122) to use the new resampling API, then merge the LadderFilter.

tim-janik commented 4 years ago

Your branch is merged, but the --resampler options needs fixing.