r8b.dll include file
Posted: Mon Jan 14, 2008 2:13 pm
Here is an include file for the r8b.dll used for resampling uncompressed WAV files. A big thank you to eriansa for suggesting this library.
The include file (r8b.pbi):
And a quick example program:
Kind regards,
Francis.
The include file (r8b.pbi):
Code: Select all
;/ ***************************************************************************
;/ **** ****
;/ **** PureBasic include file for Aleksey Vaneev's r8b.dll library ****
;/ **** (r8b.dll available from http://www.voxengo.com/product/r8brain) ****
;/ **** ****
;/ **** Programmed by Francis G. Loch, 8th January 2008 ****
;/ **** e-mail: francis@dfstudios.co.uk ****
;/ **** ****
;/ ***************************************************************************
;- Constants
Enumeration ; r8b quality constants
#TR8B_QUALITY_VERYLOW
#TR8B_QUALITY_LOW ; Please note that these constants are not part of
#TR8B_QUALITY_MEDIUM ; the r8b.dll API, but have been added to aid code
#TR8B_QUALITY_HIGH ; readability
#TR8B_QUALITY_VERYHIGH
EndEnumeration
;- Structures
Structure TR8BInputFormat
Buffer.l
Rate.l
BitDepth.l
Channels.l
IEEE.l
Len.l
EndStructure
Structure TR8BError
WasError.b
ErrMsg.c[128]
EndStructure
;- Procedures
Global r8bLib.l
Procedure.l Init_r8b()
r8bLib = OpenLibrary(#PB_Any, "r8b.dll")
ProcedureReturn IsLibrary(r8bLib)
EndProcedure
Procedure.l r8b_getWAVInfo(*fname.s, *SR.l, *Depth.l, *err.TR8BError)
ProcedureReturn CallCFunction(r8bLib, "r8b_getWAVInfo", *fname, *SR, *Depth, *err)
EndProcedure
Procedure.l r8b_execute(*InFileName.s, *OutFilename.s, OutRate.l, OutBitDepth.l, OutQuality.l, Preallocate.l, *CancelFlag.l, *TR8BCallback, *p.l, *err.TR8BError)
ProcedureReturn CallCFunction(r8bLib, "r8b_execute", *InFileName, *OutFilename, OutRate, OutBitDepth, OutQuality, Preallocate, *CancelFlag, *TR8BCallback, *p, *err)
EndProcedure
Procedure.l r8b_executeMem(*InFormat.TR8BInputFormat, *OutBuffer.l, OutLength.l, OutRate.l, OutBitDepth.l, OutQuality.l, *CancelFlag.l, *TR8BCallback, *p.l, *err.TR8BError, *ActualOut.l)
ProcedureReturn CallCFunction(r8bLib, "r8b_executeMem", *InFormat, *OutBuffer, OutLength, OutRate, OutBitDepth, OutQuality, *CancelFlag, *TR8BCallback, *p, *err, *ActualOut)
EndProcedure
Procedure.l r8b_execute2(*InFileName, *OutFilename, OutRate.l, OutBitDepth.l, OutQuality.l, Preallocate.l, OutRateReal.d, *CancelFlag.l, *TR8BCallback, *p.l, *err.TR8BError)
ProcedureReturn CallCFunction(r8bLib, "r8b_execute", *InFileName, *OutFilename, OutRate, OutBitDepth, OutQuality, Preallocate, OutRateReal, *CancelFlag, *TR8BCallback, *p, *err)
EndProcedure
Procedure.l r8b_executeMem2(*InFormat.TR8BInputFormat, *OutBuffer.l, OutLength.l, OutRate.d, OutBitDepth.l, OutQuality.l, *CancelFlag.l, *TR8BCallback, *p.l, *err.TR8BError, *ActualOut.l)
ProcedureReturn CallCFunction(r8bLib, "r8b_executeMem", *InFormat, *OutBuffer, OutLength, OutRate, OutBitDepth, OutQuality, *CancelFlag, *TR8BCallback, *p, *err, *ActualOut)
EndProcedure
Code: Select all
EnableExplicit
IncludeFile "r8b.pbi"
Init_r8b() ; Initialise the r8b library
Define filename$
Define SR.l, Depth.l
Define r8bErr.TR8BError
filename$ = OpenFileRequester("Open WAV file", "", "*.WAV|*.WAV", 0)
r8b_getWAVInfo(@filename$, @SR, @Depth, r8bErr)
If r8bErr\WasError = 0 ; Did an error occur?
; No, display sample details
Debug "Sample rate: " + Str(SR)
Debug "Depth: " + Str(Depth)
Else
; Yes, display the error
Debug PeekS(@r8bErr\ErrMsg)
EndIf
Francis.