fft.cc
fft_graph.cc
fft_result.cc
-eq_gui.cc
+plugin_eq_gui.cc
gain_meter.cc
generic_pluginui.cc
ghostregion.cc
+++ /dev/null
-/*
- Copyright (C) 2008 Paul Davis
- Author: Sampo Savolainen
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#include "eq_gui.h"
-#include "fft.h"
-
-#include "ardour_ui.h"
-#include <ardour/audio_buffer.h>
-#include <ardour/data_type.h>
-
-#include <gtkmm/box.h>
-#include <gtkmm/button.h>
-#include <gtkmm/checkbutton.h>
-
-#include <iostream>
-
-
-PluginEqGui::PluginEqGui(boost::shared_ptr<ARDOUR::PluginInsert> pluginInsert)
- : _mindB(-12.0),
- _maxdB(+12.0),
- _dBStep(3.0),
- _impulseFft(0)
-{
- _samplerate = ARDOUR_UI::instance()->the_session()->frame_rate();
-
- _plugin = pluginInsert->get_impulse_analysis_plugin();
- _plugin->activate();
-
- setBufferSize(4096);
-
- _logCoeff = (1.0 - 2.0 * (1000.0/(_samplerate/2.0))) / powf(1000.0/(_samplerate/2.0), 2.0);
- _logMax = log10f(1 + _logCoeff);
-
-
- // Setup analysis drawing area
- _analysisScaleSurface = 0;
-
- _analysisArea = new Gtk::DrawingArea();
- _analysisWidth = 500.0;
- _analysisHeight = 500.0;
- _analysisArea->set_size_request(_analysisWidth, _analysisHeight);
-
- _analysisArea->signal_expose_event().connect( sigc::mem_fun (*this, &PluginEqGui::exposeAnalysisArea));
- _analysisArea->signal_size_allocate().connect( sigc::mem_fun (*this, &PluginEqGui::resizeAnalysisArea));
-
-
- // dB selection
- dBScaleModel = Gtk::ListStore::create(dBColumns);
-
- dBScaleCombo = new Gtk::ComboBox(dBScaleModel);
- dBScaleCombo -> set_title("dB scale");
-
-#define ADD_DB_ROW(MIN,MAX,STEP,NAME) \
- { \
- Gtk::TreeModel::Row row = *(dBScaleModel->append()); \
- row[dBColumns.dBMin] = (MIN); \
- row[dBColumns.dBMax] = (MAX); \
- row[dBColumns.dBStep] = (STEP); \
- row[dBColumns.name] = NAME; \
- }
-
- ADD_DB_ROW( -6, +6, 1, "-6dB .. +6dB");
- ADD_DB_ROW(-12, +12, 3, "-12dB .. +12dB");
- ADD_DB_ROW(-24, +24, 5, "-24dB .. +24dB");
- ADD_DB_ROW(-36, +36, 6, "-36dB .. +36dB");
-
-#undef ADD_DB_ROW
-
- dBScaleCombo -> pack_start(dBColumns.name);
- dBScaleCombo -> set_active(1);
-
- dBScaleCombo -> signal_changed().connect( sigc::mem_fun(*this, &PluginEqGui::dBScaleChanged) );
-
- Gtk::Label *dBComboLabel = new Gtk::Label("dB scale");
-
- Gtk::HBox *dBSelectBin = new Gtk::HBox(false, 5);
- dBSelectBin->add( *manage(dBComboLabel));
- dBSelectBin->add( *manage(dBScaleCombo));
-
- // Phase checkbutton
- phaseSelect = new Gtk::CheckButton("Show phase");
- phaseSelect->set_active(true);
- phaseSelect->signal_toggled().connect( sigc::mem_fun(*this, &PluginEqGui::redrawScales));
-
- // Update button
- Gtk::Button *btn = new Gtk::Button("Update");
- btn->signal_clicked().connect( sigc::mem_fun(*this, &PluginEqGui::runAnalysis));
-
- // populate table
- attach( *manage(_analysisArea), 1, 4, 1, 2);
- attach( *manage(dBSelectBin), 1, 2, 2, 3, Gtk::SHRINK, Gtk::SHRINK);
- attach( *manage(phaseSelect), 2, 3, 2, 3, Gtk::SHRINK, Gtk::SHRINK);
- attach( *manage(btn), 3, 4, 2, 3, Gtk::SHRINK, Gtk::SHRINK);
-
-
- // Timeout
- //_updateConn = Glib::signal_timeout().connect( sigc::mem_fun(this, &PluginEqGui::timeoutCallback), 250);
-}
-
-PluginEqGui::~PluginEqGui()
-{
- std::cerr << "Destroying PluginEqGui for " << _plugin->name() << std::endl;
- if (_analysisScaleSurface) {
- cairo_surface_destroy (_analysisScaleSurface);
- }
-
- delete _impulseFft;
- _plugin->deactivate();
-
- // all gui objects are *manage'd by the inherited Table object
-}
-
-void
-PluginEqGui::on_hide()
-{
- Gtk::Table::on_hide();
- _updateConn.disconnect();
-}
-
-void
-PluginEqGui::on_show()
-{
- Gtk::Table::on_show();
- _updateConn = Glib::signal_timeout().connect( sigc::mem_fun(this, &PluginEqGui::timeoutCallback), 250);
-}
-
-void
-PluginEqGui::dBScaleChanged()
-{
- Gtk::TreeModel::iterator iter = dBScaleCombo -> get_active();
-
- Gtk::TreeModel::Row row;
-
- if(iter && (row = *iter)) {
- _mindB = row[dBColumns.dBMin];
- _maxdB = row[dBColumns.dBMax];
- _dBStep = row[dBColumns.dBStep];
-
-
- redrawScales();
- }
-}
-
-void
-PluginEqGui::redrawScales()
-{
-
- if (_analysisScaleSurface) {
- cairo_surface_destroy (_analysisScaleSurface);
- _analysisScaleSurface = 0;
- }
-
- _analysisArea->queue_draw();
-}
-
-void
-PluginEqGui::setBufferSize(uint32_t size)
-{
- if (_bufferSize == size)
- return;
-
- _bufferSize = size;
-
- if (_impulseFft) {
- delete _impulseFft;
- _impulseFft = 0;
- }
-
- _impulseFft = new FFT(_bufferSize);
-
- uint32_t inputs = _plugin->get_info()->n_inputs.n_audio();
- uint32_t outputs = _plugin->get_info()->n_outputs.n_audio();
-
- uint32_t n_chans = std::max(inputs, outputs);
- _bufferset.ensure_buffers(ARDOUR::DataType::AUDIO, n_chans, _bufferSize);
-
- ARDOUR::ChanCount chanCount(ARDOUR::DataType::AUDIO, n_chans);
- _bufferset.set_count(chanCount);
-
- /*
-
- const uint32_t nbufs = _bufferset.count().n_audio();
- std::cerr << "ensure_buffers(ARDOUR::DataType::Audio, " << n_chans << ", " << _bufferSize << "), _bufferset.count().n_audio() = " << nbufs << std::endl;
- */
-}
-
-void
-PluginEqGui::resizeAnalysisArea(Gtk::Allocation& size)
-{
- _analysisWidth = (float)size.get_width();
- _analysisHeight = (float)size.get_height();
-
- if (_analysisScaleSurface) {
- cairo_surface_destroy (_analysisScaleSurface);
- _analysisScaleSurface = 0;
- }
-}
-
-bool
-PluginEqGui::timeoutCallback()
-{
- /*
- struct timeval tv;
- struct timezone tz;
-
- gettimeofday(&tv, &tz);
- std::cerr << " time = " << tv.tv_sec << ":" << tv.tv_usec << std::endl;
- */
- runAnalysis();
-
- return true;
-}
-
-void
-PluginEqGui::runAnalysis()
-{
- uint32_t inputs = _plugin->get_info()->n_inputs.n_audio();
- uint32_t outputs = _plugin->get_info()->n_outputs.n_audio();
-
- const uint32_t nbufs = _bufferset.count().n_audio();
-
- // 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(_bufferSize, 0);
- memset(d, 0, sizeof(ARDOUR::Sample)*_bufferSize);
- *d = 1.0;
- }
- uint32_t x,y;
- x=y=0;
-
- _plugin->connect_and_run(_bufferset, x, y, _bufferSize, (nframes_t)0);
-
- // Analyze all output buffers
- _impulseFft->reset();
- for (uint32_t i = 0; i < outputs; ++i) {
- _impulseFft->analyze(_bufferset.get_audio(i).data(_bufferSize, 0));
- }
-
- // normalize the output
- _impulseFft->calculate();
-
- // This signals calls exposeAnalysisArea()
- _analysisArea->queue_draw();
-
-}
-
-bool
-PluginEqGui::exposeAnalysisArea(GdkEventExpose *evt)
-{
- redrawAnalysisArea();
-
- return false;
-}
-
-void
-PluginEqGui::generateAnalysisScale(cairo_t *ref_cr)
-{
- // TODO: check whether we need rounding
- _analysisScaleSurface = cairo_surface_create_similar(cairo_get_target(ref_cr),
- CAIRO_CONTENT_COLOR,
- _analysisWidth,
- _analysisHeight);
-
- cairo_t *cr = cairo_create (_analysisScaleSurface);
-
- cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
- cairo_rectangle(cr, 0.0, 0.0, _analysisWidth, _analysisHeight);
- cairo_fill(cr);
-
-
- drawPowerScale(_analysisArea, cr);
- if (phaseSelect->get_active()) {
- drawPhaseScale(_analysisArea, cr);
- }
-
- cairo_destroy(cr);
-
-}
-
-void
-PluginEqGui::redrawAnalysisArea()
-{
- cairo_t *cr;
-
- cr = gdk_cairo_create(GDK_DRAWABLE(_analysisArea->get_window()->gobj()));
-
- if (_analysisScaleSurface == 0) {
- generateAnalysisScale(cr);
- }
-
-
- cairo_copy_page(cr);
-
- cairo_set_source_surface(cr, _analysisScaleSurface, 0.0, 0.0);
- cairo_paint(cr);
-
- if (phaseSelect->get_active()) {
- drawPhase(_analysisArea, cr);
- }
- drawPower(_analysisArea, cr);
-
-
- cairo_destroy(cr);
-
-
-}
-
-#define PHASE_PROPORTION 0.6
-
-void
-PluginEqGui::drawPhaseScale(Gtk::Widget *w, cairo_t *cr)
-{
- float y;
- cairo_font_extents_t extents;
- cairo_font_extents(cr, &extents);
-
- char buf[256];
- cairo_text_extents_t t_ext;
-
- for (uint32_t i = 0; i < 3; i++) {
-
- y = _analysisHeight/2.0 - (float)i*(_analysisHeight/8.0)*PHASE_PROPORTION;
-
- cairo_set_source_rgb(cr, .8, .9, 0.2);
- if (i == 0) {
- snprintf(buf,256, "0\u00b0");
- } else {
- snprintf(buf,256, "%d\u00b0", (i * 45));
- }
- cairo_text_extents(cr, buf, &t_ext);
- cairo_move_to(cr, _analysisWidth - t_ext.width - t_ext.x_bearing - 2.0, y - extents.descent);
- cairo_show_text(cr, buf);
-
- if (i == 0)
- continue;
-
-
- cairo_set_source_rgba(cr, .8, .9, 0.2, 0.6/(float)i);
- cairo_move_to(cr, 0.0, y);
- cairo_line_to(cr, _analysisWidth, y);
-
-
- y = _analysisHeight/2.0 + (float)i*(_analysisHeight/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, _analysisWidth - t_ext.width - t_ext.x_bearing - 2.0, y - extents.descent);
- cairo_show_text(cr, buf);
-
- // 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, _analysisWidth, y);
-
- cairo_set_line_width (cr, 0.25 + 1.0/(float)(i+1));
- cairo_stroke(cr);
- }
-}
-
-void
-PluginEqGui::drawPhase(Gtk::Widget *w, cairo_t *cr)
-{
- float x,y;
-
- int prevX = 0;
- float avgY = 0.0;
- int avgNum = 0;
-
- cairo_set_source_rgba(cr, 0.95, 0.3, 0.2, 1.0);
- for (uint32_t i = 0; i < _impulseFft->bins()-1; i++) {
- // x coordinate of bin i
- x = log10f(1.0 + (float)i / (float)_impulseFft->bins() * _logCoeff) / _logMax;
- x *= _analysisWidth;
-
- y = _analysisHeight/2.0 - (_impulseFft->phaseAtBin(i)/M_PI)*(_analysisHeight/2.0)*PHASE_PROPORTION;
-
- if ( i == 0 ) {
- cairo_move_to(cr, x, y);
-
- avgY = 0;
- avgNum = 0;
- } else if (rint(x) > prevX || i == _impulseFft->bins()-1 ) {
- cairo_line_to(cr, prevX, avgY/(float)avgNum);
-
- avgY = 0;
- avgNum = 0;
-
- }
-
- prevX = rint(x);
- avgY += y;
- avgNum++;
- }
-
- cairo_set_line_width (cr, 2.0);
- cairo_stroke(cr);
-}
-
-void
-PluginEqGui::drawPowerScale(Gtk::Widget *w, cairo_t *cr)
-{
- static float scales[] = { 30.0, 70.0, 125.0, 250.0, 500.0, 1000.0, 2000.0, 5000.0, 10000.0, 15000.0, 20000.0, -1.0 };
-
- float divisor = _samplerate / 2.0 / _impulseFft->bins();
- float x;
-
- cairo_set_line_width (cr, 1.5);
- cairo_set_font_size(cr, 9);
-
- cairo_font_extents_t extents;
- cairo_font_extents(cr, &extents);
- float fontXOffset = extents.descent + 1.0;
-
- char buf[256];
-
- for (uint32_t i = 0; scales[i] != -1.0; ++i) {
- float bin = scales[i] / divisor;
-
- x = log10f(1.0 + bin / (float)_impulseFft->bins() * _logCoeff) / _logMax;
- x *= _analysisWidth;
-
- if (scales[i] < 1000.0) {
- snprintf(buf, 256, "%0.0f", scales[i]);
- } else {
- snprintf(buf, 256, "%0.0fk", scales[i]/1000.0);
- }
-
- cairo_set_source_rgb(cr, 0.4, 0.4, 0.4);
-
- cairo_move_to(cr, x + fontXOffset, 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_set_source_rgb(cr, 0.3, 0.3, 0.3);
- cairo_move_to(cr, x, _analysisHeight);
- cairo_line_to(cr, x, 0.0);
- cairo_stroke(cr);
- }
-
- float y;
-
- //double dashes[] = { 1.0, 3.0, 4.5, 3.0 };
- double dashes[] = { 3.0, 5.0 };
-
- for (float dB = 0.0; dB < _maxdB; dB += _dBStep ) {
- snprintf(buf, 256, "+%0.0f", dB );
-
- y = ( _maxdB - dB) / ( _maxdB - _mindB );
- //std::cerr << " y = " << y << std::endl;
- y *= _analysisHeight;
-
- 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.2, 0.2, 0.2);
- cairo_move_to(cr, 0, y);
- cairo_line_to(cr, _analysisWidth, y);
- cairo_stroke(cr);
-
- if (dB == 0.0) {
- cairo_set_dash(cr, dashes, 2, 0.0);
- }
- }
-
-
-
- for (float dB = - _dBStep; dB > _mindB; dB -= _dBStep ) {
- snprintf(buf, 256, "%0.0f", dB );
-
- y = ( _maxdB - dB) / ( _maxdB - _mindB );
- y *= _analysisHeight;
-
- 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, _analysisWidth, y);
- cairo_stroke(cr);
- }
-
- cairo_set_dash(cr, 0, 0, 0.0);
-
-}
-
-inline float
-power_to_dB(float a)
-{
- return 10.0 * log10f(a);
-}
-
-void
-PluginEqGui::drawPower(Gtk::Widget *w, cairo_t *cr)
-{
- float x,y;
-
- int prevX = 0;
- float avgY = 0.0;
- int avgNum = 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 < _impulseFft->bins()-1; i++) {
- // x coordinate of bin i
- x = log10f(1.0 + (float)i / (float)_impulseFft->bins() * _logCoeff) / _logMax;
- x *= _analysisWidth;
-
- float yCoeff = ( power_to_dB(_impulseFft->powerAtBin(i)) - _mindB) / (_maxdB - _mindB);
-
- y = _analysisHeight - _analysisHeight*yCoeff;
-
- if ( i == 0 ) {
- cairo_move_to(cr, x, y);
-
- avgY = 0;
- avgNum = 0;
- } else if (rint(x) > prevX || i == _impulseFft->bins()-1 ) {
- cairo_line_to(cr, prevX, avgY/(float)avgNum);
-
- avgY = 0;
- avgNum = 0;
-
- }
-
- prevX = rint(x);
- avgY += y;
- avgNum++;
- }
-
- cairo_stroke(cr);
-}
-
+++ /dev/null
-/*
- Copyright (C) 2008 Paul Davis
- Author: Sampo Savolainen
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#ifndef __ardour_eq_gui_h
-#define __ardour_eq_gui_h
-
-#include <ardour/buffer_set.h>
-#include <ardour/plugin_insert.h>
-#include <ardour/plugin.h>
-
-#include <gtkmm/table.h>
-#include <gtkmm/drawingarea.h>
-#include <gtkmm/combobox.h>
-#include <gtkmm/liststore.h>
-
-class Plugin;
-class FFT;
-
-class PluginEqGui : public Gtk::Table
-{
- public:
- PluginEqGui(boost::shared_ptr<ARDOUR::PluginInsert>);
- ~PluginEqGui();
-
-
-
- private:
- // Setup
- void setBufferSize(uint32_t);
- void dBScaleChanged();
-
- // Analysis
- void runAnalysis();
-
- // Drawing
- virtual void on_hide();
- virtual void on_show();
-
- void resizeAnalysisArea(Gtk::Allocation&);
-
- void redrawAnalysisArea();
- void generateAnalysisScale(cairo_t *);
- bool exposeAnalysisArea(GdkEventExpose *);
-
- void drawPowerScale(Gtk::Widget *, cairo_t *);
- void drawPower(Gtk::Widget *,cairo_t *);
-
- void drawPhaseScale(Gtk::Widget *,cairo_t *);
- void drawPhase(Gtk::Widget *,cairo_t *);
-
- // Helpers
- bool timeoutCallback();
- void redrawScales();
-
-
- // Fields:
-
- // analysis parameters
- float _samplerate;
-
- float _mindB;
- float _maxdB;
- float _dBStep;
-
-
- float _logCoeff;
- float _logMax;
-
- nframes_t _bufferSize;
-
- // buffers
- ARDOUR::BufferSet _bufferset;
-
-
- // dimensions
- float _analysisWidth;
- float _analysisHeight;
-
- // My objects
- FFT *_impulseFft;
- boost::shared_ptr<ARDOUR::Plugin> _plugin;
-
- // gui objects
- Gtk::DrawingArea *_analysisArea;
- cairo_surface_t *_analysisScaleSurface;
-
-
- // dB scale selection:
- class dBSelectionColumns : public Gtk::TreeModel::ColumnRecord
- {
- public:
- dBSelectionColumns()
- { add(dBMin); add(dBMax); add(dBStep); add(name); }
-
- Gtk::TreeModelColumn<float> dBMin;
- Gtk::TreeModelColumn<float> dBMax;
- Gtk::TreeModelColumn<float> dBStep;
- Gtk::TreeModelColumn<Glib::ustring> name;
- };
-
- dBSelectionColumns dBColumns;
-
- Gtk::ComboBox *dBScaleCombo;
- Glib::RefPtr<Gtk::ListStore> dBScaleModel;
-
- Gtk::CheckButton *phaseSelect;
-
- // signals and connections
- sigc::connection _updateConn;
-};
-
-#endif
-
#include <math.h>
FFT::FFT(uint32_t windowSize)
- : _windowSize(windowSize),
- _dataSize(_windowSize/2),
+ : _window_size(windowSize),
+ _data_size(_window_size/2),
_iterations(0)
{
- _fftInput = (float *) fftwf_malloc(sizeof(float) * _windowSize);
+ _fftInput = (float *) fftwf_malloc(sizeof(float) * _window_size);
- _fftOutput = (float *) fftwf_malloc(sizeof(float) * _windowSize);
+ _fftOutput = (float *) fftwf_malloc(sizeof(float) * _window_size);
- _powerAtBin = (float *) malloc(sizeof(float) * _dataSize);
- _phaseAtBin = (float *) malloc(sizeof(float) * _dataSize);
+ _power_at_bin = (float *) malloc(sizeof(float) * _data_size);
+ _phase_at_bin = (float *) malloc(sizeof(float) * _data_size);
- _plan = fftwf_plan_r2r_1d(_windowSize, _fftInput, _fftOutput, FFTW_R2HC, FFTW_ESTIMATE);
+ _plan = fftwf_plan_r2r_1d(_window_size, _fftInput, _fftOutput, FFTW_R2HC, FFTW_ESTIMATE);
reset();
}
void
FFT::reset()
{
- memset(_powerAtBin, 0, sizeof(float) * _dataSize);
- memset(_phaseAtBin, 0, sizeof(float) * _dataSize);
+ memset(_power_at_bin, 0, sizeof(float) * _data_size);
+ memset(_phase_at_bin, 0, sizeof(float) * _data_size);
_iterations = 0;
}
{
_iterations++;
- memcpy(_fftInput, input, sizeof(float) * _windowSize);
+ memcpy(_fftInput, input, sizeof(float) * _window_size);
fftwf_execute(_plan);
- _powerAtBin[0] += _fftOutput[0] * _fftOutput[0];
- _phaseAtBin[0] += 0.0;
+ _power_at_bin[0] += _fftOutput[0] * _fftOutput[0];
+ _phase_at_bin[0] += 0.0;
float power;
float phase;
#define Re (_fftOutput[i])
-#define Im (_fftOutput[_windowSize-i])
- for (uint32_t i=1; i < _dataSize - 1; i++) {
+#define Im (_fftOutput[_window_size-i])
+ for (uint32_t i=1; i < _data_size - 1; i++) {
power = (Re * Re) + (Im * Im);
phase = atanf(Im / Re);
phase -= M_PI;
}
- _powerAtBin[i] += power;
- _phaseAtBin[i] += phase;
+ _power_at_bin[i] += power;
+ _phase_at_bin[i] += phase;
}
#undef Re
#undef Im
FFT::calculate()
{
if (_iterations > 1) {
- for (uint32_t i=0; i < _dataSize - 1; i++) {
- _powerAtBin[i] /= (float)_iterations;
- _phaseAtBin[i] /= (float)_iterations;
+ for (uint32_t i=0; i < _data_size - 1; i++) {
+ _power_at_bin[i] /= (float)_iterations;
+ _phase_at_bin[i] /= (float)_iterations;
}
_iterations = 1;
}
FFT::~FFT()
{
fftwf_destroy_plan(_plan);
- free(_powerAtBin);
- free(_phaseAtBin);
+ free(_power_at_bin);
+ free(_phase_at_bin);
free(_fftOutput);
free(_fftInput);
}
void analyze(ARDOUR::Sample *);
void calculate();
- uint32_t bins() const { return _dataSize; }
+ uint32_t bins() const { return _data_size; }
- float powerAtBin(uint32_t i) const { return _powerAtBin[i]; }
- float phaseAtBin(uint32_t i) const { return _phaseAtBin[i]; }
+ float power_at_bin(uint32_t i) const { return _power_at_bin[i]; }
+ float phase_at_bin(uint32_t i) const { return _phase_at_bin[i]; }
private:
- uint32_t const _windowSize;
- uint32_t const _dataSize;
+ uint32_t const _window_size;
+ uint32_t const _data_size;
uint32_t _iterations;
float *_fftInput;
float *_fftOutput;
- float *_powerAtBin;
- float *_phaseAtBin;
+ float *_power_at_bin;
+ float *_phase_at_bin;
fftwf_plan _plan;
};
#include "utils.h"
#include "gui_thread.h"
#include "automation_controller.h"
+#include "plugin_eq_gui.h"
#include "i18n.h"
: PlugUIBase (pi),
button_table (initial_button_rows, initial_button_cols),
output_table (initial_output_rows, initial_output_cols),
+ eqgui_toggle(_("Freq Analysis")),
hAdjustment(0.0, 0.0, 0.0),
vAdjustment(0.0, 0.0, 0.0),
scroller_view(hAdjustment, vAdjustment),
{
set_name ("PluginEditor");
set_border_width (10);
- set_homogeneous (false);
+ //set_homogeneous (false);
+
+ pack1(main_contents);
settings_box.set_homogeneous (false);
constraint_hbox->set_spacing (5);
constraint_hbox->pack_start (*smaller_hbox, true, false);
constraint_hbox->pack_end (bypass_button, false, false);
+ constraint_hbox->pack_start (eqgui_toggle, false, false);
settings_box.pack_end (*constraint_hbox, false, false);
- pack_start (settings_box, false, false);
+ main_contents.pack_start (settings_box, false, false);
if ( is_scrollable ) {
scroller.set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
scroller_view.add (hpacker);
scroller.add (scroller_view);
- pack_start (scroller, true, true);
+ main_contents.pack_start (scroller, true, true);
}
else {
- pack_start (hpacker, false, false);
+ main_contents.pack_start (hpacker, false, false);
}
+ eqgui_toggle.set_active (false);
+ eqgui_toggle.signal_toggled().connect( mem_fun(*this, &GenericPluginUI::toggle_plugin_analysis));
+
pi->ActiveChanged.connect (bind(mem_fun(*this, &GenericPluginUI::processor_active_changed),
boost::weak_ptr<Processor>(pi)));
bypass_button.set_active (!pi->active());
return enums;
}
+
+
+void
+GenericPluginUI::toggle_plugin_analysis()
+{
+
+
+
+ if (eqgui_toggle.get_active() && !get_child2()) {
+ // Create the GUI
+ PluginEqGui *foo = new PluginEqGui(insert);
+ pack2( *foo );
+ show_all();
+ }
+
+ Gtk::Widget *gui;
+
+ if (!eqgui_toggle.get_active() && (gui = get_child2())) {
+ // Hide & remove
+ gui->hide();
+ remove(*gui);
+
+ delete gui;
+
+ Gtk::Widget *toplevel = get_toplevel();
+ if (!toplevel) {
+ std::cerr << "No toplevel widget?!?!" << std::endl;
+ return;
+ }
+
+ Gtk::Container *cont = dynamic_cast<Gtk::Container *>(toplevel);
+ if (!cont) {
+ std::cerr << "Toplevel widget is not a container?!?" << std::endl;
+ return;
+ }
+
+ Gtk::Allocation alloc(0, 0, 50, 50); // Just make it small
+ toplevel->size_allocate(alloc);
+ }
+}
--- /dev/null
+/*
+ Copyright (C) 2008 Paul Davis
+ Author: Sampo Savolainen
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "plugin_eq_gui.h"
+#include "fft.h"
+
+#include "ardour_ui.h"
+#include <ardour/audio_buffer.h>
+#include <ardour/data_type.h>
+
+#include <gtkmm/box.h>
+#include <gtkmm/button.h>
+#include <gtkmm/checkbutton.h>
+
+#include <iostream>
+
+
+PluginEqGui::PluginEqGui(boost::shared_ptr<ARDOUR::PluginInsert> pluginInsert)
+ : _min_dB(-12.0),
+ _max_dB(+12.0),
+ _step_dB(3.0),
+ _impulse_fft(0)
+{
+ _samplerate = ARDOUR_UI::instance()->the_session()->frame_rate();
+
+ _plugin = pluginInsert->get_impulse_analysis_plugin();
+ _plugin->activate();
+
+ set_buffer_size(4096);
+
+ _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;
+
+ _analysis_area = new Gtk::DrawingArea();
+ _analysis_width = 500.0;
+ _analysis_height = 500.0;
+ _analysis_area->set_size_request(_analysis_width, _analysis_height);
+
+ _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));
+
+
+ // dB selection
+ dBScaleModel = Gtk::ListStore::create(dBColumns);
+
+ dBScaleCombo = new Gtk::ComboBox(dBScaleModel);
+ dBScaleCombo -> set_title("dB scale");
+
+#define ADD_DB_ROW(MIN,MAX,STEP,NAME) \
+ { \
+ Gtk::TreeModel::Row row = *(dBScaleModel->append()); \
+ row[dBColumns.dBMin] = (MIN); \
+ row[dBColumns.dBMax] = (MAX); \
+ row[dBColumns.dBStep] = (STEP); \
+ row[dBColumns.name] = NAME; \
+ }
+
+ ADD_DB_ROW( -6, +6, 1, "-6dB .. +6dB");
+ ADD_DB_ROW(-12, +12, 3, "-12dB .. +12dB");
+ ADD_DB_ROW(-24, +24, 5, "-24dB .. +24dB");
+ ADD_DB_ROW(-36, +36, 6, "-36dB .. +36dB");
+
+#undef ADD_DB_ROW
+
+ dBScaleCombo -> pack_start(dBColumns.name);
+ dBScaleCombo -> set_active(1);
+
+ 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));
+
+ // Phase checkbutton
+ _phase_button = new Gtk::CheckButton("Show phase");
+ _phase_button->set_active(true);
+ _phase_button->signal_toggled().connect( sigc::mem_fun(*this, &PluginEqGui::redraw_scales));
+
+ // populate table
+ attach( *manage(_analysis_area), 1, 3, 1, 2);
+ attach( *manage(dBSelectBin), 1, 2, 2, 3, Gtk::SHRINK, Gtk::SHRINK);
+ attach( *manage(_phase_button), 2, 3, 2, 3, Gtk::SHRINK, Gtk::SHRINK);
+}
+
+PluginEqGui::~PluginEqGui()
+{
+ if (_analysis_scale_surface) {
+ cairo_surface_destroy (_analysis_scale_surface);
+ }
+
+ delete _impulse_fft;
+ _plugin->deactivate();
+
+ // all gui objects are *manage'd by the inherited Table object
+}
+
+
+void
+PluginEqGui::on_hide()
+{
+ stop_updating();
+ Gtk::Table::on_hide();
+}
+
+void
+PluginEqGui::stop_updating()
+{
+ if (_update_connection.connected()) {
+ _update_connection.disconnect();
+ }
+}
+
+void
+PluginEqGui::start_updating()
+{
+ if (!_update_connection.connected() && is_visible()) {
+ _update_connection = Glib::signal_timeout().connect( sigc::mem_fun(this, &PluginEqGui::timeout_callback), 250);
+ }
+}
+
+void
+PluginEqGui::on_show()
+{
+ Gtk::Table::on_show();
+
+ start_updating();
+
+ Gtk::Widget *toplevel = get_toplevel();
+ if (!toplevel) {
+ std::cerr << "No toplevel widget for PluginEqGui?!?!" << std::endl;
+ }
+
+ 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));
+ }
+
+}
+
+void
+PluginEqGui::change_dB_scale()
+{
+ Gtk::TreeModel::iterator iter = dBScaleCombo -> get_active();
+
+ Gtk::TreeModel::Row row;
+
+ if(iter && (row = *iter)) {
+ _min_dB = row[dBColumns.dBMin];
+ _max_dB = row[dBColumns.dBMax];
+ _step_dB = row[dBColumns.dBStep];
+
+
+ redraw_scales();
+ }
+}
+
+void
+PluginEqGui::redraw_scales()
+{
+
+ if (_analysis_scale_surface) {
+ cairo_surface_destroy (_analysis_scale_surface);
+ _analysis_scale_surface = 0;
+ }
+
+ _analysis_area->queue_draw();
+}
+
+void
+PluginEqGui::set_buffer_size(uint32_t size)
+{
+ if (_buffer_size == size)
+ return;
+
+ _buffer_size = size;
+
+ if (_impulse_fft) {
+ delete _impulse_fft;
+ _impulse_fft = 0;
+ }
+
+ _impulse_fft = new FFT(_buffer_size);
+
+ uint32_t inputs = _plugin->get_info()->n_inputs.n_audio();
+ uint32_t outputs = _plugin->get_info()->n_outputs.n_audio();
+
+ uint32_t n_chans = std::max(inputs, outputs);
+ _bufferset.ensure_buffers(ARDOUR::DataType::AUDIO, n_chans, _buffer_size);
+
+ ARDOUR::ChanCount chanCount(ARDOUR::DataType::AUDIO, n_chans);
+ _bufferset.set_count(chanCount);
+}
+
+void
+PluginEqGui::resize_analysis_area(Gtk::Allocation& size)
+{
+ _analysis_width = (float)size.get_width();
+ _analysis_height = (float)size.get_height();
+
+ if (_analysis_scale_surface) {
+ cairo_surface_destroy (_analysis_scale_surface);
+ _analysis_scale_surface = 0;
+ }
+}
+
+bool
+PluginEqGui::timeout_callback()
+{
+ run_analysis();
+
+ return true;
+}
+
+void
+PluginEqGui::run_analysis()
+{
+ uint32_t inputs = _plugin->get_info()->n_inputs.n_audio();
+ uint32_t outputs = _plugin->get_info()->n_outputs.n_audio();
+
+ // 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(_buffer_size, 0);
+ memset(d, 0, sizeof(ARDOUR::Sample)*_buffer_size);
+ *d = 1.0;
+ }
+ uint32_t x,y;
+ x=y=0;
+
+ _plugin->connect_and_run(_bufferset, x, y, _buffer_size, (nframes_t)0);
+
+ // Analyze all output buffers
+ _impulse_fft->reset();
+ for (uint32_t i = 0; i < outputs; ++i) {
+ _impulse_fft->analyze(_bufferset.get_audio(i).data(_buffer_size, 0));
+ }
+
+ // normalize the output
+ _impulse_fft->calculate();
+
+ // This signals calls expose_analysis_area()
+ _analysis_area->queue_draw();
+
+}
+
+bool
+PluginEqGui::expose_analysis_area(GdkEventExpose *evt)
+{
+ redraw_analysis_area();
+
+ return false;
+}
+
+void
+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),
+ 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);
+
+
+ draw_scales_power(_analysis_area, cr);
+ if (_phase_button->get_active()) {
+ draw_scales_phase(_analysis_area, cr);
+ }
+
+ cairo_destroy(cr);
+
+}
+
+void
+PluginEqGui::redraw_analysis_area()
+{
+ cairo_t *cr;
+
+ cr = gdk_cairo_create(GDK_DRAWABLE(_analysis_area->get_window()->gobj()));
+
+ if (_analysis_scale_surface == 0) {
+ draw_analysis_scales(cr);
+ }
+
+
+ cairo_copy_page(cr);
+
+ cairo_set_source_surface(cr, _analysis_scale_surface, 0.0, 0.0);
+ cairo_paint(cr);
+
+ if (_phase_button->get_active()) {
+ plot_phase(_analysis_area, cr);
+ }
+ plot_amplitude(_analysis_area, cr);
+
+
+ cairo_destroy(cr);
+
+
+}
+
+#define PHASE_PROPORTION 0.6
+
+void
+PluginEqGui::draw_scales_phase(Gtk::Widget *w, cairo_t *cr)
+{
+ float y;
+ cairo_font_extents_t extents;
+ cairo_font_extents(cr, &extents);
+
+ char buf[256];
+ cairo_text_extents_t t_ext;
+
+ for (uint32_t i = 0; i < 3; i++) {
+
+ y = _analysis_height/2.0 - (float)i*(_analysis_height/8.0)*PHASE_PROPORTION;
+
+ cairo_set_source_rgb(cr, .8, .9, 0.2);
+ if (i == 0) {
+ snprintf(buf,256, "0\u00b0");
+ } else {
+ 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);
+
+ if (i == 0)
+ continue;
+
+
+ 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);
+
+
+ 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);
+
+ // 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_line_width (cr, 0.25 + 1.0/(float)(i+1));
+ cairo_stroke(cr);
+ }
+}
+
+void
+PluginEqGui::plot_phase(Gtk::Widget *w, cairo_t *cr)
+{
+ float x,y;
+
+ int prevX = 0;
+ float avgY = 0.0;
+ int avgNum = 0;
+
+ 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 *= _analysis_width;
+
+ 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);
+
+ avgY = 0;
+ avgNum = 0;
+ } else if (rint(x) > prevX || i == _impulse_fft->bins()-1 ) {
+ cairo_line_to(cr, prevX, avgY/(float)avgNum);
+
+ avgY = 0;
+ avgNum = 0;
+
+ }
+
+ prevX = rint(x);
+ avgY += y;
+ avgNum++;
+ }
+
+ cairo_set_line_width (cr, 2.0);
+ cairo_stroke(cr);
+}
+
+void
+PluginEqGui::draw_scales_power(Gtk::Widget *w, cairo_t *cr)
+{
+ static float scales[] = { 30.0, 70.0, 125.0, 250.0, 500.0, 1000.0, 2000.0, 5000.0, 10000.0, 15000.0, 20000.0, -1.0 };
+
+ float divisor = _samplerate / 2.0 / _impulse_fft->bins();
+ float x;
+
+ cairo_set_line_width (cr, 1.5);
+ cairo_set_font_size(cr, 9);
+
+ cairo_font_extents_t extents;
+ cairo_font_extents(cr, &extents);
+ float fontXOffset = extents.descent + 1.0;
+
+ char buf[256];
+
+ 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 *= _analysis_width;
+
+ if (scales[i] < 1000.0) {
+ snprintf(buf, 256, "%0.0f", scales[i]);
+ } else {
+ snprintf(buf, 256, "%0.0fk", scales[i]/1000.0);
+ }
+
+ cairo_set_source_rgb(cr, 0.4, 0.4, 0.4);
+
+ cairo_move_to(cr, x + fontXOffset, 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_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;
+
+ //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 );
+
+ 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.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);
+ }
+ }
+
+
+
+ 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 *= _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.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);
+
+}
+
+inline float
+power_to_dB(float a)
+{
+ return 10.0 * log10f(a);
+}
+
+void
+PluginEqGui::plot_amplitude(Gtk::Widget *w, cairo_t *cr)
+{
+ float x,y;
+
+ int prevX = 0;
+ float avgY = 0.0;
+ int avgNum = 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++) {
+ // x coordinate of bin i
+ 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);
+
+ 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 ) {
+ cairo_line_to(cr, prevX, avgY/(float)avgNum);
+
+ avgY = 0;
+ avgNum = 0;
+
+ }
+
+ prevX = rint(x);
+ avgY += y;
+ avgNum++;
+ }
+
+ cairo_stroke(cr);
+}
+
--- /dev/null
+/*
+ Copyright (C) 2008 Paul Davis
+ Author: Sampo Savolainen
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#ifndef __ardour_plugin_eq_gui_h
+#define __ardour_plugin_eq_gui_h
+
+#include <ardour/buffer_set.h>
+#include <ardour/plugin_insert.h>
+#include <ardour/plugin.h>
+
+#include <gtkmm/table.h>
+#include <gtkmm/drawingarea.h>
+#include <gtkmm/combobox.h>
+#include <gtkmm/liststore.h>
+
+class FFT;
+
+class PluginEqGui : public Gtk::Table
+{
+ public:
+ PluginEqGui(boost::shared_ptr<ARDOUR::PluginInsert>);
+ ~PluginEqGui();
+
+
+
+ private:
+ // Setup
+ void set_buffer_size(uint32_t);
+ void change_dB_scale();
+
+ // Analysis
+ void run_analysis();
+
+ // Drawing
+ virtual void on_hide();
+ virtual void on_show();
+
+ void stop_updating();
+ void start_updating();
+
+ void resize_analysis_area(Gtk::Allocation&);
+ void redraw_analysis_area();
+
+ void draw_analysis_scales(cairo_t *);
+ bool expose_analysis_area(GdkEventExpose *);
+
+ void draw_scales_power(Gtk::Widget *, cairo_t *);
+ void plot_amplitude(Gtk::Widget *,cairo_t *);
+
+ void draw_scales_phase(Gtk::Widget *,cairo_t *);
+ void plot_phase(Gtk::Widget *,cairo_t *);
+
+ // Helpers
+ bool timeout_callback();
+ void redraw_scales();
+
+
+ // Fields:
+
+ // analysis parameters
+ float _samplerate;
+
+ float _min_dB;
+ float _max_dB;
+ float _step_dB;
+
+
+ float _log_coeff;
+ float _log_max;
+
+ nframes_t _buffer_size;
+
+ // buffers
+ ARDOUR::BufferSet _bufferset;
+
+
+ // dimensions
+ float _analysis_width;
+ float _analysis_height;
+
+ // My objects
+ FFT *_impulse_fft;
+ boost::shared_ptr<ARDOUR::Plugin> _plugin;
+
+ // gui objects
+ Gtk::DrawingArea *_analysis_area;
+ cairo_surface_t *_analysis_scale_surface;
+
+
+ // dB scale selection:
+ class dBSelectionColumns : public Gtk::TreeModel::ColumnRecord
+ {
+ public:
+ dBSelectionColumns()
+ { add(dBMin); add(dBMax); add(dBStep); add(name); }
+
+ Gtk::TreeModelColumn<float> dBMin;
+ Gtk::TreeModelColumn<float> dBMax;
+ Gtk::TreeModelColumn<float> dBStep;
+ Gtk::TreeModelColumn<Glib::ustring> name;
+ };
+
+ dBSelectionColumns dBColumns;
+
+ Gtk::ComboBox *dBScaleCombo;
+ Glib::RefPtr<Gtk::ListStore> dBScaleModel;
+
+ Gtk::CheckButton *_phase_button;
+
+ // signals and connections
+ sigc::connection _update_connection;
+ sigc::connection _window_unmap_connection;
+ sigc::connection _window_map_connection;
+};
+
+#endif
+
#include "gui_thread.h"
#include "public_editor.h"
#include "keyboard.h"
-#include "eq_gui.h"
#include "i18n.h"
GenericPluginUI* pu = new GenericPluginUI (insert, scrollable);
_pluginui = pu;
-
+ add( *pu );
+
+ /*
Gtk::HBox *hbox = new Gtk::HBox();
hbox->pack_start( *pu);
// TODO: this should be nicer
- hbox->pack_start( *manage(new PluginEqGui(insert)));
+ hbox->pack_start( eqgui_bin );
add (*manage(hbox));
-
+ */
set_wmclass (X_("ardour_plugin_editor"), "Ardour");
Gtk::ComboBoxText preset_combo;
Gtk::Button save_button;
Gtk::ToggleButton bypass_button;
+
LatencyGUI latency_gui;
void setting_selected();
void processor_active_changed (boost::weak_ptr<ARDOUR::Processor> p);
};
-class GenericPluginUI : public PlugUIBase, public Gtk::VBox
+class GenericPluginUI : public PlugUIBase, public Gtk::HPaned
{
public:
GenericPluginUI (boost::shared_ptr<ARDOUR::PluginInsert> plug, bool scrollable=false);
bool stop_updating(GdkEventAny*);
private:
+ Gtk::VBox main_contents;
+
Gtk::HBox settings_box;
Gtk::HBox hpacker;
Gtk::Table button_table;
Gtk::Table output_table;
+ Gtk::ToggleButton eqgui_toggle;
+
Gtk::ScrolledWindow scroller;
Gtk::Adjustment hAdjustment;
Gtk::Adjustment vAdjustment;
void start_touch (ControlUI*);
void stop_touch (ControlUI*);
+ void toggle_plugin_analysis ();
+
void print_parameter (char *buf, uint32_t len, uint32_t param);
};