remove debug output
[ardour.git] / gtk2_ardour / plugin_eq_gui.cc
index fb9a0dc337d2485c97effd5b884644ebec6c6821..7479ae08166ee5ad844c01e0f927923ee53d9f40 100644 (file)
 
 using namespace ARDOUR;
 
-PluginEqGui::PluginEqGui(boost::shared_ptr<ARDOUR::PluginInsert> pluginInsert)
-       : _min_dB(-12.0)
-       , _max_dB(+12.0)
-       , _step_dB(3.0)
-       , _block_size(0)
-       , _buffer_size(0)
-       , _signal_buffer_size(0)
-       , _impulse_fft(0)
-       , _signal_input_fft(0)
-       , _signal_output_fft(0)
-       , _plugin_insert(pluginInsert)
-       , _pointer_in_area_xpos(-1)
+PluginEqGui::PluginEqGui (boost::shared_ptr<ARDOUR::PluginInsert> pluginInsert)
+       : _min_dB (-12.0)
+       , _max_dB (+12.0)
+       , _step_dB (3.0)
+       , _block_size (0)
+       , _buffer_size (0)
+       , _signal_buffer_size (0)
+       , _impulse_fft (0)
+       , _signal_input_fft (0)
+       , _signal_output_fft (0)
+       , _plugin_insert (pluginInsert)
+       , _pointer_in_area_xpos (-1)
 {
        _signal_analysis_running = false;
        _samplerate = ARDOUR_UI::instance()->the_session()->sample_rate();
 
-       _log_coeff = (1.0 - 2.0 * (1000.0/(_samplerate/2.0))) / powf(1000.0/(_samplerate/2.0), 2.0);
-       _log_max = log10f(1 + _log_coeff);
+       _log_coeff = (1.0 - 2.0 * (1000.0 / (_samplerate / 2.0))) / powf (1000.0 / (_samplerate / 2.0), 2.0);
+       _log_max = log10f (1 + _log_coeff);
 
        // Setup analysis drawing area
        _analysis_scale_surface = 0;
@@ -78,17 +78,17 @@ PluginEqGui::PluginEqGui(boost::shared_ptr<ARDOUR::PluginInsert> pluginInsert)
        _analysis_area = new Gtk::DrawingArea();
        _analysis_width = 256.0;
        _analysis_height = 256.0;
-       _analysis_area->set_size_request(_analysis_width, _analysis_height);
+       _analysis_area->set_size_request (_analysis_width, _analysis_height);
 
-       _analysis_area->add_events(Gdk::POINTER_MOTION_MASK | Gdk::LEAVE_NOTIFY_MASK | Gdk::BUTTON_PRESS_MASK);
+       _analysis_area->add_events (Gdk::POINTER_MOTION_MASK | Gdk::LEAVE_NOTIFY_MASK | Gdk::BUTTON_PRESS_MASK);
 
-       _analysis_area->signal_expose_event().connectsigc::mem_fun (*this, &PluginEqGui::expose_analysis_area));
-       _analysis_area->signal_size_allocate().connectsigc::mem_fun (*this, &PluginEqGui::resize_analysis_area));
-       _analysis_area->signal_motion_notify_event().connectsigc::mem_fun (*this, &PluginEqGui::analysis_area_mouseover));
-       _analysis_area->signal_leave_notify_event().connectsigc::mem_fun (*this, &PluginEqGui::analysis_area_mouseexit));
+       _analysis_area->signal_expose_event().connect (sigc::mem_fun (*this, &PluginEqGui::expose_analysis_area));
+       _analysis_area->signal_size_allocate().connect (sigc::mem_fun (*this, &PluginEqGui::resize_analysis_area));
+       _analysis_area->signal_motion_notify_event().connect (sigc::mem_fun (*this, &PluginEqGui::analysis_area_mouseover));
+       _analysis_area->signal_leave_notify_event().connect (sigc::mem_fun (*this, &PluginEqGui::analysis_area_mouseexit));
 
        // dB selection
-       dBScaleModel = Gtk::ListStore::create(dBColumns);
+       dBScaleModel = Gtk::ListStore::create (dBColumns);
 
        dBScaleCombo = new Gtk::ComboBox (dBScaleModel, false);
        dBScaleCombo->set_title (_("dB scale"));
@@ -113,13 +113,13 @@ PluginEqGui::PluginEqGui(boost::shared_ptr<ARDOUR::PluginInsert> pluginInsert)
        dBScaleCombo -> pack_start(dBColumns.name);
        dBScaleCombo -> set_active(1);
 
-       dBScaleCombo -> signal_changed().connect( sigc::mem_fun(*this, &PluginEqGui::change_dB_scale) );
+       dBScaleCombo -> signal_changed().connect (sigc::mem_fun(*this, &PluginEqGui::change_dB_scale));
 
        Gtk::Label *dBComboLabel = new Gtk::Label (_("dB scale"));
 
-       Gtk::HBox *dBSelectBin = new Gtk::HBox(false, 5);
-       dBSelectBin->add*manage(dBComboLabel));
-       dBSelectBin->add*manage(dBScaleCombo));
+       Gtk::HBox *dBSelectBin = new Gtk::HBox (false, 5);
+       dBSelectBin->add (*manage(dBComboLabel));
+       dBSelectBin->add (*manage(dBScaleCombo));
 
        // Phase checkbutton
        _signal_button = new Gtk::CheckButton (_("Plot live signal"));
@@ -127,13 +127,13 @@ PluginEqGui::PluginEqGui(boost::shared_ptr<ARDOUR::PluginInsert> pluginInsert)
 
        // Phase checkbutton
        _phase_button = new Gtk::CheckButton (_("Show phase"));
-       _phase_button->set_active(true);
-       _phase_button->signal_toggled().connectsigc::mem_fun(*this, &PluginEqGui::redraw_scales));
+       _phase_button->set_active (true);
+       _phase_button->signal_toggled().connect (sigc::mem_fun(*this, &PluginEqGui::redraw_scales));
 
        // Freq/dB info for mouse over
        _pointer_info = new Gtk::Label ("", 1, 0.5);
-       _pointer_info->set_size_request(_analysis_width / 4, -1);
-       _pointer_info->set_name("PluginAnalysisInfoLabel");
+       _pointer_info->set_size_request (_analysis_width / 4, -1);
+       _pointer_info->set_name ("PluginAnalysisInfoLabel");
 
        // populate table
        attach (*manage(_analysis_area), 0, 4, 0, 1);
@@ -143,7 +143,7 @@ PluginEqGui::PluginEqGui(boost::shared_ptr<ARDOUR::PluginInsert> pluginInsert)
        attach (*manage(_pointer_info),  3, 4, 1, 2, Gtk::FILL,   Gtk::SHRINK);
 }
 
-PluginEqGui::~PluginEqGui()
+PluginEqGui::~PluginEqGui ()
 {
        stop_listening ();
 
@@ -162,9 +162,9 @@ PluginEqGui::~PluginEqGui()
 }
 
 static inline float
-power_to_dB(float a)
+power_to_dB (float a)
 {
-       return 10.0 * log10f(a);
+       return 10.0 * log10f (a);
 }
 
 void
@@ -190,66 +190,65 @@ PluginEqGui::stop_listening ()
 }
 
 void
-PluginEqGui::on_hide()
+PluginEqGui::on_hide ()
 {
-       stop_updating();
-       Gtk::Table::on_hide();
+       stop_updating ();
+       Gtk::Table::on_hide ();
 }
 
 void
-PluginEqGui::stop_updating()
+PluginEqGui::stop_updating ()
 {
-       if (_update_connection.connected()) {
-               _update_connection.disconnect();
+       if (_update_connection.connected ()) {
+               _update_connection.disconnect ();
        }
 }
 
 void
-PluginEqGui::start_updating()
+PluginEqGui::start_updating ()
 {
        if (!_update_connection.connected() && is_visible()) {
-               _update_connection = Glib::signal_timeout().connect( sigc::mem_fun(this, &PluginEqGui::timeout_callback), 250);
+               _update_connection = Glib::signal_timeout().connect (sigc::mem_fun (this, &PluginEqGui::timeout_callback), 250);
        }
 }
 
 void
-PluginEqGui::on_show()
+PluginEqGui::on_show ()
 {
-       Gtk::Table::on_show();
+       Gtk::Table::on_show ();
 
-       start_updating();
+       start_updating ();
 
-       Gtk::Widget *toplevel = get_toplevel();
+       Gtk::Widget *toplevel = get_toplevel ();
        if (toplevel) {
-               if (!_window_unmap_connection.connected()) {
-                       _window_unmap_connection = toplevel->signal_unmap().connect( sigc::mem_fun(this, &PluginEqGui::stop_updating));
+               if (!_window_unmap_connection.connected ()) {
+                       _window_unmap_connection = toplevel->signal_unmap().connect (sigc::mem_fun (this, &PluginEqGui::stop_updating));
                }
 
-               if (!_window_map_connection.connected()) {
-                       _window_map_connection = toplevel->signal_map().connect( sigc::mem_fun(this, &PluginEqGui::start_updating));
+               if (!_window_map_connection.connected ()) {
+                       _window_map_connection = toplevel->signal_map().connect (sigc::mem_fun (this, &PluginEqGui::start_updating));
                }
        }
 }
 
 void
-PluginEqGui::change_dB_scale()
+PluginEqGui::change_dB_scale ()
 {
-       Gtk::TreeModel::iterator iter = dBScaleCombo -> get_active();
+       Gtk::TreeModel::iterator iter = dBScaleCombo -> get_active ();
 
        Gtk::TreeModel::Row row;
 
-       if(iter && (row = *iter)) {
+       if (iter && (row = *iter)) {
                _min_dB = row[dBColumns.dBMin];
                _max_dB = row[dBColumns.dBMax];
                _step_dB = row[dBColumns.dBStep];
 
-
-               redraw_scales();
+               redraw_scales ();
        }
 }
 
 void
-PluginEqGui::redraw_scales()
+PluginEqGui::redraw_scales ()
 {
 
        if (_analysis_scale_surface) {
@@ -257,13 +256,13 @@ PluginEqGui::redraw_scales()
                _analysis_scale_surface = 0;
        }
 
-       _analysis_area->queue_draw();
+       _analysis_area->queue_draw ();
 
        // TODO: Add graph legend!
 }
 
 void
-PluginEqGui::set_buffer_size(uint32_t size, uint32_t signal_size)
+PluginEqGui::set_buffer_size (uint32_t size, uint32_t signal_size)
 {
        if (_buffer_size == size && _signal_buffer_size == signal_size) {
                return;
@@ -274,10 +273,10 @@ PluginEqGui::set_buffer_size(uint32_t size, uint32_t signal_size)
        GTKArdour::FFT *tmp3 = _signal_output_fft;
 
        try {
-               _impulse_fft       = new GTKArdour::FFT(size);
-               _signal_input_fft  = new GTKArdour::FFT(signal_size);
-               _signal_output_fft = new GTKArdour::FFT(signal_size);
-       } catch( ... ) {
+               _impulse_fft       = new GTKArdour::FFT (size);
+               _signal_input_fft  = new GTKArdour::FFT (signal_size);
+               _signal_output_fft = new GTKArdour::FFT (signal_size);
+       } catch (...) {
                // Don't care about lost memory, we're screwed anyhow
                _impulse_fft       = tmp1;
                _signal_input_fft  = tmp2;
@@ -316,48 +315,46 @@ PluginEqGui::resize_analysis_area (Gtk::Allocation& size)
                _analysis_scale_surface = 0;
        }
 
-       _pointer_info->set_size_request(_analysis_width / 4, -1);
+       _pointer_info->set_size_request (_analysis_width / 4, -1);
 }
 
 bool
-PluginEqGui::timeout_callback()
+PluginEqGui::timeout_callback ()
 {
        if (!_signal_analysis_running) {
                _signal_analysis_running = true;
-               _plugin_insert -> collect_signal_for_analysis(_signal_buffer_size);
+               _plugin_insert -> collect_signal_for_analysis (_signal_buffer_size);
        }
-       run_impulse_analysis();
 
+       run_impulse_analysis ();
        return true;
 }
 
 void
-PluginEqGui::signal_collect_callback(ARDOUR::BufferSet *in, ARDOUR::BufferSet *out)
+PluginEqGui::signal_collect_callback (ARDOUR::BufferSet* in, ARDOUR::BufferSet* out)
 {
        ENSURE_GUI_THREAD (*this, &PluginEqGui::signal_collect_callback, in, out);
 
-       _signal_input_fft ->reset();
-       _signal_output_fft->reset();
+       _signal_input_fft ->reset ();
+       _signal_output_fft->reset ();
 
        for (uint32_t i = 0; i < _plugin_insert->input_streams().n_audio(); ++i) {
-               _signal_input_fft ->analyze(in ->get_audio(i).data(), GTKArdour::FFT::HANN);
+               _signal_input_fft ->analyze (in ->get_audio (i).data(), GTKArdour::FFT::HANN);
        }
 
        for (uint32_t i = 0; i < _plugin_insert->output_streams().n_audio(); ++i) {
-               _signal_output_fft->analyze(out->get_audio(i).data(), GTKArdour::FFT::HANN);
+               _signal_output_fft->analyze (out->get_audio (i).data(), GTKArdour::FFT::HANN);
        }
 
-       _signal_input_fft ->calculate();
-       _signal_output_fft->calculate();
+       _signal_input_fft ->calculate ();
+       _signal_output_fft->calculate ();
 
        _signal_analysis_running = false;
-
-       // This signals calls expose_analysis_area()
-       _analysis_area->queue_draw();
+       _analysis_area->queue_draw ();
 }
 
 void
-PluginEqGui::run_impulse_analysis()
+PluginEqGui::run_impulse_analysis ()
 {
        /* Allocate some thread-local buffers so that Plugin::connect_and_run can use them */
        ARDOUR_UI::instance()->get_process_buffers ();
@@ -367,17 +364,17 @@ PluginEqGui::run_impulse_analysis()
 
        /* Create the impulse, can't use silence() because consecutive calls won't work */
        for (uint32_t i = 0; i < inputs; ++i) {
-               ARDOUR::AudioBuffer& buf = _bufferset.get_audio(i);
-               ARDOUR::Sample* d = buf.data();
-               memset (d, 0, sizeof(ARDOUR::Sample) * _buffer_size);
+               ARDOUR::AudioBuffer& buf = _bufferset.get_audio (i);
+               ARDOUR::Sample* d = buf.data ();
+               memset (d, 0, sizeof (ARDOUR::Sample) * _buffer_size);
                *d = 1.0;
        }
 
        /* Silence collect buffers to copy data to */
        for (uint32_t i = 0; i < outputs; ++i) {
-               ARDOUR::AudioBuffer &buf = _collect_bufferset.get_audio(i);
-               ARDOUR::Sample *d = buf.data();
-               memset(d, 0, sizeof(ARDOUR::Sample) * _buffer_size);
+               ARDOUR::AudioBuffer &buf = _collect_bufferset.get_audio (i);
+               ARDOUR::Sample *d = buf.data ();
+               memset (d, 0, sizeof (ARDOUR::Sample) * _buffer_size);
        }
 
        /* create default linear I/O maps */
@@ -402,18 +399,18 @@ PluginEqGui::run_impulse_analysis()
        samplecnt_t latency = _plugin->signal_latency ();
        samplecnt_t samples_remain = _buffer_size + latency;
 
-       _impulse_fft->reset();
+       _impulse_fft->reset ();
 
        while (samples_remain > 0) {
 
                samplecnt_t n_samples = std::min (samples_remain, block_size);
-               _plugin->connect_and_run(_bufferset, sample_pos, sample_pos + n_samples, 1.0, in_map, out_map, n_samples, 0);
+               _plugin->connect_and_run (_bufferset, sample_pos, sample_pos + n_samples, 1.0, in_map, out_map, n_samples, 0);
                samples_remain -= n_samples;
 
                /* zero input buffers */
                if (sample_pos == 0 && samples_remain > 0) {
                        for (uint32_t i = 0; i < inputs; ++i) {
-                               _bufferset.get_audio(i).data()[0] = 0.f;
+                               _bufferset.get_audio (i).data()[0] = 0.f;
                        }
                }
 
@@ -421,7 +418,7 @@ PluginEqGui::run_impulse_analysis()
                if (samples_remain > 0) {
                        for (uint32_t i = 0; i < inputs; ++i) {
                                pframes_t unused;
-                               assert (_bufferset.get_audio(i).check_silence (block_size, unused));
+                               assert (_bufferset.get_audio (i).check_silence (block_size, unused));
                        }
                }
 #endif
@@ -435,10 +432,10 @@ PluginEqGui::run_impulse_analysis()
                        assert (src_off + n_copy <= _block_size);
 
                        for (uint32_t i = 0; i < outputs; ++i) {
-                               memcpy(
-                                               &(_collect_bufferset.get_audio(i).data()[dst_off]),
-                                               &(_bufferset.get_audio(inputs + i).data()[src_off]),
-                                               n_copy * sizeof(float));
+                               memcpy (
+                                               &(_collect_bufferset.get_audio (i).data()[dst_off]),
+                                               &(_bufferset.get_audio (inputs + i).data()[src_off]),
+                                               n_copy * sizeof (float));
                        }
                }
 
@@ -446,25 +443,25 @@ PluginEqGui::run_impulse_analysis()
        }
 
        for (uint32_t i = 0; i < outputs; ++i) {
-               _impulse_fft->analyze (_collect_bufferset.get_audio(i).data());
+               _impulse_fft->analyze (_collect_bufferset.get_audio (i).data());
        }
-       _impulse_fft->calculate();
+       _impulse_fft->calculate ();
 
-       _analysis_area->queue_draw();
+       _analysis_area->queue_draw ();
 
-       ARDOUR_UI::instance()->drop_process_buffers ();
+       ARDOUR_UI::instance ()->drop_process_buffers ();
 }
 
 void
-PluginEqGui::update_pointer_info(float x)
+PluginEqGui::update_pointer_info( float x)
 {
        /* find the bin corresponding to x (see plot_impulse_amplitude) */
        int i = roundf ((powf (10, _log_max * x / _analysis_width) - 1.0) * _impulse_fft->bins() / _log_coeff);
        float dB = power_to_dB (_impulse_fft->power_at_bin (i));
        /* calc freq corresponding to bin */
-       const int freq = std::max (1, (int) roundf((float)i / (float)_impulse_fft->bins() * _samplerate / 2.f));
+       const int freq = std::max (1, (int) roundf ((float)i / (float)_impulse_fft->bins() * _samplerate / 2.f));
 
-       _pointer_in_area_freq = round (_analysis_width * log10f(1.0 + (float)i / (float)_impulse_fft->bins() * _log_coeff) / _log_max);
+       _pointer_in_area_freq = round (_analysis_width * log10f (1.0 + (float)i / (float)_impulse_fft->bins() * _log_coeff) / _log_max);
 
        std::stringstream ss;
        ss << std::fixed;
@@ -475,96 +472,96 @@ PluginEqGui::update_pointer_info(float x)
        } else {
                ss <<  std::setprecision (0) << freq << "Hz";
        }
-       ss << " " << std::setw(6) << std::setprecision (1) << std::showpos << dB;
-       ss << std::setw(0) << "dB";
+       ss << " " << std::setw (6) << std::setprecision (1) << std::showpos << dB;
+       ss << std::setw (0) << "dB";
 
-       if (_phase_button->get_active()) {
+       if (_phase_button->get_active ()) {
                float phase = 180. * _impulse_fft->phase_at_bin (i) / M_PI;
-               ss << " " << std::setw(6) << std::setprecision (1) << std::showpos << phase;
-               ss << std::setw(0) << "\u00B0";
+               ss << " " << std::setw (6) << std::setprecision (1) << std::showpos << phase;
+               ss << std::setw (0) << "\u00B0";
        }
-       _pointer_info->set_text(ss.str());
+       _pointer_info->set_text (ss.str());
 }
 
 bool
-PluginEqGui::analysis_area_mouseover(GdkEventMotion *event)
+PluginEqGui::analysis_area_mouseover (GdkEventMotion *event)
 {
-       update_pointer_info(event->x);
+       update_pointer_info (event->x);
        _pointer_in_area_xpos = event->x;
-       _analysis_area->queue_draw();
+       _analysis_area->queue_draw ();
        return true;
 }
 
 bool
-PluginEqGui::analysis_area_mouseexit(GdkEventCrossing *)
+PluginEqGui::analysis_area_mouseexit (GdkEventCrossing *)
 {
-       _pointer_info->set_text("");
+       _pointer_info->set_text ("");
        _pointer_in_area_xpos = -1;
-       _analysis_area->queue_draw();
+       _analysis_area->queue_draw ();
        return true;
 }
 
 bool
-PluginEqGui::expose_analysis_area(GdkEventExpose *)
+PluginEqGui::expose_analysis_area (GdkEventExpose *)
 {
-       redraw_analysis_area();
+       redraw_analysis_area ();
        return true;
 }
 
 void
-PluginEqGui::draw_analysis_scales(cairo_t *ref_cr)
+PluginEqGui::draw_analysis_scales (cairo_t *ref_cr)
 {
        // TODO: check whether we need rounding
-       _analysis_scale_surface = cairo_surface_create_similar (cairo_get_target(ref_cr),
+       _analysis_scale_surface = cairo_surface_create_similar (cairo_get_target (ref_cr),
                        CAIRO_CONTENT_COLOR,
                        _analysis_width,
                        _analysis_height);
 
        cairo_t *cr = cairo_create (_analysis_scale_surface);
 
-       cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
-       cairo_rectangle(cr, 0.0, 0.0, _analysis_width, _analysis_height);
-       cairo_fill(cr);
+       cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
+       cairo_rectangle (cr, 0.0, 0.0, _analysis_width, _analysis_height);
+       cairo_fill (cr);
 
+       draw_scales_power (_analysis_area, cr);
 
-       draw_scales_power(_analysis_area, cr);
-       if (_phase_button->get_active()) {
-               draw_scales_phase(_analysis_area, cr);
+       if (_phase_button->get_active ()) {
+               draw_scales_phase (_analysis_area, cr);
        }
 
-       cairo_destroy(cr);
+       cairo_destroy (cr);
 }
 
 void
-PluginEqGui::redraw_analysis_area()
+PluginEqGui::redraw_analysis_area ()
 {
        cairo_t *cr;
 
-       cr = gdk_cairo_create(GDK_DRAWABLE(_analysis_area->get_window()->gobj()));
+       cr = gdk_cairo_create (GDK_DRAWABLE(_analysis_area->get_window()->gobj()));
 
        if (_analysis_scale_surface == 0) {
-               draw_analysis_scales(cr);
+               draw_analysis_scales (cr);
        }
 
-       cairo_copy_page(cr);
+       cairo_copy_page (cr);
 
-       cairo_set_source_surface(cr, _analysis_scale_surface, 0.0, 0.0);
-       cairo_paint(cr);
+       cairo_set_source_surface (cr, _analysis_scale_surface, 0.0, 0.0);
+       cairo_paint (cr);
 
        cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
 
        if (_phase_button->get_active()) {
-               plot_impulse_phase(_analysis_area, cr);
+               plot_impulse_phase (_analysis_area, cr);
        }
 
-       plot_impulse_amplitude(_analysis_area, cr);
+       plot_impulse_amplitude (_analysis_area, cr);
 
        if (_pointer_in_area_xpos >= 0) {
                update_pointer_info (_pointer_in_area_xpos);
        }
 
        if (_signal_button->get_active()) {
-               plot_signal_amplitude_difference(_analysis_area, cr);
+               plot_signal_amplitude_difference (_analysis_area, cr);
        }
 
        if (_pointer_in_area_xpos >= 0 && _pointer_in_area_freq > 0) {
@@ -575,68 +572,72 @@ PluginEqGui::redraw_analysis_area()
                cairo_set_line_width (cr, 1.0);
                cairo_move_to (cr, _pointer_in_area_freq - .5, -.5);
                cairo_line_to (cr, _pointer_in_area_freq - .5, _analysis_height - .5);
-               cairo_stroke(cr);
+               cairo_stroke (cr);
        }
 
-       cairo_destroy(cr);
+       cairo_destroy (cr);
 }
 
 #define PHASE_PROPORTION 0.5
 
 void
-PluginEqGui::draw_scales_phase(Gtk::Widget */*w*/, cairo_t *cr)
+PluginEqGui::draw_scales_phase (Gtk::Widget*, cairo_t *cr)
 {
        float y;
        cairo_font_extents_t extents;
-       cairo_font_extents(cr, &extents);
+       cairo_font_extents (cr, &extents);
 
        char buf[256];
        cairo_text_extents_t t_ext;
 
-       for (uint32_t i = 0; i < 3; i++) {
+       for (uint32_t i = 0; i < 5; i++) {
 
-               y = _analysis_height/2.0 - (float)i*(_analysis_height/8.0)*PHASE_PROPORTION;
+               y = _analysis_height / 2.0 - (float)i * (_analysis_height / 8.0) * PHASE_PROPORTION;
 
-               cairo_set_source_rgb(cr, .8, .9, 0.2);
+               cairo_set_source_rgb (cr, .8, .9, 0.2);
                if (i == 0) {
-                       snprintf(buf,256, "0\u00b0");
+                       snprintf (buf,256, "0\u00b0");
                } else {
-                       snprintf(buf,256, "%d\u00b0", (i * 45));
+                       snprintf (buf,256, "%d\u00b0", (i * 45));
                }
-               cairo_text_extents(cr, buf, &t_ext);
-               cairo_move_to(cr, _analysis_width - t_ext.width - t_ext.x_bearing - 2.0, y - extents.descent);
-               cairo_show_text(cr, buf);
+               cairo_text_extents (cr, buf, &t_ext);
+               cairo_move_to (cr, _analysis_width - t_ext.width - t_ext.x_bearing - 2.0, y - extents.descent);
+               cairo_show_text (cr, buf);
 
-               if (i == 0)
+               if (i == 0) {
                        continue;
+               }
 
+               y = roundf (y) - .5;
 
-               cairo_set_source_rgba(cr, .8, .9, 0.2, 0.6/(float)i);
-               cairo_move_to(cr, 0.0,            y);
-               cairo_line_to(cr, _analysis_width, y);
-
+               cairo_set_source_rgba (cr, .8, .9, .2, 0.4);
+               cairo_move_to (cr, 0.0,             y);
+               cairo_line_to (cr, _analysis_width, y);
+               cairo_set_line_width (cr, 1);
+               cairo_stroke (cr);
 
-               y = _analysis_height/2.0 + (float)i*(_analysis_height/8.0)*PHASE_PROPORTION;
+               y = _analysis_height / 2.0 + (float)i * (_analysis_height / 8.0) * PHASE_PROPORTION;
 
                // label
-               snprintf(buf,256, "-%d\u00b0", (i * 45));
-               cairo_set_source_rgb(cr, .8, .9, 0.2);
-               cairo_text_extents(cr, buf, &t_ext);
-               cairo_move_to(cr, _analysis_width - t_ext.width - t_ext.x_bearing - 2.0, y - extents.descent);
-               cairo_show_text(cr, buf);
+               snprintf (buf,256, "-%d\u00b0", (i * 45));
+               cairo_set_source_rgb (cr, .8, .9, 0.2);
+               cairo_text_extents (cr, buf, &t_ext);
+               cairo_move_to (cr, _analysis_width - t_ext.width - t_ext.x_bearing - 2.0, y - extents.descent);
+               cairo_show_text (cr, buf);
 
+               y = roundf (y) - .5;
                // line
-               cairo_set_source_rgba(cr, .8, .9, 0.2, 0.6/(float)i);
-               cairo_move_to(cr, 0.0,            y);
-               cairo_line_to(cr, _analysis_width, y);
+               cairo_set_source_rgba (cr, .8, .9, .2, 0.4);
+               cairo_move_to (cr, 0.0,             y);
+               cairo_line_to (cr, _analysis_width, y);
 
-               cairo_set_line_width (cr, 0.25 + 1.0/(float)(i+1));
-               cairo_stroke(cr);
+               cairo_set_line_width (cr, 1);
+               cairo_stroke (cr);
        }
 }
 
 void
-PluginEqGui::plot_impulse_phase(Gtk::Widget *w, cairo_t *cr)
+PluginEqGui::plot_impulse_phase (Gtk::Widget *w, cairo_t *cr)
 {
        float x,y;
 
@@ -645,44 +646,46 @@ PluginEqGui::plot_impulse_phase(Gtk::Widget *w, cairo_t *cr)
        int avgNum = 0;
 
        // float width  = w->get_width();
-       float height = w->get_height();
+       float height = w->get_height ();
+       float analysis_height_2 = _analysis_height / 2.f;
 
-       cairo_set_source_rgba(cr, 0.95, 0.3, 0.2, 1.0);
-       for (uint32_t i = 0; i < _impulse_fft->bins()-1; i++) {
+       cairo_set_source_rgba (cr, 0.95, 0.3, 0.2, 1.0);
+       for (uint32_t i = 0; i < _impulse_fft->bins() - 1; ++i) {
                // x coordinate of bin i
-               x  = log10f(1.0 + (float)i / (float)_impulse_fft->bins() * _log_coeff) / _log_max;
+               x  = log10f (1.0 + (float)i / (float)_impulse_fft->bins() * _log_coeff) / _log_max;
                x *= _analysis_width;
+               y  = analysis_height_2 - (_impulse_fft->phase_at_bin (i) / M_PI) * analysis_height_2 * PHASE_PROPORTION;
 
-               y  = _analysis_height/2.0 - (_impulse_fft->phase_at_bin(i)/M_PI)*(_analysis_height/2.0)*PHASE_PROPORTION;
-
-               if ( i == 0 ) {
-                       cairo_move_to(cr, x, y);
-
+               if (i == 0) {
+                       cairo_move_to (cr, x, y);
                        avgY = 0;
                        avgNum = 0;
-               } else if (rint(x) > prevX || i == _impulse_fft->bins()-1 ) {
-                       avgY = avgY/(float)avgNum;
-                       if (avgY > (height * 10.0) ) avgY = height * 10.0;
-                       if (avgY < (-height * 10.0) ) avgY = -height * 10.0;
-                       cairo_line_to(cr, prevX, avgY);
-                       //cairo_line_to(cr, prevX, avgY/(float)avgNum);
+               } else if (rint (x) > prevX || i == _impulse_fft->bins() - 1) {
+                       avgY = avgY / (float)avgNum;
+                       if (avgY > (height * 10.0)) {
+                               avgY = height * 10.0;
+                       }
+                       if (avgY < (-height * 10.0)) {
+                               avgY = -height * 10.0;
+                       }
+
+                       cairo_line_to (cr, prevX, avgY);
 
                        avgY = 0;
                        avgNum = 0;
-
                }
 
-               prevX = rint(x);
+               prevX = rint (x);
                avgY += y;
                avgNum++;
        }
 
        cairo_set_line_width (cr, 2.0);
-       cairo_stroke(cr);
+       cairo_stroke (cr);
 }
 
 void
-PluginEqGui::draw_scales_power(Gtk::Widget */*w*/, cairo_t *cr)
+PluginEqGui::draw_scales_power (Gtk::Widget */*w*/, cairo_t *cr)
 {
        if (_impulse_fft == 0) {
                return;
@@ -693,10 +696,10 @@ PluginEqGui::draw_scales_power(Gtk::Widget */*w*/, cairo_t *cr)
        float x;
 
        cairo_set_line_width (cr, 1.5);
-       cairo_set_font_size(cr, 9);
+       cairo_set_font_size (cr, 9);
 
        cairo_font_extents_t extents;
-       cairo_font_extents(cr, &extents);
+       cairo_font_extents (cr, &extents);
        // float fontXOffset = extents.descent + 1.0;
 
        char buf[256];
@@ -704,29 +707,28 @@ PluginEqGui::draw_scales_power(Gtk::Widget */*w*/, cairo_t *cr)
        for (uint32_t i = 0; scales[i] != -1.0; ++i) {
                float bin = scales[i] / divisor;
 
-               x  = log10f(1.0 + bin / (float)_impulse_fft->bins() * _log_coeff) / _log_max;
+               x  = log10f (1.0 + bin / (float)_impulse_fft->bins() * _log_coeff) / _log_max;
                x *= _analysis_width;
 
                if (scales[i] < 1000.0) {
-                       snprintf(buf, 256, "%0.0f", scales[i]);
+                       snprintf (buf, 256, "%0.0f", scales[i]);
                } else {
-                       snprintf(buf, 256, "%0.0fk", scales[i]/1000.0);
+                       snprintf (buf, 256, "%0.0fk", scales[i]/1000.0);
                }
 
-               cairo_set_source_rgb(cr, 0.4, 0.4, 0.4);
+               cairo_set_source_rgb (cr, 0.4, 0.4, 0.4);
 
-               //cairo_move_to(cr, x + fontXOffset, 3.0);
-               cairo_move_to(cr, x - extents.height, 3.0);
+               cairo_move_to (cr, x - extents.height, 3.0);
 
-               cairo_rotate(cr, M_PI / 2.0);
-               cairo_show_text(cr, buf);
-               cairo_rotate(cr, -M_PI / 2.0);
-               cairo_stroke(cr);
+               cairo_rotate (cr, M_PI / 2.0);
+               cairo_show_text (cr, buf);
+               cairo_rotate (cr, -M_PI / 2.0);
+               cairo_stroke (cr);
 
-               cairo_set_source_rgb(cr, 0.3, 0.3, 0.3);
-               cairo_move_to(cr, x, _analysis_height);
-               cairo_line_to(cr, x, 0.0);
-               cairo_stroke(cr);
+               cairo_set_source_rgb (cr, 0.3, 0.3, 0.3);
+               cairo_move_to (cr, x, _analysis_height);
+               cairo_line_to (cr, x, 0.0);
+               cairo_stroke (cr);
        }
 
        float y;
@@ -734,55 +736,52 @@ PluginEqGui::draw_scales_power(Gtk::Widget */*w*/, cairo_t *cr)
        //double dashes[] = { 1.0, 3.0, 4.5, 3.0 };
        double dashes[] = { 3.0, 5.0 };
 
-       for (float dB = 0.0; dB < _max_dB; dB += _step_dB ) {
-               snprintf(buf, 256, "+%0.0f", dB );
+       for (float dB = 0.0; dB < _max_dB; dB += _step_dB) {
+               snprintf (buf, 256, "+%0.0f", dB);
 
-               y  = ( _max_dB - dB) / ( _max_dB - _min_dB );
+               y  = (_max_dB - dB) / (_max_dB - _min_dB);
                //std::cerr << " y = " << y << std::endl;
                y *= _analysis_height;
 
                if (dB != 0.0) {
-                       cairo_set_source_rgb(cr, 0.4, 0.4, 0.4);
-                       cairo_move_to(cr, 1.0,     y + extents.height + 1.0);
-                       cairo_show_text(cr, buf);
-                       cairo_stroke(cr);
+                       cairo_set_source_rgb (cr, 0.4, 0.4, 0.4);
+                       cairo_move_to (cr, 1.0,     y + extents.height + 1.0);
+                       cairo_show_text (cr, buf);
+                       cairo_stroke (cr);
                }
 
-               cairo_set_source_rgb(cr, 0.2, 0.2, 0.2);
-               cairo_move_to(cr, 0,     y);
-               cairo_line_to(cr, _analysis_width, y);
-               cairo_stroke(cr);
+               cairo_set_source_rgb (cr, 0.2, 0.2, 0.2);
+               cairo_move_to (cr, 0,               y);
+               cairo_line_to (cr, _analysis_width, y);
+               cairo_stroke (cr);
 
                if (dB == 0.0) {
-                       cairo_set_dash(cr, dashes, 2, 0.0);
+                       cairo_set_dash (cr, dashes, 2, 0.0);
                }
        }
 
+       for (float dB = - _step_dB; dB > _min_dB; dB -= _step_dB) {
+               snprintf (buf, 256, "%0.0f", dB);
 
-
-       for (float dB = - _step_dB; dB > _min_dB; dB -= _step_dB ) {
-               snprintf(buf, 256, "%0.0f", dB );
-
-               y  = ( _max_dB - dB) / ( _max_dB - _min_dB );
+               y  = (_max_dB - dB) / (_max_dB - _min_dB);
                y *= _analysis_height;
 
-               cairo_set_source_rgb(cr, 0.4, 0.4, 0.4);
-               cairo_move_to(cr, 1.0,     y - extents.descent - 1.0);
-               cairo_show_text(cr, buf);
-               cairo_stroke(cr);
+               cairo_set_source_rgb (cr, 0.4, 0.4, 0.4);
+               cairo_move_to (cr, 1.0, y - extents.descent - 1.0);
+               cairo_show_text (cr, buf);
+               cairo_stroke (cr);
 
-               cairo_set_source_rgb(cr, 0.2, 0.2, 0.2);
-               cairo_move_to(cr, 0,     y);
-               cairo_line_to(cr, _analysis_width, y);
-               cairo_stroke(cr);
+               cairo_set_source_rgb (cr, 0.2, 0.2, 0.2);
+               cairo_move_to (cr, 0,               y);
+               cairo_line_to (cr, _analysis_width, y);
+               cairo_stroke (cr);
        }
 
-       cairo_set_dash(cr, 0, 0, 0.0);
-
+       cairo_set_dash (cr, 0, 0, 0.0);
 }
 
 void
-PluginEqGui::plot_impulse_amplitude(Gtk::Widget *w, cairo_t *cr)
+PluginEqGui::plot_impulse_amplitude (Gtk::Widget *w, cairo_t *cr)
 {
        float x,y;
        int prevX = 0;
@@ -790,47 +789,48 @@ PluginEqGui::plot_impulse_amplitude(Gtk::Widget *w, cairo_t *cr)
        int avgNum = 0;
 
        // float width  = w->get_width();
-       float height = w->get_height();
+       float height = w->get_height ();
 
-       cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
+       cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
        cairo_set_line_width (cr, 2.5);
 
-       for (uint32_t i = 0; i < _impulse_fft->bins()-1; i++) {
+       for (uint32_t i = 0; i < _impulse_fft->bins() - 1; ++i) {
                // x coordinate of bin i
-               x  = log10f(1.0 + (float)i / (float)_impulse_fft->bins() * _log_coeff) / _log_max;
+               x  = log10f (1.0 + (float)i / (float)_impulse_fft->bins() * _log_coeff) / _log_max;
                x *= _analysis_width;
 
-               float yCoeff = ( power_to_dB(_impulse_fft->power_at_bin(i)) - _min_dB) / (_max_dB - _min_dB);
+               float yCoeff = (power_to_dB (_impulse_fft->power_at_bin (i)) - _min_dB) / (_max_dB - _min_dB);
 
-               y = _analysis_height - _analysis_height*yCoeff;
-
-               if ( i == 0 ) {
-                       cairo_move_to(cr, x, y);
+               y = _analysis_height - _analysis_height * yCoeff;
 
+               if (i == 0) {
+                       cairo_move_to (cr, x, y);
                        avgY = 0;
                        avgNum = 0;
-               } else if (rint(x) > prevX || i == _impulse_fft->bins()-1 ) {
-                       avgY = avgY/(float)avgNum;
-                       if (avgY > (height * 10.0) ) avgY = height * 10.0;
-                       if (avgY < (-height * 10.0) ) avgY = -height * 10.0;
-                       cairo_line_to(cr, prevX, avgY);
-                       //cairo_line_to(cr, prevX, avgY/(float)avgNum);
+               } else if (rint (x) > prevX || i == _impulse_fft->bins() - 1) {
+                       avgY = avgY / (float)avgNum;
+                       if (avgY > (height * 10.0)) {
+                               avgY = height * 10.0;
+                       }
+                       if (avgY < (-height * 10.0)) {
+                               avgY = -height * 10.0;
+                       }
+                       cairo_line_to (cr, prevX, avgY);
 
                        avgY = 0;
                        avgNum = 0;
-
                }
 
-               prevX = rint(x);
+               prevX = rint (x);
                avgY += y;
                avgNum++;
        }
 
-       cairo_stroke(cr);
+       cairo_stroke (cr);
 }
 
 void
-PluginEqGui::plot_signal_amplitude_difference(Gtk::Widget *w, cairo_t *cr)
+PluginEqGui::plot_signal_amplitude_difference (Gtk::Widget *w, cairo_t *cr)
 {
        float x,y;
 
@@ -838,15 +838,14 @@ PluginEqGui::plot_signal_amplitude_difference(Gtk::Widget *w, cairo_t *cr)
        float avgY = 0.0;
        int avgNum = 0;
 
-       // float width  = w->get_width();
        float height = w->get_height();
 
-       cairo_set_source_rgb(cr, 0.0, 1.0, 0.0);
+       cairo_set_source_rgb (cr, 0.0, 1.0, 0.0);
        cairo_set_line_width (cr, 1.5);
 
-       for (uint32_t i = 0; i < _signal_input_fft->bins()-1; i++) {
+       for (uint32_t i = 0; i < _signal_input_fft->bins() - 1; ++i) {
                // x coordinate of bin i
-               x  = log10f(1.0 + (float)i / (float)_signal_input_fft->bins() * _log_coeff) / _log_max;
+               x  = log10f (1.0 + (float)i / (float)_signal_input_fft->bins() * _log_coeff) / _log_max;
                x *= _analysis_width;
 
                float power_out = _signal_output_fft->power_at_bin (i) + 1e-30;
@@ -856,30 +855,34 @@ PluginEqGui::plot_signal_amplitude_difference(Gtk::Widget *w, cairo_t *cr)
                assert (!ISINF(power));
                assert (!ISNAN(power));
 
-               float yCoeff = ( power - _min_dB) / (_max_dB - _min_dB);
+               float yCoeff = (power - _min_dB) / (_max_dB - _min_dB);
 
                y = _analysis_height - _analysis_height*yCoeff;
 
-               if ( i == 0 ) {
-                       cairo_move_to(cr, x, y);
+               if (i == 0) {
+                       cairo_move_to (cr, x, y);
 
                        avgY = 0;
                        avgNum = 0;
-               } else if (rint(x) > prevX || i == _impulse_fft->bins()-1 ) {
-                       avgY = avgY/(float)avgNum;
-                       if (avgY > (height * 10.0) ) avgY = height * 10.0;
-                       if (avgY < (-height * 10.0) ) avgY = -height * 10.0;
-                       cairo_line_to(cr, prevX, avgY);
+               } else if (rint (x) > prevX || i == _impulse_fft->bins() - 1) {
+                       avgY = avgY / (float)avgNum;
+                       if (avgY > (height * 10.0)) {
+                               avgY = height * 10.0;
+                       }
+                       if (avgY < (-height * 10.0)) {
+                               avgY = -height * 10.0;
+                       }
+                       cairo_line_to (cr, prevX, avgY);
 
                        avgY = 0;
                        avgNum = 0;
 
                }
 
-               prevX = rint(x);
+               prevX = rint (x);
                avgY += y;
                avgNum++;
        }
 
-       cairo_stroke(cr);
+       cairo_stroke (cr);
 }