IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
ReplayGain.dll interop issue, Always returns 64.82
Jebus
post Jun 21 2011, 21:54
Post #1





Group: Developer
Posts: 1294
Joined: 17-March 03
From: Calgary, AB
Member No.: 5541



Hi everyone!

Its been years since I've posted. Not prepared to even say what i'm working on, but I'm trying to use replaygain.dll (off Rarewares) via C# interop. Ever time I call GetTitleGain(), it returns 64.82. From a quick google search, it seems that means i've encountered an error.


Here is my p/invoke signature:

CODE
[DllImport("replaygain.dll", CallingConvention = CallingConvention.Cdecl)]
internal static extern int InitGainAnalysis(long sampleFreq);

[DllImport("replaygain.dll", CallingConvention = CallingConvention.Cdecl)]
internal static extern int AnalyzeSamples(float[] leftSamples, float[] rightRamples, UIntPtr numSamples, int numChannels);
      
[DllImport("replaygain.dll", CallingConvention = CallingConvention.Cdecl)]
internal static extern float GetTitleGain();



and then i'm basically calling:


CODE
float[] leftSamples = new float[4096];
float[] rightSamples = new float[4096];

// Code to initialize the samples, somewhere between -1 and 1.

InitGainAnalysis(sampleRate)

AnalyzeSamples(leftSamples, rightSamples, new UIntPtr((ulong)sampleCount), 2);

float replaygain = GetTitleGain(); // Always returns 64.82 after at least 1 call to AnalyzeSamples.


Anyone else tried this from C#? Am I missing anything? Alternatively, is there another ReplayGain library to suggest, preferably with multi-channel and >48khz support?

This post has been edited by Jebus: Jun 22 2011, 16:07
Go to the top of the page
+Quote Post
Jebus
post Jun 22 2011, 03:35
Post #2





Group: Developer
Posts: 1294
Joined: 17-March 03
From: Calgary, AB
Member No.: 5541



So I'm pretty sure this is just a normalization issue... if my samples are in the range of -10 through 10, I get a more sane (but still wrong) result of around 2 dB. I'm expecting roughly -7 dB.


What does ReplayGain.dll expectfor the input samples? The documentation, such as it is, simply says that the samples are in floating-point format so I assumed a range of -1:+1. The code makes little sense to me, as I am not an audio engineer (or a very good C programmer).

This post has been edited by Jebus: Jun 22 2011, 04:24
Go to the top of the page
+Quote Post
pbelkner
post Jun 22 2011, 06:44
Post #3





Group: Members
Posts: 412
Joined: 13-June 10
Member No.: 81467



QUOTE (Jebus @ Jun 21 2011, 21:54) *
Ever time I call GetTitleGain(), it returns 64.82.

Google for "site:hydrogenaudio.org wavegain 0x7fff".
Go to the top of the page
+Quote Post
Jebus
post Jun 22 2011, 15:54
Post #4





Group: Developer
Posts: 1294
Joined: 17-March 03
From: Calgary, AB
Member No.: 5541



Thanks! I will log my issue in that thread (changing float to double and long to int as suggested didn't work)
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 16th September 2014 - 22:20