Created
January 20, 2014 08:01
-
-
Save sqbing/8516543 to your computer and use it in GitHub Desktop.
Segment fault with Aquila::OouraFft::ifft()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <aquila/global.h> | |
| #include <aquila/source/WaveFile.h> | |
| #include <aquila/tools/TextPlot.h> | |
| #include <aquila/transform/FftFactory.h> | |
| #include <algorithm> | |
| #include <cstdlib> | |
| int main(int argc, const char *argv[]) | |
| { | |
| if(argc < 2) { | |
| std::cout<<"Filename not found."<<std::endl; | |
| return -1; | |
| } | |
| Aquila::WaveFile wav(argv[1]); | |
| std::cout<<"Loaded file "<<wav.getFilename() | |
| <<" ("<<wav.getBitsPerSample()<<"b)"<<std::endl | |
| <<" samples: "<<wav.getSamplesCount()<<std::endl | |
| <<" sample frequency: "<<wav.getSampleFrequency()<<std::endl; | |
| std::size_t SIZE = 44100; // It's ok when size is 64. | |
| Aquila::TextPlot plt("Signal waveform before filteration"); | |
| plt.plot(wav.toArray(), SIZE); | |
| auto fft = Aquila::FftFactory::getFft(SIZE); | |
| Aquila::SpectrumType spectrum = fft->fft(wav.toArray()); | |
| plt.setTitle("Signal spectrum before filteration"); | |
| plt.plotSpectrum(spectrum); | |
| double x1[SIZE]; | |
| fft->ifft(spectrum, x1); | |
| plt.setTitle("Signal waveform after filteration"); | |
| plt.plot(x1, SIZE); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment