I am trying to use libmpg123 to play sounds from mp3 files. So far so good, I can play sounds, but I trying to make finer adjustmens and make things prim and proper.
I want to default to paFloat32 (Port Audio) as the sample format. The default for libmpg123 seemed to be int16. I could get float32 working by
mpg123_format(mh, 44100, MPG123_MONO or MPG123_STEREO, MPG123_ENC_FLOAT_32);
if mhErr <> MPG123_OK then
DebugLn('Error after mpg123_format ' + IntToStr(mhErr));
However the proper way for doing this seems to be (as per
https://www.mpg123.de/api/mpg123__to__out123_8c_source.shtml ) to call
mpg123_rates, get the list of rates, and then call
mp123_format for each. However I am unable to call
mpg123_rates properly. Whatever I do, I get the number (of rates) 0.
This is what I am trying. (I have been trying all sorts of combinations frantically, so it is not really pretty.)
var
Rates: pplong;
RateCount: integer;
X, Y: Pointer;
Count: integer;
begin
mh:=nil;
mh := mpg123_new(nil, mhErr);
if mhErr <> MPG123_OK then
DebugLn('Error after mpg123_new ' + IntToStr(mhErr));
mhErr := mpg123_format_none(mh);
if mhErr <> MPG123_OK then
DebugLn('Error after mpg123_format_none ' + IntToStr(mhErr));
RateCount := 0;
X := @RateCount;
//Y := @Rates;
//Rates := nil;
mpg123_rates(Rates, X);
//DebugLn('After mpg123_rates. Rate count is ' + IntToStr(RateCount));
The C function that is being called:
void attribute_align_arg mpg123_rates(const long **list, size_t *number)
{
if(list != NULL) *list = my_rates;
if(number != NULL) *number = sizeof(my_rates)/sizeof(long);
}
Any help on how to get the call to mpg123_rates work will be really helpful.