Nsound
0.9.4
|
#include <Nsound/Plotter.h>
Public Member Functions | |
Plotter () | |
Construct the Plotter. More... | |
virtual | ~Plotter () |
Deconstruct the Plotter. More... | |
void | axhline (const float64 &y_pos=0.0, const std::string &kwargs="") |
Draws a horizontal line at y and spans xmin to xmax (ralitive). More... | |
void | axvline (const float64 &x_pos=0.0, const std::string &kwargs="") |
Draws a vertical line at x and spans ymin to ymax (ralitive). More... | |
void | xlim (const float64 &xmin, const float64 &xmax) |
Sets the limit for the x & y axis. More... | |
void | ylim (const float64 &ymin, const float64 &ymax) |
void | figure (const std::string &kwargs="") const |
Creates a new figure window to plot in. More... | |
void | grid (boolean flag) |
Sets the grid state. More... | |
void | hide () |
Hides all plots, prevents any plot window being rendered to the screen. Usefull if only saveing plots to disk. More... | |
void | hold (boolean flag) |
Sets the hold state. More... | |
void | imagesc (const AudioStream &Z, const std::string &kwargs="") |
Plots the AudioStream like a 2D matrix. More... | |
void | imagesc (const Buffer &x_axis, const Buffer &y_axis, const AudioStream &Z, const std::string &kwargs="") |
Plots the AudioStream like a 2D matrix with axis labels. More... | |
void | legend (const std::string &kwargs="") |
Shows the legend on the current axes. More... | |
void | plot (const Buffer &y, const std::string &fmt="", const std::string &kwargs="") |
Plots the Buffer on the current figure. More... | |
void | plot (const Buffer &x, const Buffer &y, const std::string &fmt="", const std::string &kwargs="") |
Plots x vs y on the current figure, length(x) must equal length(y) More... | |
void | plot (const float64 &x, const float64 &y, const std::string &fmt="", const std::string &kwargs="") |
Plots x vs y on the current figure. More... | |
void | run_string (const std::string &command) const |
executes the python string More... | |
void | savefig (const std::string &filename, const std::string &kwargs="") |
Saves the last figure drawn to filename. More... | |
void | set_xscale (const std::string &s) |
Sets the x axis scaling: log or linear. More... | |
void | set_yscale (const std::string &s) |
Sets the y axis scaling: log or linear. More... | |
Axes | subplot (const uint32 n_rows, const uint32 n_cols, const uint32 n, const std::string &kwargs="", Axes *sharex=NULL, Axes *sharey=NULL) |
Creates a figure in a subplot, subplot(A, B, C, **kwargs) More... | |
void | text (const float64 &x, const float64 &y, const std::string &text, const std::string &kwargs="") |
Adds text at the x, y data point. More... | |
void | title (const std::string &title, const std::string &kwargs="") |
Add a title to the plot at the top and centered. More... | |
void | xlabel (const std::string &label, const std::string &kwargs="") |
Add a label x axis. More... | |
void | ylabel (const std::string &label, const std::string &kwargs="") |
Add a label y axis. More... | |
void | _swig_shadow () |
SWIG helper function function to shadow. More... | |
Static Public Member Functions | |
static void | show () |
Acutally draw the plots to the screen. More... | |
Protected Types | |
enum | PlotterState { BOOTING, INITALIZED, UNLOADED } |
typedef std::pair< std::string, PyObject * > | StringPyObjectPair |
typedef std::map< std::string, PyObject * > | PylabTable |
Protected Member Functions | |
PyObject * | _make_kwargs (const std::string &kwargs) const |
Static Protected Attributes | |
static int32 | count_ = 0 |
static PylabTable | table_ |
static PlotterState | state_ = Plotter::BOOTING |
static boolean | grid_is_on_ = true |
static boolean | hold_is_on_ = false |
static float64 | xmin_ = 1e300 |
static float64 | xmax_ = -1e300 |
static float64 | ymin_ = 1e300 |
static float64 | ymax_ = -1e300 |
Private Member Functions | |
Plotter (const Plotter &rhs) | |
Copy constructor disabled. More... | |
Plotter & | operator= (const Plotter &rhs) |
Asignment disabled. More... | |
PyObject * | makePyListFromBuffer (const Buffer &buffer) const |
Create a PyList object from a buffer! More... | |
PyObject * | makePyIntFromUint32 (const uint32 &i) const |
Create a PyInt. More... | |
|
protected |
|
protected |
|
protected |
Enumerator | |
---|---|
BOOTING | |
INITALIZED | |
UNLOADED |
Plotter::Plotter | ( | ) |
Construct the Plotter.
Definition at line 114 of file Plotter.cc.
References BOOTING, count_, INITALIZED, M_CHECK_PY_PTR_RETURN, M_THROW, run_string(), state_, and table_.
|
virtual |
Deconstruct the Plotter.
Definition at line 230 of file Plotter.cc.
References count_, state_, and UNLOADED.
|
private |
Copy constructor disabled.
void Plotter::axhline | ( | const float64 & | y_pos = 0.0 , |
const std::string & | kwargs = "" |
||
) |
Draws a horizontal line at y and spans xmin to xmax (ralitive).
Definition at line 327 of file Plotter.cc.
References _make_kwargs(), INITALIZED, M_CHECK_PY_PTR_RETURN, state_, and table_.
void Plotter::axvline | ( | const float64 & | x_pos = 0.0 , |
const std::string & | kwargs = "" |
||
) |
Draws a vertical line at x and spans ymin to ymax (ralitive).
Definition at line 358 of file Plotter.cc.
References _make_kwargs(), INITALIZED, M_CHECK_PY_PTR_RETURN, state_, and table_.
Referenced by Nsound::FilterLowPassMoogVcf::plot(), Nsound::FilterTone::plot(), Nsound::FilterHighPassIIR::plot(), Nsound::FilterLowPassIIR::plot(), Nsound::FilterCombLowPassFeedback::plot(), Nsound::FilterLowPassFIR::plot(), Nsound::FilterHighPassFIR::plot(), Nsound::FilterBandPassVocoder::plot(), Nsound::FilterBandPassFIR::plot(), Nsound::FilterBandRejectFIR::plot(), Nsound::FilterBandRejectIIR::plot(), and Nsound::FilterParametricEqualizer::plot().
Sets the limit for the x & y axis.
Definition at line 389 of file Plotter.cc.
References INITALIZED, M_ASSERT_VALUE, M_CHECK_PY_PTR_RETURN, state_, and table_.
Referenced by main(), my_main(), Nsound::FilterIIR::savePlot(), and Nsound::Vocoder::Vocoder().
Definition at line 422 of file Plotter.cc.
References INITALIZED, M_ASSERT_VALUE, M_CHECK_PY_PTR_RETURN, state_, and table_.
Referenced by main(), my_main(), Nsound::Filter::plot(), Nsound::FilterIIR::savePlot(), and Nsound::Vocoder::Vocoder().
void Plotter::figure | ( | const std::string & | kwargs = "" | ) | const |
Creates a new figure window to plot in.
Definition at line 455 of file Plotter.cc.
References _make_kwargs(), INITALIZED, M_CHECK_PY_PTR_RETURN, state_, and table_.
Referenced by main(), my_main(), Nsound::Spectrogram::plot(), Nsound::FFTChunk::plot(), Nsound::Filter::plot(), Nsound::AudioStream::plot(), Nsound::Buffer::plot(), Nsound::FilterIIR::savePlot(), and Nsound::Vocoder::Vocoder().
void Plotter::grid | ( | boolean | flag | ) |
Sets the grid state.
Definition at line 496 of file Plotter.cc.
References run_string().
Referenced by Generator_UnitTest(), hold(), and Nsound::Vocoder::Vocoder().
void Plotter::hide | ( | ) |
Hides all plots, prevents any plot window being rendered to the screen. Usefull if only saveing plots to disk.
Definition at line 525 of file Plotter.cc.
References INITALIZED, M_CHECK_PY_PTR_RETURN, state_, and table_.
void Plotter::hold | ( | boolean | flag | ) |
Sets the hold state.
Definition at line 554 of file Plotter.cc.
References grid(), hold_is_on_, INITALIZED, M_CHECK_PY_PTR_RETURN, state_, and table_.
Referenced by Nsound::Vocoder::Vocoder().
void Plotter::imagesc | ( | const AudioStream & | Z, |
const std::string & | kwargs = "" |
||
) |
Plots the AudioStream like a 2D matrix.
Definition at line 593 of file Plotter.cc.
Referenced by my_main(), and Nsound::Spectrogram::plot().
void Plotter::imagesc | ( | const Buffer & | x_axis, |
const Buffer & | y_axis, | ||
const AudioStream & | Z, | ||
const std::string & | kwargs = "" |
||
) |
Plots the AudioStream like a 2D matrix with axis labels.
Definition at line 600 of file Plotter.cc.
References _make_kwargs(), Nsound::AudioStream::getLength(), Nsound::Buffer::getLength(), Nsound::AudioStream::getNChannels(), grid_is_on_, INITALIZED, M_CHECK_PY_PTR_RETURN, M_THROW, makePyListFromBuffer(), run_string(), state_, and table_.
void Plotter::legend | ( | const std::string & | kwargs = "" | ) |
Shows the legend on the current axes.
Definition at line 745 of file Plotter.cc.
References _make_kwargs(), M_CHECK_PY_PTR_RETURN, and table_.
Referenced by Generator_UnitTest().
void Plotter::plot | ( | const Buffer & | y, |
const std::string & | fmt = "" , |
||
const std::string & | kwargs = "" |
||
) |
Plots the Buffer on the current figure.
Definition at line 765 of file Plotter.cc.
Referenced by Generator_UnitTest(), main(), my_main(), Nsound::FFTChunk::plot(), Nsound::Filter::plot(), plot(), Nsound::AudioStream::plot(), Nsound::Buffer::plot(), Nsound::FilterIIR::savePlot(), and Nsound::Vocoder::Vocoder().
void Plotter::plot | ( | const Buffer & | x, |
const Buffer & | y, | ||
const std::string & | fmt = "" , |
||
const std::string & | kwargs = "" |
||
) |
Plots x vs y on the current figure, length(x) must equal length(y)
Definition at line 775 of file Plotter.cc.
References _make_kwargs(), Nsound::Buffer::getLength(), grid_is_on_, INITALIZED, M_ASSERT_VALUE, M_CHECK_PY_PTR_RETURN, makePyListFromBuffer(), run_string(), state_, and table_.
void Plotter::plot | ( | const float64 & | x, |
const float64 & | y, | ||
const std::string & | fmt = "" , |
||
const std::string & | kwargs = "" |
||
) |
Plots x vs y on the current figure.
Definition at line 915 of file Plotter.cc.
References plot().
void Plotter::run_string | ( | const std::string & | command | ) | const |
executes the python string
Definition at line 933 of file Plotter.cc.
References M_CHECK_PY_PTR_RETURN, and table_.
Referenced by grid(), imagesc(), plot(), Plotter(), savefig(), set_xscale(), set_yscale(), and subplot().
void Plotter::savefig | ( | const std::string & | filename, |
const std::string & | kwargs = "" |
||
) |
Saves the last figure drawn to filename.
Definition at line 951 of file Plotter.cc.
References INITALIZED, run_string(), and state_.
void Plotter::set_xscale | ( | const std::string & | s | ) |
Sets the x axis scaling: log or linear.
Definition at line 995 of file Plotter.cc.
References run_string().
void Plotter::set_yscale | ( | const std::string & | s | ) |
Sets the y axis scaling: log or linear.
Definition at line 1013 of file Plotter.cc.
References run_string().
Axes Plotter::subplot | ( | const uint32 | n_rows, |
const uint32 | n_cols, | ||
const uint32 | n, | ||
const std::string & | kwargs = "" , |
||
Axes * | sharex = NULL , |
||
Axes * | sharey = NULL |
||
) |
Creates a figure in a subplot, subplot(A, B, C, **kwargs)
A = number of rows B = number of columns C = axes number kwargs - keyword arguments sharex - an axes to share xlimits with sharey - an axes to share ylimits with
Definition at line 1031 of file Plotter.cc.
References _make_kwargs(), Nsound::Axes::get_axes(), grid_is_on_, INITALIZED, M_CHECK_PY_PTR, run_string(), state_, and table_.
Referenced by main(), my_main(), Nsound::FilterLowPassMoogVcf::plot(), Nsound::FilterPhaser::plot(), Nsound::FilterTone::plot(), Nsound::FilterHighPassIIR::plot(), Nsound::FFTChunk::plot(), Nsound::FilterLowPassIIR::plot(), Nsound::FilterCombLowPassFeedback::plot(), Nsound::FilterLowPassFIR::plot(), Nsound::FilterAllPass::plot(), Nsound::FilterHighPassFIR::plot(), Nsound::FilterBandPassVocoder::plot(), Nsound::Filter::plot(), Nsound::FilterBandPassFIR::plot(), Nsound::FilterLeastSquaresFIR::plot(), Nsound::FilterFlanger::plot(), Nsound::FilterBandRejectFIR::plot(), Nsound::FilterBandRejectIIR::plot(), and Nsound::AudioStream::plot().
void Plotter::text | ( | const float64 & | x, |
const float64 & | y, | ||
const std::string & | text, | ||
const std::string & | kwargs = "" |
||
) |
Adds text at the x, y data point.
Definition at line 1092 of file Plotter.cc.
References _make_kwargs(), INITALIZED, M_CHECK_PY_PTR_RETURN, state_, and table_.
Referenced by main(), and Nsound::FilterIIR::savePlot().
void Plotter::title | ( | const std::string & | title, |
const std::string & | kwargs = "" |
||
) |
Add a title to the plot at the top and centered.
Definition at line 1127 of file Plotter.cc.
References _make_kwargs(), INITALIZED, M_CHECK_PY_PTR_RETURN, state_, and table_.
Referenced by main(), my_main(), Nsound::FilterLowPassMoogVcf::plot(), Nsound::Spectrogram::plot(), Nsound::FilterPhaser::plot(), Nsound::FilterTone::plot(), Nsound::FilterHighPassIIR::plot(), Nsound::FFTChunk::plot(), Nsound::FilterLowPassIIR::plot(), Nsound::FilterCombLowPassFeedback::plot(), Nsound::FilterLowPassFIR::plot(), Nsound::FilterAllPass::plot(), Nsound::FilterHighPassFIR::plot(), Nsound::FilterBandPassVocoder::plot(), Nsound::FilterBandPassFIR::plot(), Nsound::FilterLeastSquaresFIR::plot(), Nsound::FilterFlanger::plot(), Nsound::FilterBandRejectFIR::plot(), Nsound::FilterBandRejectIIR::plot(), Nsound::FilterParametricEqualizer::plot(), Nsound::AudioStream::plot(), Nsound::Buffer::plot(), and Nsound::FilterIIR::savePlot().
void Plotter::xlabel | ( | const std::string & | label, |
const std::string & | kwargs = "" |
||
) |
Add a label x axis.
Definition at line 1154 of file Plotter.cc.
References _make_kwargs(), INITALIZED, M_CHECK_PY_PTR_RETURN, state_, and table_.
Referenced by main(), my_main(), Nsound::Spectrogram::plot(), Nsound::FFTChunk::plot(), Nsound::Filter::plot(), Nsound::AudioStream::plot(), Nsound::FilterIIR::savePlot(), and Nsound::Vocoder::Vocoder().
void Plotter::ylabel | ( | const std::string & | label, |
const std::string & | kwargs = "" |
||
) |
Add a label y axis.
Definition at line 1180 of file Plotter.cc.
References _make_kwargs(), INITALIZED, M_CHECK_PY_PTR_RETURN, state_, and table_.
Referenced by main(), my_main(), Nsound::Spectrogram::plot(), Nsound::FFTChunk::plot(), Nsound::Filter::plot(), Nsound::AudioStream::plot(), Nsound::FilterIIR::savePlot(), and Nsound::Vocoder::Vocoder().
|
static |
Acutally draw the plots to the screen.
Definition at line 252 of file Plotter.cc.
References INITALIZED, M_CHECK_PY_PTR_RETURN, state_, and table_.
Referenced by Buffer_UnitTest(), BufferResample_UnitTest(), DelayLine_UnitTest(), FFTransform_UnitTest(), FilterCombLowPassFeedback_UnitTest(), FilterDelay_UnitTest(), FilterLeastSquaresFIR_UnitTest(), FilterParametricEqualizer_UnitTest(), Generator_UnitTest(), main(), my_main(), Sine_UnitTest(), testBufferAdd(), Triangle_UnitTest(), and Wavefile_UnitTest().
|
inline |
|
protected |
|
staticprotected |
Definition at line 207 of file Plotter.h.
Referenced by Plotter(), and ~Plotter().
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |