zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit 83d179e45ee1faaab92c1a20eb4963d2cc5f6272
parent c46df0ff88997a61d45881d4f97320a1c97647dd
Author: fundamental <[email protected]>
Date:   Fri, 23 Oct 2015 11:17:07 -0400

Fl_EQGraph: Add Gain Back To Display

Resolves sf bug #85

Diffstat:
Msrc/UI/Fl_EQGraph.H | 1+
Msrc/UI/Fl_EQGraph.cpp | 7+++++--
2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/UI/Fl_EQGraph.H b/src/UI/Fl_EQGraph.H @@ -24,6 +24,7 @@ class Fl_EQGraph:public Fl_Box, public Fl_Osc_Widget float getfreqpos(float freq) const; float samplerate; + float gain; float num[MAX_EQ_BANDS*MAX_FILTER_STAGES*3]; float dem[MAX_EQ_BANDS*MAX_FILTER_STAGES*3]; }; diff --git a/src/UI/Fl_EQGraph.cpp b/src/UI/Fl_EQGraph.cpp @@ -11,7 +11,7 @@ #define MAX_DB 30 Fl_EQGraph::Fl_EQGraph(int x,int y, int w, int h, const char *label) - :Fl_Box(x,y,w,h,label), Fl_Osc_Widget(this), samplerate(48000) + :Fl_Box(x,y,w,h,label), Fl_Osc_Widget(this), samplerate(48000), gain(0.5f) { memset(num, 0, sizeof(num)); memset(dem, 0, sizeof(dem)); @@ -21,6 +21,7 @@ Fl_EQGraph::Fl_EQGraph(int x,int y, int w, int h, const char *label) osc->createLink("/samplerate", this); osc->requestValue("/samplerate"); oscRegister("eq-coeffs"); + oscRegister("parameter0"); } Fl_EQGraph::~Fl_EQGraph(void) @@ -30,6 +31,8 @@ void Fl_EQGraph::OSC_raw(const char *msg) { if(strstr(msg, "samplerate") && !strcmp("f", rtosc_argument_string(msg))) { samplerate = rtosc_argument(msg, 0).f; + } else if(strstr(msg, "parameter0") && !strcmp("i", rtosc_argument_string(msg))) { + gain = powf(0.005f, (1.0f-rtosc_argument(msg, 0).i/127.0f)) * 10.0f; } else { memcpy(dem, rtosc_argument(msg, 0).b.data, sizeof(dem)); memcpy(num, rtosc_argument(msg, 1).b.data, sizeof(num)); @@ -158,7 +161,7 @@ double Fl_EQGraph::getresponse(int maxy,float freq) const mag *= abs(num_res/dem_res); } - float dbresp=20*log(mag)/log(10); + float dbresp=20*log(mag*gain)/log(10); //rescale return (int) ((dbresp/MAX_DB+1.0)*maxy/2.0);