Giter VIP home page Giter VIP logo

Comments (5)

velipso avatar velipso commented on June 19, 2024

I haven't looked at this in a while, but that does look wrong.

Here's the code in Freeverb3 that I was attempting to clean up (I think):

http://git.savannah.gnu.org/cgit/freeverb3.git/tree/freeverb/src.cpp#n159

void FV3_(src)::src_d_iir2(fv3_float_t *input, fv3_float_t *output, long factor, long numsamples, FV3_(biquad) * iir)
{
  for(long i = 0;i < numsamples*factor;i ++) input[i] = iir->process(input[i]);
  for(long i = 0;i < numsamples;i ++) output[i] = input[factor*i];
}

They're processing in blocks, whereas I'm processing one sample at a time. So you can think of it as hard-coding numsamples to 1.

Original code in sndfilter:

// input length must be oversample->factor
static inline float oversample_stepdown(sf_rv_oversample_st *oversample, float *input){
  if (oversample->factor == 1)
    return input[0];
  for (int i = 0; i < oversample->factor; i++)
    biquad_step(&oversample->lpfD, input[i]);
  return input[0];
}

I think what I'm missing is saving the return value of biquad_step:

  for (int i = 0; i < oversample->factor; i++)
    input[i] = biquad_step(&oversample->lpfD, input[i]);
  return input[0];

Now, I'd rather not stomp the input array, so instead I should do something like:

// input length must be oversample->factor
static inline float oversample_stepdown(sf_rv_oversample_st *oversample, float *input){
  if (oversample->factor == 1)
    return input[0];
  float out = biquad_step(&oversample->lpfD, input[0]);
  for (int i = 1; i < oversample->factor; i++)
    biquad_step(&oversample->lpfD, input[i]);
  return out;
}

That seems like it matches the spirit of Freeverb3. What do you think?

from sndfilter.

SwarmSysUser avatar SwarmSysUser commented on June 19, 2024

Well that certainly looks like what the code is doing.

from sndfilter.

SwarmSysUser avatar SwarmSysUser commented on June 19, 2024

Also the code does not flush denormal numbers to zero. Do you configure the FCU to do this?

from sndfilter.

velipso avatar velipso commented on June 19, 2024

no, I debated whether to do optimizations like that, and decided against it to aid in readability... I think there are a lot of optimizations that could be done on the code (ex: iirc, Apple provides hardware instructions for doing biquad math on a buffer, which Chromium uses but I don't), but wanted to try and remain as simple as possible, so it was more accessible

I'm about to push up the fix

from sndfilter.

velipso avatar velipso commented on June 19, 2024

I just added a note to the readme to make it clear I favored simple over fast.

Thanks for bringing up these issues!

from sndfilter.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.