IPB

Welcome Guest ( Log In | Register )

foo_dsp_invhardlimit (for fb2k 1.1+), Inversion of “Hard -6dB limiter”
lvqcl
post Jun 14 2012, 15:55
Post #1





Group: Developer
Posts: 3328
Joined: 2-December 07
Member No.: 49183



DLL: Attached File  foo_dsp_invhardlimit.zip ( 98.5K ) Number of downloads: 599


Code:
CODE
#include "../SDK/foobar2000.h"
#include <boost\math\special_functions\atanh.hpp>

DECLARE_COMPONENT_VERSION("Hard Limiter Inversion", "0.0.1", "");

class dsp_invlimiter : public dsp_impl_base
{
public:
dsp_invlimiter() {}

static GUID g_get_guid() { // {C4688FBC-CCB3-4F35-8F13-E8F1760FBD32}
static const GUID guid = { 0xc4688fbc, 0xccb3, 0x4f35, { 0x8f, 0x13, 0xe8, 0xf1, 0x76, 0xf, 0xbd, 0x32 } };
return guid;
}

static void g_get_name(pfc::string_base & p_out) { p_out = "Invert HardLimiter"; }

static bool g_have_config_popup() { return false; }

virtual void on_endoftrack(abort_callback & p_abort) { }

virtual void on_endofplayback(abort_callback & p_abort) { }

virtual void flush() {}

virtual double get_latency() { return 0.0; }

virtual bool need_track_change_mark() { return false; }

virtual bool on_chunk(audio_chunk * chunk, abort_callback & p_abort)
{
static const float limiter_max = 0.9999f;
static const float limiter_max_05 = limiter_max - 0.5f;

audio_sample * ptr = chunk->get_data();
t_size n;
for(n = chunk->get_data_length(); n; --n)
{
double val = *ptr;

if (val < -0.5)
{
if (val < -limiter_max + DBL_EPSILON) val = -limiter_max + DBL_EPSILON;
val = (boost::math::atanh((val + 0.5) / limiter_max_05) * limiter_max_05 - 0.5);
}
else if (val > 0.5)
{
if (val > limiter_max - DBL_EPSILON) val = limiter_max - DBL_EPSILON;
val = (boost::math::atanh((val - 0.5) / limiter_max_05) * limiter_max_05 + 0.5);
}

*ptr = (audio_sample) val;
ptr++;
}
return true;
}
};

static dsp_factory_nopreset_t<dsp_invlimiter> foo_dsp_invlimiter;


The idea is to cancel the effect of a limiter in foo_dsp_winamp.

This post has been edited by lvqcl: Jun 14 2012, 16:04
Go to the top of the page
+Quote Post

Posts in this topic
- lvqcl   foo_dsp_invhardlimit (for fb2k 1.1+)   Jun 14 2012, 15:55
- - DJ_DOGGY   Instead of this , try to find the source of the fo...   Jun 4 2013, 18:44
- - lvqcl   RE: foo_dsp_invhardlimit (for fb2k 1.1+)   Jun 4 2013, 19:06
- - mudlord   No.   Feb 15 2014, 06:32


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 25th July 2014 - 22:14