COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 09-25-2017, 05:58 AM   #1
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 264
Default What is wrong with this code?

Hi,

I'm trying to build simple compressor.

Everything is fine.I can see that compressor is working on meter with seekgain.But i can't make it work with "gain".There is no any process.

Code:
    double gain = seekgain = 1;
    double c = 8.65617025;
    
    double t = 0;
    double b = -exp(-62.83185307 / GetSampleRate() );
    double a = 1.0 + b;
    
    double threshDB = mThr;
    double thresh = exp(threshDB/c);
    double ratio = 1/20;
    
    double attack = exp( threshDB / (10*GetSampleRate()/1000) / c);
    double release = exp( threshDB / (100*GetSampleRate()/1000) / c );
    
    
  
    
    seekgain = 1;
    
    double rms = std::max( fabs(*in1) , fabs(*in2) );
    rms = std::max( sqrt( (t = a*rms-b*t) ) , rms);
    
    if (rms > thresh)
      seekgain = exp((threshDB + (log(rms)*c-threshDB)*ratio) /c) / rms;
    else
      seekgain = 1;
    
    
    
    if (gain > seekgain)
      gain = std::max( gain*attack , seekgain );
    else
      gain = std::min( gain/release , seekgain );
    
    *out1 = *in1 * gain ;
    *out2 = *in2 * gain ;
Tunca is offline   Reply With Quote
Old 09-28-2017, 08:10 AM   #2
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 264
Default

Really? No one?
Tunca is offline   Reply With Quote
Old 09-28-2017, 08:13 AM   #3
Youlean
Human being with feelings
 
Youlean's Avatar
 
Join Date: May 2015
Location: Serbia
Posts: 654
Default

I would suggest you to go with something simpler than C++ like NI Reactor until you understand how dsp works.
__________________
Website | Facebook Page | IPlug-Youlean
Youlean is offline   Reply With Quote
Old 09-28-2017, 08:33 AM   #4
Youlean
Human being with feelings
 
Youlean's Avatar
 
Join Date: May 2015
Location: Serbia
Posts: 654
Default

Also, you got your answers here: http://www.kvraudio.com/forum/viewto...?f=33&t=491706
__________________
Website | Facebook Page | IPlug-Youlean
Youlean is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 01:40 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.