Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: need help with libreplaygain + python and numpy (Read 1983 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

need help with libreplaygain + python and numpy

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
EDIT : here is a simpler version of the same snippet using scipy to read the sound file : 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

need help with libreplaygain + python and numpy

Reply #1
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

need help with libreplaygain + python and numpy

Reply #2
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...)

 

need help with libreplaygain + python and numpy

Reply #3
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)