Nsound  0.9.4
Functions
test_plotter.cc File Reference
#include <Nsound/AudioStream.h>
#include <Nsound/Buffer.h>
#include <Nsound/Nsound.h>
#include <Nsound/Generator.h>
#include <Nsound/Plotter.h>
#include <Nsound/Sine.h>
#include <cmath>
#include <iostream>
Include dependency graph for test_plotter.cc:

Go to the source code of this file.

Functions

void testBuffer ()
 
int main (int argc, char **argv)
 

Function Documentation

void testBuffer ( )
int main ( int  argc,
char **  argv 
)

Definition at line 47 of file test_plotter.cc.

References Nsound::Generator::drawFatGaussian(), Nsound::Generator::drawGaussian(), Nsound::Generator::drawLine(), Nsound::Plotter::figure(), Nsound::Plotter::plot(), Nsound::AudioStream::plot(), Nsound::Plotter::show(), Nsound::Plotter::subplot(), Nsound::Plotter::title(), Nsound::Plotter::xlabel(), and Nsound::Plotter::ylabel().

48 {
49  Generator generator(5000);
50  Sine sine(5000);
51 
52  AudioStream as(5000, 2);
53 
54  // Draw some signals.
55  as[0] = sine.drawGaussian(2.0, 1.0, 0.10);
56  as[1] = sine.drawFatGaussian(2.0, 0.3);
57 
58  Plotter pylab;
59 
60  // Plot a buffer in blue.
61  pylab.plot(as[0],"b");
62 
63  // Plot a buffer in red.
64  pylab.plot(as[1],"r");
65 
66  // Set the title.
67  pylab.title("blue = default gaussian, red = gaussian with 30% pass band");
68 
69  // Set the axis labels.
70  pylab.xlabel("sample");
71  pylab.ylabel("amplitude");
72 
73  // Creating a plot with two subplots
74  Buffer x_axis = sine.drawLine(2.0, 0.0, 2.0);
75 
76  pylab.figure();
77  pylab.subplot(2,1,1);
78  pylab.title("default gaussian");
79  pylab.plot(x_axis, as[0], "b");
80  pylab.ylabel("amplitude");
81 
82  pylab.subplot(2,1,2);
83  pylab.title("gaussian with 30% pass band");
84  pylab.plot(x_axis, as[1], "r");
85  pylab.xlabel("seconds");
86  pylab.ylabel("amplitude");
87 
88  // simple plot of AudioStream
89  as.plot("quick plot from AudioStream");
90 
91  // simple plots of Buffers
92  as[1].plot("quick plot, gaussian with 30% pass band");
93  as[0].plot("quick plot, default gaussian");
94 
95  Plotter::show();
96 
97  return 0;
98 }
void xlabel(const std::string &label, const std::string &kwargs="")
Add a label x axis.
Definition: Plotter.cc:1154
void plot(const Buffer &y, const std::string &fmt="", const std::string &kwargs="")
Plots the Buffer on the current figure.
Definition: Plotter.cc:765
void figure(const std::string &kwargs="") const
Creates a new figure window to plot in.
Definition: Plotter.cc:455
void title(const std::string &title, const std::string &kwargs="")
Add a title to the plot at the top and centered.
Definition: Plotter.cc:1127
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)
Definition: Plotter.cc:1031
void ylabel(const std::string &label, const std::string &kwargs="")
Add a label y axis.
Definition: Plotter.cc:1180
A Buffer for storing audio samples.
Definition: Buffer.h:60
DOXME.
Definition: Sine.h:43
A class the provides draw utilities and a wavetable oscillator.
Definition: Generator.h:50