Recent

Author Topic: (SOLVED)Is There a Manner to Play a Sound CrossPlatform With a Free Library???  (Read 5954 times)

lestroso

  • Full Member
  • ***
  • Posts: 134
    • FaSasoftware
Is There a Manner to Play a Sound CrossPlatform With a Free Library???

i have tested all the lazarus library in the site...but nothing works here...i need a cross platform sound library that works...for my projects...
I have a macos x 10.13.6, 16gb ram, 1tb hard disk ssd,intel i3 imac....but i have also an Asus with 8 gb ram amd10 , 1tb hard disk ssd...
does exist a free solution??? can somebody help me??
I thank you a lot in advance....
Lestroso :'( :'( :'(
« Last Edit: May 07, 2019, 07:50:46 pm by lestroso »

kupferstecher

  • Hero Member
  • *****
  • Posts: 604
I used PortAudio before. It works cross platform.

It works with a callback function that is called by PortAudio sequently and you have to provide the current audio data through parameters. This means PortAudio doesn't open sound files, you have to take care of it seperately, but it also means you have full control of the played sound.

Regards~

Edit: I used it on Windows.

lestroso

  • Full Member
  • ***
  • Posts: 134
    • FaSasoftware
thank you...kupferstecher...

i tryed but nothing works here....the system is thery complicated.....or can you show me an your example to use use it??please?? thanks a lot...

Lestroso

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Not exactly the best (or more elegant) way, but there's a simple one that should work on most systems in the wiki: Play Sound Multiplatform.

It invokes mmsystem.sndPlaySound() for Windows and, for Linux, it searchs for one of several known players and, if found, calls it through a TAsyncProcess. I guess something similar might be done for *BSD and (Darwin) MacOS.

Otherwise, you can start reading at Multimedia Programming and go from there.

Oh, also check out this post: Recomendations for audio metadata. I asked about sound metadata but most library recommendations included ways to play the sounds, too.
« Last Edit: May 07, 2019, 12:36:57 am by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

lestroso

  • Full Member
  • ***
  • Posts: 134
    • FaSasoftware
Dear Lucamar,dear kupferstecher, dear all friends...

I'm sorry for this question....perhaps i have missed this option library...You have solved my problem!!! I thank to you! to everybody.... Definetly the best solution to add some sounds in our projects!!!
The link below is the right solution to every body...Play Sound Multiplatform
http://wiki.freepascal.org/Play_Sound_Multiplatform

I have tested many formats!!! Works well in my Imac 2010....The formats that works fine with this library are:
WAV,AIFF,MP3,M4A,FLAC.....The formats that don't works with this library are OGG and WMA....
But...i'm very happy for this...i need mp3 the right compression!!!It  Works....

The only thing that i had to do was add the audio component  and rebuild Lazarus....It's all ok!!!

There are no words to thank you again....

Best regards,
Lestroso :D :D :D :D
https://www.fasasoftware.com
« Last Edit: May 07, 2019, 07:51:41 pm by lestroso »

lazer

  • Sr. Member
  • ****
  • Posts: 269
Is this library still current with Lazarus?

I did the svn checkout and got 750MB of cruft on my system.
I copied the relevant Playsound tree to my lazarus components.

Code: Pascal  [Select][+][-]
  1. ls /usr/lib64/lazarus/components/playsoundpackage/latest_stable
  2. aboutplaysound.pas  license.lrs  playsoundackage.pas  playsound_icon.png   playwavepackage.pas  TPlaysound.png  uplaysound.pas
  3. demo                locale       playsound_icon.lrs   playwavepackage.lpk  readme.txt           updates
  4.  

Having rebuild all packages it still does not show up in the list , so I go to import it. There seems to be nothing in that structure which matches the filter Lazarus is imposing.

what do I need to do to use this?  Does even work with current Lazarus?

Thanks.

wp

  • Hero Member
  • *****
  • Posts: 13266
Is this library still current with Lazarus?
Yes (if you mean "playsound" - see below)

I did the svn checkout and got 750MB of cruft on my system.
You can also do a partial checkout from ccr: The following line gets you the playsoundpackage only
Code: [Select]
svn checkout svn://svn.code.sf.net/p/lazarus-ccr/svn/components/playsoundpackageOr download the zipped snapshot from https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/components/playsoundpackage/

Having rebuild all packages it still does not show up in the list , so I go to import it. There seems to be nothing in that structure which matches the filter Lazarus is imposing.

what do I need to do to use this?  Does even work with current Lazarus?
I don't understand what you are doing...

After downloading the playsoundpackage, load the "playwavepackage.lpk" file in "Package" > "Open packge file (*.lpk)" into the IDE, then "Use" > "Install" > "build". When the IDE has restarted you can drop the component on your form.

Alternatively, you could also use a standalone version of the playsound unit which does not require any installation, just copy it into your project folder. See attached zip file which contains the modified unit from the playsoundpackage together with a small demo project - no installation required, just compile & run.

lazer

  • Sr. Member
  • ****
  • Posts: 269
LOL. So I downloaded 723MB of data and all I needed was ONE file !.
Plus all the fannying around to install a library with one component was a waste of time too.

It's a shame they do not give more sensible instructions.

In fact, I opened the demo project and when I went to compile it Lazarus automatically pulled in the library and rebuilt component library.
That fixed it. I added the cmpt to my main window and it all works fine.

Many thanks for the example files and taking the time to explain.

This is a lot simpler and cleaner than uos.

lazer

  • Sr. Member
  • ****
  • Posts: 269
Oh man , this is wasting so much time.

I've got your test project working fine and I get the audio outpu.

Now I tried to apply it my program and I'm getting some very odd behaviour.

First of all I was getting some confusion with the installed packages which I was having trouble full getting rid of.
To ensure no cross talk, I renamed your pas file notplaysound.pas and changes uses clause.  That still works in your example

However, when I try to call it from my program I get a segfault and a crazy error with a very improbably path it can't find.

Code: Pascal  [Select][+][-]
  1. The file "/builddir/build/BUILD/fpc-3.2.2-build/fpcbuild-3.2.2/fpcsrc/rtl/inc/astrings.inc" was not found.
  2. Do you want to locate it yourself?

For a start there is not /builddir  on this system /builddir/build/BUILD/ looks like total BS and then the repeated fpcbuild-3.2.2/f , this is totally messed up.

do you have any idea what that is all about and how to fix it?

TIA.

wp

  • Hero Member
  • *****
  • Posts: 13266
It's hard to tell from the distance...

The error message is unusual to me, I am not a Linux specialist. I did not even know of a "builddir"... In case of such strange messages, I normally do a clean rebuild of the project ("Run" > "Build", or "Run" > "Clean up and Build"). If this does not help, I do a clean rebuild of the IDE. "Tools" > "Configure Build Lazarus" > in the "Clean up" box check "Clean all" and "Switch to automatic mode after building" > "Build".

Depending on how you installed Lazarus, however, rebuilding the IDE in Linux may be easy or a pain... - there are numerous threads in the forum about such problems.

How did you use the "old" package in your project? Did you add the path to it in the "Other unit files" project options? That's the way Delphi does it. Remove the path to the playsound package from "Other unit files". Delete the output directory of the project (listed as "Unit output directory" on the same page of the project options) and compile again. Or did you add the package to the "required packages" of the project (in the Project Options)? That's the Lazarus way. Just delete the package from the "required packages" node of the project tree. It would not be harmful to delete the output directory, too.

You should also get rid of the package. Did you "use" > "install" as I told you in the previous message? In this case, go to "Package" > "Install/uninstall packages", select the package in the LEFT package list, click "Uninstall selection", then "Rebuild IDE". After a while the IDE restarts, and the package is gone. It still exists on the disk though, you can simple delete the files now.

lazer

  • Sr. Member
  • ****
  • Posts: 269
Thanks for all that. I didn't realise how much I had forgotten out using Lazarus.
All the rebuilding did not change anything, however, I have found this:

 
Code: XML  [Select][+][-]
  1.  <Package125 Name="pasmp" Count="1">
  2.     <PackageFile0 Name="lazpasmp.lpk"/>
  3.   </Package125>
  4.   <Package126 Name="PlaysoundPackage" Count="1">
  5.     <PackageFile0 Name="playwavepackage.lpk"/>
  6.   </Package126>
  7.   <Package127 Name="plotpanel-lazarus-0.97.1" Count="1">
  8.     <PackageFile0 Name="plot.lpk"/>
  9.   </Package127>
  10.  
in ~/.lazarus/onlinepackagemanager/config

playwavepackage.lpk does not exist anywhere on the system and this package should not exist. I no longer see it in the IDE.

Similarly in the .json file in the same directory.

Code: Pascal  [Select][+][-]
  1.   "PackageData126" : {
  2.     "Name" : "PlaysoundPackage",
  3.     "DisplayName" : "PlaysoundPackage",
  4.     "Category" : "Multimedia",
  5.     "CommunityDescription" : "Component to play wave (.wav) files on Windows/Linux.",
  6.     "ExternalDependecies" : "",
  7.     "OrphanedPackage" : 0,
  8.     "RepositoryFileName" : "PlaysoundPackage.zip",
  9.     "RepositoryFileSize" : 226718,
  10.     "RepositoryFileHash" : "96254466de751ebcf83aa38dafd71080",
  11.     "RepositoryDate" : 4.5300534273645833E+004,
  12.     "PackageBaseDir" : "playsoundpackage\\/",
  13.     "HomePageURL" : "http://wiki.freepascal.org/playsound",
  14.     "DownloadURL" : "https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/components/playsoundpackage/latest_stable/updates/update_playsoundpackage.json?format=raw",
  15.     "SVNURL" : ""
  16.   },
  17.  
« Last Edit: September 03, 2025, 03:37:36 am by lazer »

lazer

  • Sr. Member
  • ****
  • Posts: 269
I just did the cmpt installation as I did before .

I opened the demo project and it goes online to pull in the package (apparently it's not set up properly to use it's own code directly).

This installed the cmpt as before but if I add an example to my form , without actually using it, it now throws an exception as soon as I run it.


I think a lot of the problem is that there are two versions on the onlineinstallation database , one in /usr/lib64 installed by the distro lazarus pkg and another maybe created locally when I run the IDE.

The demo triggered an installation in the local one which I can't get rid of. At some point it seems to have got two versions of the pkg installed . If I use the IDE to remove it , it only removes one and then thinks its not longer there so can't uninstall the one which is left.
« Last Edit: September 03, 2025, 04:47:36 am by lazer »

lazer

  • Sr. Member
  • ****
  • Posts: 269
OK, I've uninstalled both lazarus and fpc distro packages.
I deleted any existing remnants I could find in system and home directories and reinstalled.
I removed the redundant dependancy in my project from the IDE.

Same strange error.

The file it is searching for is in /usr/share/fpc  the rest of that path is some kind of AI hallucination.
« Last Edit: September 03, 2025, 09:05:49 am by lazer »

wp

  • Hero Member
  • *****
  • Posts: 13266
the rest of that path is some kind of AI hallucination.
AI hallucination? Both Lazarus and FPC do not use any AI (except for the aissist package which is not installed by default). What are you doing?

Fred vS

  • Hero Member
  • *****
  • Posts: 3721
    • StrumPract is the musicians best friend
This is a lot simpler and cleaner than uos.

Ha, could you explain what is difficult and not clean with uos?
And to play mp3, ogg, wav, flac, m4a, aac, opus, mod, it, s3m, xm, cda, ... audio files you will need only 3 megas of dependencies.
And these dependencies are loaded dynamically, so you don't need to install anything on the system.
And all the demos should compile + run out-of-the-box.
« Last Edit: September 03, 2025, 12:40:11 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