Using libsndfile lib / analyze sound files

Dear all,

Maybe anyone could give me some help on how would I make use of functionality of external library like libsndfile (http://www.mega-nerd.com/libsndfile/) to analyze waveforms?
As far as I’m aware of, ROOT does not have such functionality intrinsically.
I had successfully installed (re-complied ROOT) with FFTW, and have libsndfile library installed (/usr/local/include and /usr/local/lib), and few libsndfile examples compiled and working i.e. I can extract and print / save wave data. I would want to do it within my root macro so to put it into a vector / histo / array any ROOT vehicle that would help me analyze it, save as part of ROOT-toople for later, etc. (there is also graphical and other data I’m trying to bring together and correlate… this is why using ROOT).

Is there a way to use this functionality in CINT interpreted macros first (they’re great for troubleshooting and to understand what I want with data first… :slight_smile:)

Much gratitude for your continuing support, and regards!

Hi,

I think that the ingredient you are looking for are dictionaries.
root.cern.ch/drupal/content/int … s-rootcint
With dictionaries, which you can create with genreflex or rootcint, you can utilise 3rd party classes within macros.
A way in which you could avoid them and start immediately to interactively use your classes is ROOT6. TO interactively use whatever library with ROOT6, it is enough to include the header file(s) containing the interfaces of the classes you are interested in and to load the library(ies) containing their implementations.
Supposing to have a scenario like: “myCoolHeader.h” and “libMyCoolLib.so”, the steps to be taken would be

root [0] #include "myCoolHeader.h"
root [1] gSystem->Load("libMyCoolLib.so")

Cheers,
Danilo

Dear Danilo,
Thank you very much for your answer! I am going to try, and once successful, I’d post some snippet that works so all of us could use little wave analysis example! :slight_smile:
Will report later on, and then will mark solved.
Again, Sincere regards – Eugene.

Try also: root [0] gSystem->Load("libMyCoolLib") root [1] .L myCoolHeader.h++

Ok… not much luck, and I cannot understand why.
This goes okay

root [0] gSystem->Load("/usr/local/lib/libsndfile.so") (int)0
but then when I try to show it the header file,

root [1] .L /usr/local/include/sndfile.h++ Info in <TUnixSystem::ACLiC>: creating shared library /usr/local/include/sndfile_h.so Warning: link requested for unknown srcfile /usr/local/include/sndfile.hh /usr/local/include/sndfile_h_ACLiC_linkdef.h:9: /usr/local/include/sndfile_h_ACLiC_dict.cxx:122: error: ISO C++ forbids declaration of ‘loops’ with no type /usr/local/include/sndfile_h_ACLiC_dict.cxx:399: error: ISO C++ forbids declaration of ‘parameter’ with no type /usr/local/include/sndfile_h_ACLiC_dict.cxx: In function ‘ROOT::TGenericClassInfo* ROOT::GenerateInitInstanceLocal(const int SF_INSTRUMENT::*)’: /usr/local/include/sndfile_h_ACLiC_dict.cxx:402: error: expected unqualified-id before ‘)’ t ..... and so on

It seems that the interpreter does not see the rest of the package to make sense, i.e. it tries to look for files referenced such as /usr/local/include/sndfile.hh and does not find it?

What I am trying to do, is that I have a working example of the libsndfile library (sndfile-to-text.c) that converts wave file to text. All I need is to dump that into a histo instead, and run FFT on it. FFT portion I have worked out fine… it’s the getting the data from wave files that is limping. To compile example,

gcc -I $HOME/local/include -L /usr/local/lib -lsndfile sndfile-to-text.c -o snd2txt

sndfile-to-text.zip (1.81 KB)

Hi,

I think that the best way to achieve this is to take advantage of ROOT6. Could you give it a try?

Cheers,
Danilo

What exactly the advantage would be? I could give it a try if the gains vs hassles would seem tangible :slight_smile:

The main advantage is that you will not have to generate dictionaries nor use aclic. You just need to include the relevant header and load the library to interactively call the methods, use the classes and other C++ entities it implements.