velipso / sndfilter Goto Github PK
View Code? Open in Web Editor NEWAlgorithms for sound filters, like reverb, dynamic range compression, lowpass, highpass, notch, etc
License: BSD Zero Clause License
Algorithms for sound filters, like reverb, dynamic range compression, lowpass, highpass, notch, etc
License: BSD Zero Clause License
Hi, first of all Thank you so much for your amazing works.
I tried using your reverb and it works well and sounds very good.
But it seems like it is pretty heavy in terms of CPU usage.
I wonder if you have any suggestion to reduce it's CPU usage other than reducing the channel to mono.
Thanks!
The only explicit means of changing the reverb wetness/dryness is by repopulating the reverb structure with the same parameters but with different wet/dry values. This seems cumbersome for the computer. What am I missing?
Hello, first of all, nice work. :squirrel:
I'm working on an opensource code that will be released under a permissive license and i have add some reverberation to an audio source, your reverb implementation is exactly what im looking for, but i've read the readme and it says
The reverb effect is a complete rewrite of Freeverb3's Progenitor2 algorithm.
afaik Freeverb3 is a gnu library under gnu gpl license, due to the properties of this license, shouldn't this code be licensed under gpl aswell?
https://github.com/voidqk/sndfilter/blob/master/src/reverb.c#L128
static inline float iir1_step(sf_rv_iir1_st *iir1, float v){
float out = v * iir1->b1 + iir1->y1;
iir1->y1 = out * iir1->a2 + v * iir1->b2;
return out;
}
I think that should be:
iir1->y1 = out * iir1->a2 - v * iir1->b2;
need to confirm
The function oversample_stepdown appears to put the samples through the recovery low pass filter but always returns the first input value. I think it should look more like this:
// input length must be oversample->factor
static float oversample_stepdown(sf_rv_oversample_st *oversample, float *input)
{
if (oversample->factor == 1)
{
return input[0];
}
else
{
int i;
float accum = 0.0f;
for (i = 0; i < oversample->factor; i++)
{
accum += biquad_step(&oversample->lpfD, input[i]);
}
accum /= (float)oversample->factor;
return accum;
}
}
In the biquad_makeLPF
function in reverb.c
:
static inline void biquad_makeLPF(sf_rv_biquad_st *biquad, int rate, float freq, float bw){
freq = clampf(freq, 0, rate / 2);
float omega = 2.0f * (float)M_PI * freq / (float)rate;
float cs = cosf(omega);
float sn = sinf(omega);
float alpha = sn * sinhf((float)M_LN2 * 0.5f * bw * omega / sn);
float a0inv = 1.0f / (1.0f + alpha);
biquad->b0 = a0inv * (1.0f - cs) * 0.5f;
biquad->b1 = 2.0f * biquad->b0;
biquad->b2 = biquad->b0;
biquad->a1 = a0inv * -2.0f * cs;
biquad->a2 = a0inv * (1.0f - alpha);
biquad->xn1 = 0;
biquad->xn2 = 0;
biquad->yn1 = 0;
biquad->yn2 = 0;
}
If rate
is integral multiple of freq
, then omega
will be integral multiple of PI
, and sn = sinf(M_PI)
is 0, sn
is used as a divisor for calculating alpha
, the result of alpha
will be INFINITY
, which causes any other values to be NaN
when calculated with alpha
.
Can I test the value of alpha
with isinf()
, if it is true, assign a valid value to it? But what is the valid value range of alpha
? Or what is the valid value for it if it is INFINITY
?
Your classes are very good.
How about altering the compressor to support a) upward (compress when audio is below threshold) and b) expand (increase range instead of reduce it by ratio).
Are you sure this is working right?
sf_advancecomp(&STX[i], 48000, 0, -40, 0, 10, 0.25f, 0.15f,
0.006f, // predelay
0.090f, // releasezone1
0.160f, // releasezone2
0.420f, // releasezone3
0.980f, // releasezone4
0.000f, // postgain
1.000f // wet
);
Now this is fed with a 512-sample array
And the result is (at sample 287)
Is there some extra gain added?
I'm using sndfilter biquad filter as a chain of filters, i.e. combining lowshelf, peaking and highshelf filters.
In general, the equalizer should not over amplify the audio with the params I use.
I can see that you have ported Web Audio API biquad filter and the code is almost the same, but it results in completely different output.
GarageBand is just an example, we will get almost the same result with other tools.
Could you please confirm whether this behavior is expected or maybe it's a known issue?
Download drum-beat.wav
sndfilter drum-beat.wav filtered.wav lowshelf 250 1 20
sndfilter filtered.wav filtered.wav peaking 500 3 20
You can reproduce it only by using lowshelf or peaking, but it's more demonstrative when combining them too.
And also biquad filters affect only starting from around 1.3 seconds of the input audio. This is a separate issue BTW.
It 'd be nice to be able to add a parameter for sidechain: Different input signal than output signal.
So for example, sf_compressor_process with an additional input 2: If the input 2 is above threshold, then compress input 1.
I have ported the lib to my Android project, the algorithm works well, but it is time cost. Can you give me some suggestion about this? Should I reduce some parameters or reduce effect quality?
Hiya - I'm wondering how to go about using the compressor in a context of streaming since it's using a chunk size of 32 and so always return <= the input buffer.
Hi voidqk!
I'm very interesting with your dynamic range compressor project.
i'm making it like you (nuc505 and Keil C), but i have some issues and i really want to get a wav file to test your code.
Could you send me a link to download it?
Thanks
P/s: sorry about my English skill.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.