HydrogenAudio

Hydrogenaudio Forum => General Audio => Topic started by: sebpiq on 2013-02-07 19:21:23

Title: need help with libreplaygain + python and numpy
Post by: sebpiq on 2013-02-07 19:21:23
Hi all !

I am trying to calculate the replay gain from Python, have tried over and over again, and failed miserably ...
I figured that would be the best place to ask, but if it isn't please redirect me

I am using the shared object "libreplaygain.so" and what happens is that whatever data I give to `gain_analyze_samples`, `gain_get_chapter` always returns 80.000 ...

Here is the script I am using for testing : http://pastebin.com/4ngNuDZP (http://pastebin.com/4ngNuDZP)
EDIT : here is a simpler version of the same snippet using scipy to read the sound file : http://pastebin.com/C7AWiGC6 (http://pastebin.com/C7AWiGC6)

I've really tried everything, and I am a bit desperate now  . I am not very good with C, and don't really understand what's going on with "ctypes", so I guess that might be a problem with value types. Hopefully the problem might be obvious to some of you?

Thanks,

Sébastien
Title: need help with libreplaygain + python and numpy
Post by: romor on 2013-02-07 20:14:54
Not to me, but you can calculate RG just with scipy.
Additionally if you want to calculate filter coefficients, you can see example of Yulewalk in scikit talkbox, AR model function (or perhaps in statsmodels also), as it's not included in scipy. But coefficients can also be downloaded precomputed, for various sample rates.

Original idea explained, with scripts (which or course slightly differs from your linked library): http://web.archive.org/web/20060713212205/...ulating_rg.html (http://web.archive.org/web/20060713212205/http://replaygain.hydrogenaudio.org/calculating_rg.html)
Title: need help with libreplaygain + python and numpy
Post by: sebpiq on 2013-02-07 20:22:32
Not to me, but you can calculate RG just with scipy.


Yeah ... I also thought about this options, but then I kind of thought using the shared library would be easier, faster, and wouldl't require scipy dependency (which I don't need for anything else...)
Title: need help with libreplaygain + python and numpy
Post by: sebpiq on 2013-02-07 20:45:28
Ok ... I've got some improvement by using :

replaygain.gain_get_chapter.restype = ctypes.c_double

before calling gain_get_chapter

Now it returns different values (previously only 80.000), but it is still different than what the command line tool gives me (64dB vs. -3dB)