Friday, June 19, 2015

Digital Audio processing with c++ ( Chapter 1 ) - Configure Aquila Digital signal processing Library in Visual Studio

Aquila is  Digital signal processing Library that work with C++.And it has lots of features to analyze and process signals like audio.You can learn more about this library from official  website.

Today I'm going to show how to configure it visual studio programming environment.

Working environment

Windows 8.1
Visual studio 11

Development Tools



  • cmake     Download   (make sure to download binary distributions)


Library Configuration

  1. Install MinGW C++ compiler. During installation , select “C++ Compiler” and “MSYS Basic System” for installation
  2. Add system PATH to "c:/mingw/bin" (Right click on my computer-> Properties->Advance system settings->Environment variable -> select path and click edit) example
  3. Install Cmake
  4. unzip Aquila to C:\Aquila-src
  5. Run cmake GUI tool
  6. Choose C:\Aquila-src\ as source
  7. Choose the destination, C:\Aquila-build ,This is where to build the binaries
  8. Press Configure button, choose MinGW Makefiles as the generator.(then in red highlighted area We can choose many options but it's better to use default options if you are beginner)
  9. Press the Configure button again then press the Generate button
  10. Exit the cmake program when the generating is done
  11. Run the command line mode (cmd.exe) and go to the destination directory Aquila-build (type :- cd /Aquila-build)
  12. Type "mingw32-make". You can see a progress of building binaries. If the command is not found error occur problem is in system path (step 2)
  13. Then type "mingw32-make install" (you can see install path .we need it in next step)
In addition to this we need to do small one thing .That is we need to add these 2 files to your install directly (default directly C:\Program Files (x86)\Aquila\lib) 

**I try this few days and this is not work for me .then I found this 2 files need to place in that directly for work this library

Create Project 


  1. Open Visual Studio IDE
  2. Create new Console Application
  3. Go to project properties (Project-> Properties)
  4. Go to C/C++ -> General then add path of  "include" to Additional Include Directories  (example :- C:\Program Files (x86)\Aquila\include)
  5. Go to linker-> General then add path of  "lib" to Additional Library Directories  (example:- C:\Program Files (x86)\Aquila\lib)
  6. Go to linker-> input then add library files to Additional Dependencies (Add Aquila.lib ,Ooura_fft.lib )

Implementation


Then run this code

#include "aquila/global.h"
#include "aquila/source/generator/SineGenerator.h"
#include "aquila/transform/FftFactory.h"
#include "aquila/tools/TextPlot.h"

int main()
{
    // input signal parameters
    const std::size_t SIZE = 64;
    const Aquila::FrequencyType sampleFreq = 2000;
    const Aquila::FrequencyType f1 = 125, f2 = 700;

    Aquila::SineGenerator sineGenerator1 = Aquila::SineGenerator(sampleFreq);
    sineGenerator1.setAmplitude(32).setFrequency(f1).generate(SIZE);
    Aquila::SineGenerator sineGenerator2 = Aquila::SineGenerator(sampleFreq);
    sineGenerator2.setAmplitude(8).setFrequency(f2).setPhase(0.75).generate(SIZE);
    auto sum = sineGenerator1 + sineGenerator2;

    Aquila::TextPlot plt("Input signal");
    plt.plot(sum);

    // calculate the FFT
    auto fft = Aquila::FftFactory::getFft(SIZE);
    Aquila::SpectrumType spectrum = fft->fft(sum.toArray());

    plt.setTitle("Spectrum");
    plt.plotSpectrum(spectrum);

    return 0;
}


and you will get an output if you get error about "LNK2019 error c++ unresolved external symbol"
Go to BUILD->Configuration Manager and change platform to 64 bit

If  have any question please post a comment .This post written by using my experience.so sometimes there can be simple approach than this.Please be kind enough to mention that one also Thank you :)

***Update If you have a trouble with building an own library you can try my pre-build library . I have only tested 64bit lib files but I already added 32bit versions.Try and please kind enough to mentioned is this library works fine or not

Reference official website