Recent

Author Topic: Sound in raspberry pi  (Read 17971 times)

openscoreboard

  • New Member
  • *
  • Posts: 30
  • openscoreboard
Sound in raspberry pi
« on: January 12, 2016, 03:06:53 pm »
I cant play sound in rapberry pi using UOS. I have used lib than has raspbian distro (libmpg123.so.0.40.3, libsndfile.so.1.0.25, libportaudio.so.2.0.0), the compliation is ok but i have error"raised exception class External SIGSEGV" when execute

uos_Play(PlayerIndex1)

In linux (lubuntu) the code work fine...

Any idea?

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1290
Re: Sound in raspberry pi
« Reply #1 on: January 12, 2016, 05:54:45 pm »
hello,
show us the whole source code and what kind of sound file do you want to play (mp3, wav ... ) ?
i don't know if someone has used uos on raspberry :
Quote
uos
Included in the package:
. Examples fpGUI, LCL and console.
. Binaries of libraries for Linux, Windows, Mac osX, FreeBSD.


Friendly, J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

openscoreboard

  • New Member
  • *
  • Posts: 30
  • openscoreboard
Re: Sound in raspberry pi
« Reply #2 on: January 12, 2016, 07:18:54 pm »
The code loading library....

Code: Pascal  [Select][+][-]
  1.  
  2. procedure Load_uos;
  3. var
  4.   res: integer;
  5.   ordir, opath, PA_FileName, SF_FileName, MPG_FileName: string;
  6.   begin
  7.     ordir := application.Location;
  8.  
  9.  
  10.  {$IFDEF linux}
  11.     {$if defined(cpu64)}
  12.     PA_FileName := ordir + 'uos_lib/Linux/64bit/LibPortaudio-64.so';
  13.     SF_FileName := ordir + 'uos_lib/Linux/64bit/LibSndFile-64.so';
  14.     MPG_FileName := ordir + 'uos_lib/Linux/64bit/LibMpg123-64.so';
  15.     {$else}
  16.     PA_FileName := ordir + 'uos_lib/Linux/rpi/libportaudio.so.2.0.0';
  17.     SF_FileName := ordir + 'uos_lib/Linux/rpi/libsndfile.so.1.0.25';
  18.     MPG_FileName := ordir + 'uos_lib/Linux/rpi/libmpg123.so.0.40.3';
  19.   {$endif}
  20. {$ENDIF}
  21.  
  22.  
  23.     // Load the libraries
  24.     // function uos_LoadLib(PortAudioFileName: Pchar; SndFileFileName: Pchar; Mpg123FileName: Pchar; SoundTouchFileName: Pchar) : integer;
  25.  
  26.    res := uos_LoadLib(Pchar(PA_FileName), Pchar(SF_FileName), Pchar(MPG_FileName), nil) ;
  27.  
  28.   //  writeln('Result of loading (if 0 => ok ) : ' + IntToStr(res));
  29.  
  30.    if res = 0 then uos_lib_OK := True else
  31.      begin
  32.      uos_lib_OK := False;
  33.      ShowMessage('uos LoadLib Error');
  34.      end;
  35.      end;            
  36.  

...and  button click and play sound

Code: Pascal  [Select][+][-]
  1.  if uos_lib_OK then
  2.   begin
  3.   PlayerIndex1 := 0;
  4.   uos_CreatePlayer(PlayerIndex1); //// Create the player
  5.  
  6.   In1Index := uos_AddFromFile(PlayerIndex1,(pchar('sound/test.wav')));
  7.  
  8.     uos_AddIntoDevOut(PlayerIndex1, -1, -1, uos_InputGetSampleRate(PlayerIndex1, In1Index), -1, -1, -1);
  9.     // play File
  10.     uos_Play(PlayerIndex1);
  11.    end;
  12.  

Thanks...
« Last Edit: January 12, 2016, 07:41:37 pm by openscoreboard »

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1290
Re: Sound in raspberry pi
« Reply #3 on: January 12, 2016, 11:29:14 pm »
hello,
what is the value of In1Index ?
Try to put the full path for the sound file if variable = -1
The Load_uos procedure load 64 or 32 bits sound libraries ?
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

openscoreboard

  • New Member
  • *
  • Posts: 30
  • openscoreboard
Re: Sound in raspberry pi
« Reply #4 on: January 14, 2016, 08:04:42 pm »
Testing

Lubuntu: OK
In1Index=0 library=64bit (LibPortaudio-64.so, LibSndFile-64.so, LibMpg123-64.so)


Raspberry pi: ERROR
In1Index=0 library=rpi (libportaudio.so.2.0.0, libsndfile.so.1.0.25, libmpg123.so.0.40.3)

« Last Edit: January 15, 2016, 12:02:41 am by openscoreboard »

Fred vS

  • Hero Member
  • *****
  • Posts: 3734
    • StrumPract is the musicians best friend
Re: Sound in raspberry pi
« Reply #5 on: January 15, 2016, 12:03:45 am »
Hello.

Like Jurassic Pork said, try with full path, something like:

Code: Pascal  [Select][+][-]
  1. In1Index := uos_AddFromFile(PlayerIndex1,(pchar('/home/openscoreboard/sound/test.wav')));

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

openscoreboard

  • New Member
  • *
  • Posts: 30
  • openscoreboard
Re: Sound in raspberry pi
« Reply #6 on: January 15, 2016, 12:20:15 am »
 %)

Fred vS

  • Hero Member
  • *****
  • Posts: 3734
    • StrumPract is the musicians best friend
Re: Sound in raspberry pi
« Reply #7 on: January 15, 2016, 12:31:04 am »
Have you try to play your test.wav with a other application in your pi ?

[EDIT] Have you try with a mp3 or ogg or flac file ?
« Last Edit: January 15, 2016, 12:34:33 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

openscoreboard

  • New Member
  • *
  • Posts: 30
  • openscoreboard
Re: Sound in raspberry pi
« Reply #8 on: January 15, 2016, 03:42:54 pm »
Testing....

Lubuntu

WAV , MP3 , OGG, FLAC OK



RPI


WAV OK, MP3 NOISE,  OGG NOISE, FLAC NOISE with aplay

WAV OK, MP3 OK, OGG OK, FLAC ok with VLCplayer

Thanks....
« Last Edit: January 15, 2016, 03:50:07 pm by openscoreboard »

Fred vS

  • Hero Member
  • *****
  • Posts: 3734
    • StrumPract is the musicians best friend
Re: Sound in raspberry pi
« Reply #9 on: January 15, 2016, 04:41:16 pm »
What is "aplay" ? A uos demo ?

Have you try with different configuration, example with 16 or 32 or float 32 sample format ?

Code: Pascal  [Select][+][-]
  1.  function AddIntoDevOut(Device: LongInt; Latency: CDouble;
  2.       SampleRate: LongInt; Channels: LongInt; SampleFormat: LongInt ; FramesCount: LongInt ): LongInt;
     ////// Add a Output into Device Output
    //////////// Device ( -1 is default device )
    //////////// Latency  ( -1 is latency suggested ) )
    //////////// SampleRate : delault : -1 (44100)
    //////////// Channels : delault : -1 (2:stereo) (0: no channels, 1:mono, 2:stereo, ...)
    //////////// SampleFormat : default : -1 (1:Int16) (0: Float32, 1:Int32, 2:Int16)
    //////////// FramesCount : default : -1 (= 65536)
    //  result :  Output Index in array    -1 = error
    /// example : OutputIndex1 := AddIntoDevOut(-1,-1,-1,-1,0);

Code: Pascal  [Select][+][-]
  1.  function AddFromFile(Filename: Pchar; OutputIndex: LongInt;
  2.       SampleFormat: LongInt ; FramesCount: LongInt): LongInt;
    /////// Add a input from audio file with custom parameters
    ////////// FileName : filename of audio file
    ////////// OutputIndex : Output index of used output// -1: all output, -2: no output, other LongInt refer to a existing OutputIndex  (if multi-output then OutName = name of each output separeted by ';')
    //////////// SampleFormat : default : -1 (1:Int16) (0: Float32, 1:Int32, 2:Int16)
    //////////// FramesCount : default : -1 (65536)
    //  result :   Input Index in array    -1 = error
    //////////// example : InputIndex1 := AddFromFile(edit5.Text,-1,0,-1);

FreD
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

openscoreboard

  • New Member
  • *
  • Posts: 30
  • openscoreboard
Re: Sound in raspberry pi
« Reply #10 on: January 19, 2016, 10:40:14 pm »
 :D My raspberry pi SOUND!!!...is a little poor but SOUND!!!

AddIntoDevOut    <---- SampleFormat :=0 (Float32)

AddFromFile <-----  SampleFormat:=0 (Float32)

Thanks!!!!!!


PD: aplay is a command for rpi include in ALSA

http://linux.die.net/man/1/aplay
« Last Edit: January 19, 2016, 11:25:48 pm by openscoreboard »

Fred vS

  • Hero Member
  • *****
  • Posts: 3734
    • StrumPract is the musicians best friend
Re: Sound in raspberry pi
« Reply #11 on: January 20, 2016, 09:28:22 pm »
Quote
:D My raspberry pi SOUND!!!..

Ha, I am very happy  ;)

Quote
is a little poor but SOUND!!!

What do you mean with "poor" ?

Quote
PD: aplay is a command for rpi include in ALSA

Do you know that uos is autonomous., that it can work without ALSA or OSS or Pulse installed ?

PS: Would you be kind and give, in attachment (or in https://github.com/fredvs/uos/issues )
the compiled libraries that you use for your Raspberry pi (portaudio, sndfile and mpg123).

Many thanks.

Fre;D
« Last Edit: January 20, 2016, 09:45:14 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

openscoreboard

  • New Member
  • *
  • Posts: 30
  • openscoreboard
Re: Sound in raspberry pi
« Reply #12 on: January 20, 2016, 11:13:15 pm »
https://youtu.be/D7Ph_IJqpUo


Testing sound....with aplay and uos

Fred vS

  • Hero Member
  • *****
  • Posts: 3734
    • StrumPract is the musicians best friend
Re: Sound in raspberry pi
« Reply #13 on: January 21, 2016, 09:34:57 am »
Quote
https://youtu.be/D7Ph_IJqpUo

Thanks but... the video is private and I cannot see it  :-X

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

openscoreboard

  • New Member
  • *
  • Posts: 30
  • openscoreboard
Re: Sound in raspberry pi
« Reply #14 on: January 21, 2016, 10:02:17 am »
 :-[
Sorry..now is public!

 

TinyPortal © 2005-2018