57     Wavefile::setDefaultSampleSize(64);
 
   58     Wavefile::setIEEEFloat(
true);
 
   62     Buffer input = cos.buzz(1.0, 8.0, 2.0, 0.0);
 
   70     cout << 
TEST_HEADER << 
"Testing FFTransform::fft(), ifft() ..." << flush;
 
   72     vec = fft.fft(input, 128, 0);
 
   74     if(vec.size() != 512 / 128)
 
   77              << 
"Output did not match!" 
   79              << 
"vec.size() = " << vec.size() << 
" != " << 512 / 128
 
   85     Buffer data = fft.ifft(vec);
 
   93              << 
"Output did not match!" 
   95              << 
"result.getLength() = " << data.
getLength() << 
" != " 
  105     gold = 
Buffer(
"gold/FFTransform_out1.wav");
 
  107     Buffer diff = data - gold;
 
  112              << 
"Output did not match gold file!" 
  115         diff.
plot(
"input - gold");
 
  125     cout << 
TEST_HEADER << 
"Testing FFTChunk::getReal(), getImaginary() ..." << flush;
 
  127     vec = fft.fft(input, 128, 0);
 
  129     Buffer real = vec[0].getReal();
 
  130     Buffer img  = vec[0].getImaginary();
 
  136     gold = 
Buffer(
"gold/FFTransform_out2.wav");
 
  143              << 
"Output did not match gold file!" 
  146         diff.
plot(
"real - gold");
 
  154     gold = 
Buffer(
"gold/FFTransform_out3.wav");
 
  162              << 
"Output did not match gold file!" 
  165         diff.
plot(
"img - gold");
 
  175     cout << 
TEST_HEADER << 
"Testing FFTChunk::getMagnitude(), getPhase() ..." << flush;
 
  177     vec = fft.fft(input, 128, 0);
 
  179     Buffer mag   = vec[0].getMagnitude();
 
  180     Buffer phase = vec[0].getPhase();
 
  186     gold = 
Buffer(
"gold/FFTransform_out4.wav");
 
  193              << 
"Output did not match gold file!" 
  196         diff.
plot(
"data - gold");
 
  204     gold = 
Buffer(
"gold/FFTransform_out5.wav");
 
  208     diff(diff > 2.0 * 
M_PI - 0.01) = 0.0;
 
  209     diff(diff < 2.0 * 
M_PI - 0.01) = 0.0;
 
  214              << 
"Output did not match gold file!" 
  217         diff.
plot(
"phase - gold");
 
  227     cout << 
TEST_HEADER << 
"Testing FFTChunk::toCartesian(), toPolar() ..." << flush;
 
  231     mag   = vec[0].getMagnitude();
 
  232     phase = vec[0].getPhase();
 
  234     gold = 
Buffer(
"gold/FFTransform_out4.wav");
 
  241              << 
"Output did not match gold file!" 
  244         diff.
plot(
"data - gold");
 
  252     gold = 
Buffer(
"gold/FFTransform_out5.wav");
 
  259              << 
"Output did not match gold file!" 
  262         diff.
plot(
"phase - gold");
 
  272     cout << 
TEST_HEADER << 
"Testing FFTChunk::setCartesian(), setPolar() ..." << flush;
 
  274     vec = fft.fft(input, 512, 0);
 
  276     mag = vec[0].getMagnitude();
 
  277     phase = vec[0].getPhase();
 
  282     chunk.setPolar(mag, phase);
 
  286     data = fft.ifft(vec);
 
  293              << 
"Output did not match gold file!" 
  296         diff.
plot(
"data - gold");
 
  304     chunk.setCartesian(orig.getReal(), orig.getImaginary());
 
  308     data = fft.ifft(vec);
 
  315              << 
"Output did not match gold file!" 
  318         diff.
plot(
"data - gold");
 
  328     cout << 
TEST_HEADER << 
"Testing FFTChunk::getFrequencyAxis() ..." << flush;
 
  330     data = vec[0].getFrequencyAxis();
 
  335     gold = 
Buffer(
"gold/FFTransform_out6.wav");
 
  342              << 
"Output did not match gold file!" 
  345         diff.
plot(
"data - gold");
 
  353     cout << SUCCESS << endl;
 
Results of performing an FFT are stored in this class. 
 
void plot(const std::string &title="Buffer") const 
Requires matplotlib. Creates a plot of this Buffer. 
 
Buffer getAbs() const 
Modifies a copy of the Buffer by making any negative value positive. 
 
uint32 getLength() const 
Returns the number of samples in the Buffer. 
 
#define TEST_ERROR_HEADER
 
void abs()
Modifies the Buffer by making any negative value positive. 
 
A Buffer for storing audio samples. 
 
float64 getMax() const 
Returns the maximum sample value in the Buffer. 
 
std::vector< FFTChunk > FFTChunkVector