55 ref_response << g.drawLine(0.25, 0.0, 0.8)
56 << g.drawLine(0.25, 0.8, 0.8)
57 << g.drawLine(0.15, 0.8, 1.4)
58 << g.drawLine(0.15, 1.4, 1.4)
59 << g.drawLine(0.20, 1.4, 0.0);
62 while( ref_response.
getLength() < 256 ) ref_response << 0.0;
64 Buffer ref_freq_axis = g.drawLine(1.0, 0.0, sr/2.0);
71 pylab.
plot(ref_freq_axis, ref_response);
72 pylab.
title(
"desired frequency response");
74 Buffer evolution = f.designFrequencyResponse(ref_response, 0.001, 10000);
76 cout <<
"f = " << endl << f << endl;
79 pylab.
plot(evolution);
82 pylab.
xlabel(
"Generation");
86 float64 error = evolution[n_generations - 1];
89 sprintf(buffer,
"%5.2f RMS error in %d generations",
93 pylab.
title(std::string(buffer));
95 Buffer fr = f.getFrequencyResponse();
96 Buffer faxis = f.getFrequencyAxis();
99 pylab.
plot(ref_freq_axis, ref_response);
100 pylab.
plot(faxis, fr);
101 pylab.
xlabel(
"Frequency Hz");
102 pylab.
ylabel(
"Frequency Response");
104 pylab.
ylim(0.0, ref_response.
getMax() * 1.10);
106 sprintf(buffer,
"Generation %06d", n_generations);
108 pylab.
title(std::string(buffer));
112 sprintf(buffer,
"Error = %.3f RMS", error);
115 faxis[static_cast<uint32>(faxis.
getLength() * 0.5)],
117 std::string(buffer));
void xlabel(const std::string &label, const std::string &kwargs="")
Add a label x axis.
void plot(const Buffer &y, const std::string &fmt="", const std::string &kwargs="")
Plots the Buffer on the current figure.
void figure(const std::string &kwargs="") const
Creates a new figure window to plot in.
void title(const std::string &title, const std::string &kwargs="")
Add a title to the plot at the top and centered.
void xlim(const float64 &xmin, const float64 &xmax)
Sets the limit for the x & y axis.
uint32 getLength() const
Returns the number of samples in the Buffer.
void ylim(const float64 &ymin, const float64 &ymax)
void text(const float64 &x, const float64 &y, const std::string &text, const std::string &kwargs="")
Adds text at the x, y data point.
void ylabel(const std::string &label, const std::string &kwargs="")
Add a label y axis.
A Buffer for storing audio samples.
float64 getMax() const
Returns the maximum sample value in the Buffer.
A class the provides draw utilities and a wavetable oscillator.