MaroonMike
19th April 2006, 15:57
Hello all.
I am trying to use the r8brain DLL (r8b.dll) in a Visual Basic 6 application to do resampling conversions. I have tried calling the function within this DLL like I call other Windows API functions, but all I keep getting an a GPF in VB.
The r8b.dll is apparently written in Pascal, which shouldn't be a problem to reference.
Here is my VB code reference:
Private Declare Sub r8b_execute Lib "r8b.dll" (ByVal InFilename As String, ByVal OutFileName As String, ByVal OutRate As Double, ByVal OutBitDepth As Long, ByVal OutQuality As Long, ByVal Preallocate As Long, CancelFlag As Long, Callback As Variant, Pointer As Double, err As Variant)
Here is the documentation for r8b.dll and the function I am trying to call:
procedure r8b_execute (InFileName, OutFileName: PChar;
OutRate, OutBitDepth, OutQuality, Preallocate: LongInt;
var CancelFlag: LongInt; Callback: TR8BCallback; p: Pointer;
var err: TR8BError); cdecl; external 'r8b.dll';
This procedure performs sample rate conversion. WAV file InFileName will be
converted to WAV file with the name OutFileName.
OutRate - sample rate of output file. Please, don't use extreme values for
output sample rate. Normal "designed" input to output sample rate ratio lies
between 0.2 to 5. Also it is not a very good idea to specify the output sample
rate value equal to the input sample rate value (e.g., for performing bit
depth conversion only) since internally conversion will take place in any
way, thus slightly cutting higher frequencies of the original file.
OutBitDepth specifies bit depth of the output file. Allowed values are
8, 16, 24, 32 and 64. Please note that values 32 and 64 mean output file will
be written in IEEE floating sample format.
OutQuality value must be specified in the range from 0 to 4 inclusive,
where 0 is the lowest quality and the highest execution speed, and 4 is the
highest quality and the lowest execution speed.
If Preallocate parameter is non-zero, WAV file will be expanded to the
necessary size before performing conversion. Preallocation allows to minimize
output file fragmentation thus increasing speed of subsequent accesses.
CancelFlag variable can be adjusted to a non-zero value during callback to
signal r8b_execute to stop processing. r8b_execute automatically zeroes it
before processing starts. Even if conversion was stopped output WAV file will
be correctly closed and will contain data up to the point where the process
was stopped. Actually, WAV file will be larger if Preallocate variable was set
to a non-zero value.
Callback is an address of the callback procedure, defined as:
type
TR8BCallback = procedure (Position, Max: LongInt; p: Pointer); cdecl;
That is, if Callback <> nil, r8b_execute periodically calls this procedure
signalling the progress of the conversion. Position is the current state of
the process and Max is its maximal value. Position is always lesser or equal
to Max. Progress in percent is calculated this way:
progress = Position / Max * 100.0. p is an additional custom pointer you have
provided when calling r8b_execute.
I have the r8b.dll in the source path as well as the C:\windows\system32 folder.
ANY ideas or assistance is greatly appreciated!
Mike
I am trying to use the r8brain DLL (r8b.dll) in a Visual Basic 6 application to do resampling conversions. I have tried calling the function within this DLL like I call other Windows API functions, but all I keep getting an a GPF in VB.
The r8b.dll is apparently written in Pascal, which shouldn't be a problem to reference.
Here is my VB code reference:
Private Declare Sub r8b_execute Lib "r8b.dll" (ByVal InFilename As String, ByVal OutFileName As String, ByVal OutRate As Double, ByVal OutBitDepth As Long, ByVal OutQuality As Long, ByVal Preallocate As Long, CancelFlag As Long, Callback As Variant, Pointer As Double, err As Variant)
Here is the documentation for r8b.dll and the function I am trying to call:
procedure r8b_execute (InFileName, OutFileName: PChar;
OutRate, OutBitDepth, OutQuality, Preallocate: LongInt;
var CancelFlag: LongInt; Callback: TR8BCallback; p: Pointer;
var err: TR8BError); cdecl; external 'r8b.dll';
This procedure performs sample rate conversion. WAV file InFileName will be
converted to WAV file with the name OutFileName.
OutRate - sample rate of output file. Please, don't use extreme values for
output sample rate. Normal "designed" input to output sample rate ratio lies
between 0.2 to 5. Also it is not a very good idea to specify the output sample
rate value equal to the input sample rate value (e.g., for performing bit
depth conversion only) since internally conversion will take place in any
way, thus slightly cutting higher frequencies of the original file.
OutBitDepth specifies bit depth of the output file. Allowed values are
8, 16, 24, 32 and 64. Please note that values 32 and 64 mean output file will
be written in IEEE floating sample format.
OutQuality value must be specified in the range from 0 to 4 inclusive,
where 0 is the lowest quality and the highest execution speed, and 4 is the
highest quality and the lowest execution speed.
If Preallocate parameter is non-zero, WAV file will be expanded to the
necessary size before performing conversion. Preallocation allows to minimize
output file fragmentation thus increasing speed of subsequent accesses.
CancelFlag variable can be adjusted to a non-zero value during callback to
signal r8b_execute to stop processing. r8b_execute automatically zeroes it
before processing starts. Even if conversion was stopped output WAV file will
be correctly closed and will contain data up to the point where the process
was stopped. Actually, WAV file will be larger if Preallocate variable was set
to a non-zero value.
Callback is an address of the callback procedure, defined as:
type
TR8BCallback = procedure (Position, Max: LongInt; p: Pointer); cdecl;
That is, if Callback <> nil, r8b_execute periodically calls this procedure
signalling the progress of the conversion. Position is the current state of
the process and Max is its maximal value. Position is always lesser or equal
to Max. Progress in percent is calculated this way:
progress = Position / Max * 100.0. p is an additional custom pointer you have
provided when calling r8b_execute.
I have the r8b.dll in the source path as well as the C:\windows\system32 folder.
ANY ideas or assistance is greatly appreciated!
Mike