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

28 comments:

Vasundhara said...

Is MinGW C++ compiler needed for VS2010 installation aswell? I'm trying to work with Aquila and am facing trouble using it with VS2010.

Nipuna Shanthidewa said...

I don't think so. VS has inbuilt compiler for C++.In my case I use MinGw for create library files of Aquila.Can you specify exact trouble that you faced then may be I can help you to overcome it

chathumini hapugoda said...

It works well. Thank you.

Unknown said...

when i configure the the files using cmake gui it gives error "libgmp-10.dll file missing"

Nipuna Shanthidewa said...

Hi Huzaifa,
Sorry for late response .Did you add MinGW path to system variable? (step2)

Unknown said...

Thanks for your concern
this problem has been resolved but when i run the code following errors occurred.


Error2:error LNK2038: mismatch detected for '_MSC_VER': value '1700' doesn't match value '1800' in ConsoleApplication3.obj ..\Aquila.lib(SignalSource.obj)

Error :error LNK1319: 6 mismatches detected

please tell me how to resolve these error

Nipuna Shanthidewa said...

What is the version of your Visual studio?
And also make sur you are running x64 project

Unknown said...

yep I have changed the Platform to x64.. working on VS 2013

Unknown said...

problem has been resolved by changing the platform toolset to Visual Studio 2012 (v110)

Unknown said...

Hi Nipuna Shanthidewa ..
i have followed the steps as you have mentioned in your blog properly(even step 2).. but sir when i try to configure the the files using cmake gui it gives error "libgmp-10.dll file missing".. even then i let the flow going.. i.e; i configure it and then generate.. on step 11 i write command on GitBash command window but error coming "mingw32-make: command not found" ...

Nipuna Shanthidewa said...

Hi @asiyah,
Sorry for late response.I think still problem is System path .Can you please check you add it correctly to SYSTEM PATH not path .And please restart you computer.

Unknown said...

em trying to calculate mfcc and dtw using aquila. but when i execute the following code

void main()
{

int frame_size =256;

Aquila::WaveFile waveIn0("a_converted.wav");
Aquila::FramesCollection frameCollection0(waveIn0, frame_size);
vector> dtwdt0;
Aquila::Mfcc mfcc0(frame_size);


for (int i=0; i mfccValues = mfcc0.calculate(frame);
dtwdt0.push_back(mfccValues);

}

this exception occurred.


vector subscript out of range
File: c:\program files\microsoft visual studio 8\vc\include\vector
Line: 1124
what could be the issue? please help

Nipuna Shanthidewa said...

Sorry guys currently i'm not touching in this audio processing implementation.I'll try my best to help you

Unknown said...

6.Choose C:\Aquila-src\ as source..
i can't find "as source"
When running cmake to configure, it floats called "error in configuration process, project file may be invalid"

Nipuna Shanthidewa said...

Hi 우준김,

In this tutorial in step 5 i have add image of cmake interface
http://nip-saga.blogspot.com/2015/01/Configure-eclipse-with-open-CV.html

In that you can see "Where is the source code" field

Thank you

Unknown said...

Hi, i receive an error when building the sample file.
- LINK : fatal error LNK1104: cannot open file 'Aquila.lib'
I did add "Aquila.lib" and "Ooura_fft.lib" in Input->Additional Dependencies

Could you help me with this error?
And also the link for downloading the two needed files to add them in the installed directory are no more available.
THanks a lot

Unknown said...

Hi, again. At the step including "Aquila.lib" and "Ooura_lib.lib", I do not have these ".lib" files. I only have "libAquila.a" and "libOoura_fft.a". How can I get the ".lib" files as in your instructions?

I tried to include "libAquila.a" instead of "Aquila.lib". The error "LINK : fatal error LNK1104: cannot open file 'Aquila.lib'" is no longer showed, however the error "LNK2019 unresolved external symbols" occured. (I did switch the project into x64 compiler).

Any tips please. Thanks

Nipuna Shanthidewa said...

Hi my dear friends ,
Sorry for late response You can download these libs from this repository https://github.com/Nipuna-saga/Aquila-Libs

Thanks

Neha said...

Hi Nipuna, can you tell which two additional files to paste in lib folder? your link is redirecting to your git repo and not just files.

Nipuna Shanthidewa said...

Hey Neha,
please note this location https://github.com/Nipuna-saga/Aquila-Libs/tree/master/Aquila/lib/x86/Debug
This is for 32 bit Debug version projects
Choose your files like this according to your requirement
Thanks

Unknown said...
This comment has been removed by the author.
Unknown said...

Thank you, Nipuna :)

Shreyasi said...

I have followed all the steps and included the 2 .lib files as well. Then I tried to run the code in Visual Studio 12 and got this linking error:
"Error 1 error LNK1181: cannot open input file 'Aquila.lib'"
Please help me resolve it.

Nipuna Shanthidewa said...

Hi Shreyasi,
I think this may help https://support.microsoft.com/en-us/kb/815645

Handsome said...

In my case , i was facing problem with downloaded .lib files.

i tried all the permutation , it didn't worked .


Finally

Open cmake-gui ---> configure ->>>> select which visual studio --->ok

select source === aquila-src
select build-binary === aquila-lib (creat manually if configure)

then visual studio will build all the files inside the source and put to aquila-lib


now from the aquila-lib find out the two .lib files and put into lib folder

Unknown said...

please help

CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage

Unknown said...

Install configuration...
CMake Error at cmake_install.cmake:31 :
file cannot create directory: C:/Program Files/Aquila.lib. Maybe need
administrative privileges.

Makefile:104: recipe for target 'install' failed
ming32-make: ***[install] Error 1


PLEASE HELP!!!

Windows 7

Unknown said...

Hi, can you please clarify what this means? "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)"