Giter VIP home page Giter VIP logo

Comments (5)

cuinjune avatar cuinjune commented on July 19, 2024 3

Thank you for your brilliant suggestion.

First of all, reducing the oversampling amount didn't really help.
So I tried commenting out sections one by one as you suggested and the diffusion part turned out to be the most expensive section.

After some tests, I decided to comment out diffusion, cross fade and bass boost sections and it still sounded like a reverb :)

The original version used about 53 ~ 55% CPU for running 10 reverbs on my Macbook Pro.
And after commenting out the 3 sections, now it uses about 32 ~ 34% CPU.
I think it's okay to use for desktop applications but maybe a bit too expensive for mobiles.

Other than the performance issue, I think the reverb is really decent :)
Once again, Thank you so much!

from sndfilter.

velipso avatar velipso commented on July 19, 2024

Here are some ideas -- I haven't tried these, this is just off the top of my head. Give these a try and see what helps and what is acceptable.

You can reduce the oversampling by changing reverb.h:

#define SF_REVERB_OF 4

Try 1 to disable oversampling entirely, or 2 or 3 to just perform less oversampling.

Or you can start commenting out sections of the algorithm inside the sf_reverb_process function in reverb.c:

for (int i = 0; i < size; i++){
	// early reflection
	// ...

	// oversample the single input into multiple outputs
	// ...

	// for each oversampled sample...
	for (int i2 = 0; i2 < rv->oversampleL.factor; i2++){
		// dc cut
		// ...

		// noise
		// ...

		// diffusion
		// ...

		// cross fade
		// ...

		// bass boost
		// ...

		// dampening
		// ...

		// update cross fade bass boost delay
		// ...

		//
		float D1 = ...
		// delay stuff...

		osL[i2] = ... final oversampled output
		osR[i2] = ... final oversampled output
	}

	// ...reverse oversample
	output[i] = (sf_sample_st){ outL, outR };
}

In particular, the the following regions might be good candidates for commenting out:

  • dc cut
  • noise
  • diffusion
  • cross fade
  • bass boost
  • dampening
  • update cross fade bass boost delay

Don't be intimidated by the formulas and what they're doing. Just try things and see. Most sections don't rely on the previous sections, and everything is mostly just stepping forwards modifying the sample one stage at a time. Just follow the variables.

from sndfilter.

velipso avatar velipso commented on July 19, 2024

Also for anyone else wondering: reducing the channels to mono would require a bit of changes to the source code. The current code processes stereo exclusively.

from sndfilter.

neevek avatar neevek commented on July 19, 2024

Also for anyone else wondering: reducing the channels to mono would require a bit of changes to the source code. The current code processes stereo exclusively.

I am new to all this DSP thing. I need mono support for this library, I have looked into the code, I can see that some calculations exchanged L and R samples, what's your suggestions for a newbie like me to start making it support mono?

from sndfilter.

velipso avatar velipso commented on July 19, 2024

I would change things one step at a time, and check the results. Start by making a WAV file with left and right channels the same, and send it through the reverb.

Then start removing/simplifying parts. Each step of the way, run through the same file, and make sure it doesn't sound drastically different.

If I remember correctly, some parts of the processing are strictly for bouncing the signal between L and R -- you could remove those entirely.

Just take your time; it's a little tedious, but that's how it goes.

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.