Recent

Author Topic: Last release of libsndfile has mp3 decoder now!  (Read 4456 times)

Fred vS

  • Hero Member
  • *****
  • Posts: 3736
    • StrumPract is the musicians best friend
Last release of libsndfile has mp3 decoder now!
« on: March 27, 2022, 03:18:25 pm »
Hello.

With last release of libsndfile, you may decode mp3 too.

https://github.com/libsndfile/libsndfile/releases/tag/1.1.0

If you are using uos, with last release of libsndfile you may decode mp3, ogg, wav, flac, m4a, aiff, voc, caf, sd2, opus audio files.
« Last Edit: March 27, 2022, 03:23:55 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

domasz

  • Hero Member
  • *****
  • Posts: 615
Re: Last release of libsndfile has mp3 decoder now!
« Reply #1 on: March 29, 2022, 06:58:31 pm »
It is in C++ so for Lazarus we need a DLL. Not great considering Lazarus is multi platform and the 3 popular platforms (Windows, MacOS, Linux) require at least 6 different compiled binaries (Win32, Win64, Linux64, Linux64 for Arm, MacOS 64 Intel, MacOS M1).

Fred vS

  • Hero Member
  • *****
  • Posts: 3736
    • StrumPract is the musicians best friend
Re: Last release of libsndfile has mp3 decoder now!
« Reply #2 on: March 29, 2022, 08:12:57 pm »
It is in C++ so for Lazarus we need a DLL. Not great considering Lazarus is multi platform and the 3 popular platforms (Windows, MacOS, Linux) require at least 6 different compiled binaries (Win32, Win64, Linux64, Linux64 for Arm, MacOS 64 Intel, MacOS M1).

Huh, there is also FreeBSD OS and arrch64 CPU.
Yes, indeed, each platform and each cpu needs his compiled binary.
And there are good news, nearly all Linux/Free BSD distro have libsndfile installed by default.
( in uos package all those binaries are included and can dynamically be loaded ).

But I agree with you, Pascal open source with LGPL license (or equivalent) to decode (perfectly) mp3, opus, flac, wav, ogg, m4a or cda is a big wish of each Pascal programmer.
There are here and there some projects, sadly I never found something stable that could help me.
And there is also the problem of license.

On the other hand we have C libraries working perfectly that can be used by fpc, like libsndfile, libmpg123, portaudio, with LGPL license.

All that said, if you find something stable in Pascal to decode mp3, opus, flac, wav, ogg, m4, I am very interested by this code...

Fre;D

« Last Edit: March 30, 2022, 02:10:32 am by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Last release of libsndfile has mp3 decoder now!
« Reply #3 on: March 29, 2022, 08:49:40 pm »

All that said, if you find something stable in Pascal to decode mp3, opus, flac, wav, ogg, m4, I am very interested by this code...

Fre;D

Hi Fre;D!

This is OS independent:

https://github.com/dpethes/mp3dp

Not tested

Winni

Fred vS

  • Hero Member
  • *****
  • Posts: 3736
    • StrumPract is the musicians best friend
Re: Last release of libsndfile has mp3 decoder now!
« Reply #4 on: March 30, 2022, 12:17:03 am »

All that said, if you find something stable in Pascal to decode mp3, opus, flac, wav, ogg, m4, I am very interested by this code...

Fre;D

Hi Fre;D!

This is OS independent:

https://github.com/dpethes/mp3dp

Not tested

Winni

Hello Winni.

Thanks but https://forum.lazarus.freepascal.org/index.php/topic,58893.msg438941.html#msg438941

Fre;D
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

domasz

  • Hero Member
  • *****
  • Posts: 615
Re: Last release of libsndfile has mp3 decoder now!
« Reply #5 on: March 30, 2022, 04:06:36 pm »

All that said, if you find something stable in Pascal to decode mp3, opus, flac, wav, ogg, m4, I am very interested by this code...

Fre;D

Wave is pretty easy, I saw something for Opus and for MPEG I am trying to port something from C++ here:
https://forum.lazarus.freepascal.org/index.php/topic,58893.msg438965.html#msg438965

I also tried to find a way how to use a public domain Pascal mp3 decoder here:
https://forum.lazarus.freepascal.org/index.php/topic,58542.msg436124.html#msg436124

Fred vS

  • Hero Member
  • *****
  • Posts: 3736
    • StrumPract is the musicians best friend
Re: Last release of libsndfile has mp3 decoder now!
« Reply #6 on: March 30, 2022, 05:38:03 pm »

All that said, if you find something stable in Pascal to decode mp3, opus, flac, wav, ogg, m4, I am very interested by this code...

Fre;D

Wave is pretty easy, I saw something for Opus and for MPEG I am trying to port something from C++ here:
https://forum.lazarus.freepascal.org/index.php/topic,58893.msg438965.html#msg438965

I also tried to find a way how to use a public domain Pascal mp3 decoder here:
https://forum.lazarus.freepascal.org/index.php/topic,58542.msg436124.html#msg436124

Hello Domasz.

I follow the project mpg123 ( https://www.mpg123.de/ ) for more than 20 years now.
It has tons of commits and took lot of energy before to become stable and usable.

It is the reason why I am a few skeptical about the result of a old project with only few commits.
But I agree it is not a valid argument.

The "ténor" open-source sound applications like "Audacity" use also libraries (libsndfile, libmpg123, portaudio) and "Audacity"  is written in C, like the libraries (but dont include the code of the libraries).

After this you will need code to "render" the decoded audio file via the sound card.
It is also difficult to find something stable for each platform (something like portaudio but written in Pascal).

But, yes, like said before, a complete independent Pascal open-source project for audio, without dependencies (I have lot of doubt if it will be possible) is a Graal ( but maybe too utopia ).

Fre;D
« Last Edit: March 30, 2022, 05:40:19 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Fred vS

  • Hero Member
  • *****
  • Posts: 3736
    • StrumPract is the musicians best friend
Re: Last release of libsndfile has mp3 decoder now!
« Reply #7 on: March 30, 2022, 06:17:56 pm »
I saw something for Opus

Hum, without any dependencies (even without libopus.so ), I am curious.
The same for flac, ogg, all-wav-type  (16 and 32 resolution)...

I fear that we are living in a world where "total independence" is not reasonable (even in the Pascal world).

Fre;D
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

domasz

  • Hero Member
  • *****
  • Posts: 615
Re: Last release of libsndfile has mp3 decoder now!
« Reply #8 on: March 30, 2022, 06:45:51 pm »

Hum, without any dependencies (even without libopus.so ), I am curious.
The same for flac, ogg, all-wav-type  (16 and 32 resolution)...


Here you are OGG for Pascal:
https://github.com/Relfos/TERRA-Engine/blob/d4aba7106242e5949464b19d7dfc652f105eec3a/Engine/Audio/Formats/TERRA_OGG.pas

We should remember that C & C++ are younger, retarded brothers of Pascal and it's a shame so much is written in them and so little in Pascal ;)

Fred vS

  • Hero Member
  • *****
  • Posts: 3736
    • StrumPract is the musicians best friend
Re: Last release of libsndfile has mp3 decoder now!
« Reply #9 on: March 30, 2022, 07:09:15 pm »
We should remember that C & C++ are younger...

No problems with our younger brothers (they know the elder brother is the boss) and if I can convert you that using libraries is not a crime, imho, libraries written in C and compiled with clang is the best option.

And it is perfect for us, fpc can deal perfectly with clang libraries.
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

dpethes

  • Newbie
  • Posts: 4
Re: Last release of libsndfile has mp3 decoder now!
« Reply #10 on: May 02, 2022, 08:02:49 pm »

All that said, if you find something stable in Pascal to decode mp3, opus, flac, wav, ogg, m4, I am very interested by this code...

Fre;D

Hi Fre;D!

This is OS independent:

https://github.com/dpethes/mp3dp

Not tested

Winni

Hello Winni.

Thanks but https://forum.lazarus.freepascal.org/index.php/topic,58893.msg438941.html#msg438941

Fre;D

As author of mp3dp, I'm not sure I understand - you have an issue with it being gpl? Also to add to that chain, bunch of code is still from iso dist10 mp3 source from ancient history, and not gpl.

Fred vS

  • Hero Member
  • *****
  • Posts: 3736
    • StrumPract is the musicians best friend
Re: Last release of libsndfile has mp3 decoder now!
« Reply #11 on: May 02, 2022, 09:32:24 pm »
As author of mp3dp, I'm not sure I understand - you have an issue with it being gpl? Also to add to that chain, bunch of code is still from iso dist10 mp3 source from ancient history, and not gpl.

Hello dpethes.

With GPL only for libraries there is less liberty than with modified-LGPL.
Is it possible for your project to become modified-LGPL?
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Fred vS

  • Hero Member
  • *****
  • Posts: 3736
    • StrumPract is the musicians best friend
Re: Last release of libsndfile has mp3 decoder now!
« Reply #12 on: May 02, 2022, 11:37:31 pm »
As author of mp3dp,..

Hello dpethes.

I did test SDL window player from your release https://github.com/dpethes/mp3dp/releases

WOW, very impressing.
Tested via wine on Linux and it works out-of-the-box, even with my mp3.
The sound is very clear, congratulation.

Do you have plan for seek() methods?

And do you have read() methods?

Like in libsndfile:
Code: Pascal  [Select][+][-]
  1. sf_read_float: function(sndfile: TSNDFILE_HANDLE; ptr: ctypes.pcfloat;
  2.   frames: Tuos_count_t): Tuos_count_t; cdecl;

or in mpg123:
Code: Pascal  [Select][+][-]
  1. mpg123_read = function(mh: Tmpg123_handle; outmemory: pcfloat;
  2.     outmemsize: size_t; var done: size_t): integer; cdecl;

or in opusfile:
Code: Pascal  [Select][+][-]
  1. op_read: function(OpusFile: TOpusFile; pcm : pcint; SampleCount: cint; li: pcint): cint;cdecl;

or in soundtouch:
Code: Pascal  [Select][+][-]
  1. soundtouch_putSamples: procedure(h: THandle; const samples: pcfloat;
  2.   numSamples: cardinal); cdecl;

If yes, great, so your code can be used with PortAudio or other audio-api for players and will be accessible for other OS, like Linux or OSX.
« Last Edit: May 08, 2022, 05:02:37 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

dpethes

  • Newbie
  • Posts: 4
Re: Last release of libsndfile has mp3 decoder now!
« Reply #13 on: May 03, 2022, 01:47:24 pm »
Switching to modified LGPL can be arranged. As for the api, currently it only takes an input stream and decodes it to output stream. I can add a lower level api, exposing seeking and partial decoding - it needs to be expanded anyway, to report sampling frequency, so the user can set up the audio device properly. However I'm not familiar with PortAudio and don't plan on using it. The sample player should be compilable on Linux and MacOS but I imagine that one would miss the imgui lib to run it, so the mp3_decode demo can be used to test instead (testers welcomed).
Sound should be more or less as in any other player. Samples won't be bit-exact due to difference in floating point computations*, but if there's no error in input, it's inaudible. Or should be, unless bugs creep in, of course.


* the mpeg standard doesn't specify bit-exact decoding, that became a feature in later standards. Maximum error is specified instead for the decoder to be conformant

Fred vS

  • Hero Member
  • *****
  • Posts: 3736
    • StrumPract is the musicians best friend
Re: Last release of libsndfile has mp3 decoder now!
« Reply #14 on: May 03, 2022, 02:53:49 pm »
Hello dpethes.

Switching to modified LGPL can be arranged.

Great!  ;)

However I'm not familiar with PortAudio and don't plan on using it.

PortAudio is an Open-Source Cross-Platform Audio API that can deal with lot of OS and sound-cards.

But the principle is the same for each audio api, like ALSA, PulseAudio, ... : take a defined number of decoded samples from the input (can be from file, mic, synth ...), with a defined sample-rate, and give it to the audio-device that will convert the samples into analogic signal.
The samples can be 16 or 32 bit integer or 32 bit float.

All that audio api can deal with the audio-file-decoder libraries like libsndfile or mpg123 for example.
For this the file_read_ method is used by the audio api and is similar for libsndfile and mpg123.

To resume: it would be great if your mp3 decoder would have also a file_read_ method +- similar as libsndfile or mpg123.
« Last Edit: May 07, 2022, 04:55:02 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

 

TinyPortal © 2005-2018