libmpg123 and libout123 version 1.23.0

External libraries (GTK, GSL, SDL, Allegro, OpenGL, etc) questions.
D.J.Peters
Posts: 7717
Joined: May 28, 2005 3:28

libmpg123 and libout123 version 1.23.0

Postby D.J.Peters » Feb 06, 2016 19:48

libmpg123 and libout123 version 1.23.0 32/64-bit (static and dynamic)

download: fbmpg123.zip

homepage: http://www.mpg123.org

Joshy

file decodemp3.bas

Code: Select all

#define MPG123_STATIC
#include once "mpg123_1.23.0.bi"

sub _init constructor
  mpg123_init()
end sub

sub _exit destructor
  mpg123_exit()
end sub

'
' main
'
ChDir ExePath()
var hDecoder = mpg123_new(NULL,NULL)
if hDecoder then
  if mpg123_open(hDecoder,"legends.mp3") = MPG123_OK then
    dim as long rate,channels,encod
    if mpg123_getformat(hDecoder, @rate, @channels, @encod) = MPG123_OK then
      mpg123_format_none(hDecoder)
      mpg123_format(hDecoder, rate, channels, encod)
      var BufferSize = mpg123_outblock(hDecoder)
      var Buffer = allocate(BufferSize)
      dim as long errCode,done
      print "decode 'legends.mp3' ..."
      dim as double tStart=timer()
      do
        errCode = mpg123_read(hDecoder, Buffer, BufferSize, @done)
      loop while ( (done>0) andalso (errCode=MPG123_OK))
      dim as double tNow=timer()
      print "done ..." & tNow-tStart
      sleep
      deallocate buffer
    else
      print "out123_getformat() failed !"
      beep : sleep
    end if
    mpg123_close(hDecoder)
  else
    print "mpg123_open() failed !"
    beep : sleep
  end if
  mpg123_delete(hDecoder)
  hDecoder=NULL
else
  print "mpg123_new() failed !"
  beep : sleep
end if
file: playmp3.bas

Code: Select all

#define MPG123_STATIC
#include once "mpg123_1.23.0.bi"

#define OUT123_STATIC
#include once "out123_1.23.0.bi"

sub _init constructor
  mpg123_init()
end sub

sub _exit destructor
  mpg123_exit()
end sub

'
' main
'
ChDir ExePath()
var hDecoder = mpg123_new(NULL,NULL)
if hDecoder then
  mpg123_reset_eq(hDecoder)
  if mpg123_open(hDecoder,"legends.mp3") = MPG123_OK then
    var hOut = out123_new()
    if (hOut<>NULL) then
      if out123_open(hOut,NULL,NULL)=0 then
         dim as long rate,channels,encod
         if mpg123_getformat(hDecoder, @rate, @channels, @encod) = MPG123_OK then
           dim as zstring ptr driver = NULL
           if out123_driver_info(hOut, @driver,NULL) = OUT123_OK then
             print "using driver: " & *driver
             mpg123_format_none(hDecoder)
             mpg123_format(hDecoder, rate, channels, encod)
             if out123_start(hOut, rate, channels, encod) = OUT123_OK  then
               dim as long framesize
               if out123_getformat(hOut, NULL, NULL, NULL, @framesize) = OUT123_OK  then
                 var BufferSize = mpg123_outblock(hDecoder)
                 var Buffer = allocate(BufferSize)
                 dim as long errCode,done
                 dim as off_t samples
                 print "playing: press [ctrl] & [c] ..."
                 do
                   errCode = mpg123_read(hDecoder, Buffer, BufferSize, @done)
                   dim as size_t played = out123_play(hOut, Buffer, done)
                   samples += played/framesize
                   if (played <> done) then
                     print "warning: played: " & played & "  decoded: " & done
                   end if
                 loop while ( (done>0) andalso (errCode=MPG123_OK))
                 deallocate buffer
               else
                 print "out123_getformat() failed !"
               end if
               out123_stop(hOut)
             else
               print "out123_start() failed !"
             end if
           else
             print "out123_driver_info() failed !"
           end if
         else
           print "mpg123_getformat_open() failed !"
         end if
         print "out123_close()"
         out123_close(hOut)
      else
        print "out123_open() failed !"
      end if
      print "out123_del()"
      out123_del hOut
      hOut=NULL
    else
      print "out123_new() failed !"
      beep : sleep : end 1
    end if
    print "mpg123_close()"
    mpg123_close(hDecoder)
  else
    print "mpg123_open() failed !"
    beep : sleep : end 1
  end if
  print "mpg123_delete()"
  mpg123_delete(hDecoder)
  hDecoder=NULL
else
  print "mpg123_new() failed !"
  beep : sleep : end 1
end if
Last edited by D.J.Peters on Oct 03, 2017 3:48, edited 1 time in total.
D.J.Peters
Posts: 7717
Joined: May 28, 2005 3:28

Re: libmpg123 and libout123 version 1.23.0

Postby D.J.Peters » Feb 07, 2016 17:02

I used last 15 years Slackware Linux without any problems.

I installed ubuntu desktop 15.10 on two boxes (32 and 64-bit) now and need help from you GURU :-)

If I install "sudo apt-get libmpg123-dev" then libout123 are missing

so I removed the lib via "sudo aptg-get remove libmpg123-dev"

I downloaded and extracted mpg123 from http://sourceforge.net/projects/mpg123/ ... 23/1.23.0/

./configure
tells me I need ltdl

sudo apt-get install libltdl-dev OK

./configure
make
sudo make install

all looks good so far
ubuntu wrote:joshy@P4:~/fbmpg123$ ls /usr/local/lib/
freebasic
libmpg123.so
libmpg123.so.0.42.0
libout123.so
libout123.so.0.1.0
libmpg123.la
libmpg123.so.0
libout123.la
libout123.so.0
fbc playmp3.bas

FreeBASIC compiles fine that means libmpg123 and libout123 are linked.

but if I run ./playmp3 I get
./playmp3: error while loading shared libraries: libmpg123.so.0: cannot open shared object file: No such file or directory

How can I fix it ?

Thank you.

Joshy
St_W
Posts: 1467
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: libmpg123 and libout123 version 1.23.0

Postby St_W » Feb 07, 2016 18:27

Unfortunately I cannot provide a solution directly, but maybe some ideas for finding the issue causing the error:

- I guess some of the listed files are symlinks. Check if they are valid (point to valid locations).
- verify that the library is in the loader path; e.g. try if you can solve the problem by manually putting the library in some folder and setting LD_LIBRARY_PATH accordingly
- there may be some 32-bit/64-bit issue (library path; library for different architecture; ...)
- maybe some version conflict
- maybe some access permission problem
caseih
Posts: 1355
Joined: Feb 26, 2007 5:32

Re: libmpg123 and libout123 version 1.23.0

Postby caseih » Feb 07, 2016 20:07

What does the "ldd" command say about your compiled binary? That should list all the libraries and where the linker is going to look to find them.

Return to “Libraries”

Who is online

Users browsing this forum: No registered users and 1 guest