Recent

Author Topic: Play MP3/WAV files in freepascal command line on RPI 2  (Read 20877 times)

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Play MP3/WAV files in freepascal command line on RPI 2
« Reply #15 on: July 18, 2016, 02:58:19 pm »
What kind of *.wav can be recognized by openal ?
None ;)
OpenAL is for playback and recording audio only, not for reading audio files.
Reading (decoding/encoding) the audio depends on other the external libraries.

.wav file reading is implemented in test sample itself (TWaveReader class). Btw, it should give you either "unable to read WAVE format" or "WAVE file is using compression. Cannot play sorry. Please provide uncompressed .wav" message.

Fred vS

  • Hero Member
  • *****
  • Posts: 3724
    • StrumPract is the musicians best friend
Re: Play MP3/WAV files in freepascal command line on RPI 2
« Reply #16 on: July 18, 2016, 03:20:41 pm »
Btw, it should give you either "unable to read WAVE format" or "WAVE file is using compression. Cannot play sorry. Please provide uncompressed .wav" message.

I used wavopenal.pas from trunck and a classical wav 16 bit stereo file (listen attachment).

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

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Play MP3/WAV files in freepascal command line on RPI 2
« Reply #17 on: July 18, 2016, 03:28:09 pm »
I used wavopenal.pas from trunck and a classical wav 16 bit stereo file (listen attachment).
try to compile the sample and run it as following:
Code: [Select]
./wavopenal /home/fred/Téléchargements/waveopenal/test.wav

Fred vS

  • Hero Member
  • *****
  • Posts: 3724
    • StrumPract is the musicians best friend
Re: Play MP3/WAV files in freepascal command line on RPI 2
« Reply #18 on: July 18, 2016, 03:34:01 pm »
Quote
./wavopenal /home/fred/Téléchargements/waveopenal/test.wav

OK, thanks =>

Quote
Blocksize    : 4
Rate         : 44100
Channels     : 2
OpenAL Buffers     : 4
OpenAL Buffer Size : 20000
....................

Quote
And is openal.so library needed for only decoding a wav  file (no pure code only) ?
Huh, yes (Y) or no (N) ?

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

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Play MP3/WAV files in freepascal command line on RPI 2
« Reply #19 on: July 18, 2016, 03:46:29 pm »
Quote
And is openal.so library needed for only decoding a wav  file (no pure code only) ?
Huh, yes (Y) or no (N) ?
openal.so is need for playback or recording only.
Has nothing to do with .wav files at all.

OpenAL is a lower level library than uOS. It doesn't provide any file reading/decoding capabilities.

Fred vS

  • Hero Member
  • *****
  • Posts: 3724
    • StrumPract is the musicians best friend
Re: Play MP3/WAV files in freepascal command line on RPI 2
« Reply #20 on: July 18, 2016, 04:57:53 pm »
Quote
openal.so is need for playback or recording only.
Has nothing to do with .wav files at all.

Ha, so the answer is : "If you use the wave decoder included in the wavopenal.pas demo, you do not need openal library."  (?)

Quote
OpenAL is a lower level library than uOS.

What is lower level, what can be lower than working with samples (stored into a float array) ?

Thanks.

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

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Play MP3/WAV files in freepascal command line on RPI 2
« Reply #21 on: July 18, 2016, 05:38:58 pm »
Ha, so the answer is : "If you use the wave decoder included in the wavopenal.pas demo, you do not need openal library."  (?)
That's correct. Any OpenAL related code can be stripped off, including the reference to openal library.

What is lower level, what can be lower than working with samples (stored into a float array) ?
You need to define "working".
For example rendering the wave form on a GUI part of a system is "working with samples", but it's pretty high-level, since it needs to handle a lot of stuff.

uOS provides API to play audio as well as to decode audio from a file.
OpenAL provides API to play an audio only.
That places OpenAL or a lower level, compared to uOS. As well as OpenAL's "working" is strictly limited to playing/recording audio samples only, where uOS also provides a mean to decode/encode it to different storage (file) formats.

The benefit of OpenAL is a higher chance of availability on an end system, compared to uOS library.
« Last Edit: July 18, 2016, 05:41:14 pm by skalogryz »

Fred vS

  • Hero Member
  • *****
  • Posts: 3724
    • StrumPract is the musicians best friend
Re: Play MP3/WAV files in freepascal command line on RPI 2
« Reply #22 on: July 18, 2016, 06:58:32 pm »
Quote
uOS provides API to play audio as well as to decode audio from a file.
OpenAL provides API to play an audio only.
That places OpenAL or a lower level, compared to uOS. As well as OpenAL's "working" is strictly limited to playing/recording audio samples only, where uOS also provides a mean to decode/encode it to different storage (file) formats.

Hum, afaik, with wavopenal.pas demo, you get sound.
So, how openal library does to connect to audio port ?
If openal library is a "low level" library, it should deal (and have code to do this) with audio port too.
But it is not the case.

But, maybe, our "low level" understanding differs.

By the way, many thanks for (your?) wavopenal.pas demo.
If the author (you?) agrees, I will add the wav decoder of the demo in uos (so it will be possible to decode wav files also without loading SndFile.so audio library).

But, till now, I do not see advantage of  openal.so vs portaudio.so (both are limited to playing/recording audio samples, but portaudio can deal directly with audio devices (or use the installed sound system). Openal can only deal with a installed sound system, like ALSA, OSS, Pulse, ...


Fre;D
« Last Edit: July 20, 2016, 12:32:49 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

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Play MP3/WAV files in freepascal command line on RPI 2
« Reply #23 on: July 18, 2016, 07:40:47 pm »
So, how openal library does to connect to audio port ?
If openal library is a "low level" library, it should deal (and have code to do this) with audio port too.
Try this example
Code: [Select]
program wavopenal;

{$mode objfpc}

uses openal;

procedure ListDevices(dev: PChar);
var
  i : integer;
  j : integer;
  n : string;
  l : integer;
begin
  i:=0;
  j:=0;
  repeat
    while dev[i]<>#0 do inc(i);
    if j+1<i then begin
      l:=i-j;
      SetLength(n, l);
      Move(dev[0], n[1], l);
      writeln(n);
      inc(i);
      j:=i;
      if dev[j]=#0 then // end is reachedl
        Break
      else
        inc(i);
    end;
  until (dev[j]=#0) and (dev[i]=#0);
end;

var
  def  : PChar;
  list : PChar;
  name : string;
begin
  name:='ALC_ENUMERATION_EXT';
  if alcIsExtensionPresent(nil,PALChar(@name[1]))  then
  begin
    def := PChar(alcGetString(nil, ALC_DEFAULT_DEVICE_SPECIFIER));
    list := PChar(alcGetString(nil, ALC_DEVICE_SPECIFIER));
  end else begin
    def:=nil;
    list:=nil;
  end;

  if not Assigned(list) then begin
    writeln('unable to get the list of devices');
    Exit;
  end;
  writeln('Devices:');
  ListDevices(list);
  writeln;
  writeln('Default:', def);
end.
See what devices it lists to you and what's the default

If the author (you?) agrees, I will add the wav decoder of the demo in uos (so it will be possible to decode wav files also without loading SndFile.so audio library).
Yes, I'm the author and feel free to add it to the demo.

Fred vS

  • Hero Member
  • *****
  • Posts: 3724
    • StrumPract is the musicians best friend
Re: Play MP3/WAV files in freepascal command line on RPI 2
« Reply #24 on: July 18, 2016, 11:00:47 pm »
Quote
Try this example
Ha, ok, then openal deals with audio devices too, nice  ;). (With the help of a installed sound system like OSS or Pulse or can it deal with devices directly, like PortAudio ?)

Quote
Yes, I'm the author...
Wow, super congrats.

There is something that I do not understand.  :-[
Why openal library is needed, could it be possible to have all the code of openal in Pascal, like AGGPas for AGG, so no need to call a external C library ?

Quote
and feel free to add it to the demo.
Huh, the idea was to use part of the code of wavopenal.pas to create something like this (but not to use it as a demo):
Code: Pascal  [Select][+][-]
  1. uos_AddFromUncompressedWavFile(PlayerIndex: LongInt; Filename: PChar): LongInt;
,

Thanks.

Fre;D
« Last Edit: July 18, 2016, 11:13:08 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

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Play MP3/WAV files in freepascal command line on RPI 2
« Reply #25 on: July 18, 2016, 11:45:41 pm »
Ha, ok, then openal deals with audio devices too, nice  ;). (With the help of a installed sound system like OSS or Pulse or can it deal with devices directly, like PortAudio ?)
I've no idea how openal does it, but according to the wiki, it already supports all of them.

There is something that I do not understand.  :-[
Why openal library is needed, could it be possible to have all the code of openal in Pascal, like AGGPas for AGG, so no need to call a external C library ?
Because it has already been implemented in C :) porting it to Pascal might introduce some more issues.
Also, the implementation is already cross-platform, and C still compiles on a greater set of platforms than FPC does.


Fred vS

  • Hero Member
  • *****
  • Posts: 3724
    • StrumPract is the musicians best friend
Re: Play MP3/WAV files in freepascal command line on RPI 2
« Reply #26 on: July 19, 2016, 12:00:18 am »
Quote
I've no idea how openal does it, but according to the wiki, it already supports all of them.

From wiki:
Quote
Supported platforms
...
Linux (supports ALSA, OSS, PortAudio and PulseAudio)

So openal needs a installed sound system (and then uos is lower-level than openal, because it can deal directly with devices. :-X )

But the great news is:  your wav decoder, full fpc code (no need of any library) that will be soon (if you agree) part of uos.

[EDIT] Ooops, after a deeper look at your code, it seems that seek() is not implemented, nor 32 bit integer nor 32 bit float resolution.  %)
Sorry but it is not usable for uos yet.

Many thanks.

Fre;D

 
« Last Edit: July 19, 2016, 03:14:04 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

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Play MP3/WAV files in freepascal command line on RPI 2
« Reply #27 on: July 19, 2016, 12:08:11 am »
just let fpsound to be released :) it will make other sound apis redundant for FreePascal :D

Fred vS

  • Hero Member
  • *****
  • Posts: 3724
    • StrumPract is the musicians best friend
Re: Play MP3/WAV files in freepascal command line on RPI 2
« Reply #28 on: July 19, 2016, 12:22:53 am »
Quote
just let fpsound to be released

OK, I am ready to be impressed (a lot this time, I hope).
« Last Edit: July 19, 2016, 12:25:54 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

 

TinyPortal © 2005-2018