Recent

Author Topic: Full, or partial WAV playing - mulit-platform file or memory  (Read 509 times)

process_1

  • Guest
For multi-platform (Windows, Linux, OS X at least) I would need to play some sound in the game I'm trying to make:

Scenario 1:

- Have several WAV files on HDD
- One or several WAV files should be played asynchrounioulsy (at the same time), not necessarily begining at the same time (various effects depening on action)
- All asynchrounioulsy played files should be able to be termineted at any time

Scenario 2:

- Have one WAV stream in memory with several effects which require immediate playng. Latency to read from HDD and then to prepare and play is not welcome in that case
- Playing each such effects from one stream should also be played asynchrounioulsy as upper and terminated in any moment. For instance from one specific stream location to another, or specified time.

Does some library which should allow upper requirements already exists, or I would need to create such myself?

The game itself is not quite complex, thus I would not use any huge graphical and multimedia engine already may exists. It is enough to be able to play such simple and short WAV sequences.

« Last Edit: July 16, 2020, 02:48:26 pm by process_1 »

Seenkao

  • Jr. Member
  • **
  • Posts: 69
Re: Full, or partial WAV playing - mulit-platform file or memory
« Reply #1 on: July 16, 2020, 10:52:00 pm »
Use library OpenAL, BASS or other.
проблема будет только в выборе папок для разных OS.
google translate: the problem will be only in choosing folders for different OS.

process_1

  • Guest
Re: Full, or partial WAV playing - mulit-platform file or memory
« Reply #2 on: July 16, 2020, 11:47:00 pm »
Seenkao, thank you for your reply.

However,  OpenAL, BASS and similar require separate download. That is exactly what I'm trying to avoid.

What I have made so far is my own library from ground to support upper requirements for Linux using ALSA. Similar would be also possible to made for Windows, however I'm not certain for OS X, as I do not have any Mac machine, nor experience with.

Probably some similar basic library which do not require external download already exists, however I'm not aware of it.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1009
  • Former Delphi 1-7, 10.2 User
Re: Full, or partial WAV playing - mulit-platform file or memory
« Reply #3 on: July 17, 2020, 02:37:04 am »
Here are your Cross-Platform options, but you may have to bite the proverbial bullet and go with a mix of cross-platform and Native (Windows, macOS) options.
o Lazarus v2.1.0 r63871, FPC v3.3.1 r46876, macOS 10.14.6 (with sup update), Xcode 11.3.1
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 amd64 (VMware Fusion VM)
o FPC 3.0.4, FreeBSD 12.2-STABLE r365646 amd64
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 20.04 (Parallels VM)


Fred vS

  • Hero Member
  • *****
  • Posts: 1888
    • StrumPract is the musicians best friend
Re: Full, or partial WAV playing - mulit-platform file or memory
« Reply #5 on: July 17, 2020, 02:30:45 pm »
Hello.

You may use uos and the libraries installed on the system, so no libraries needed to download.

For this use "system" as path name for loading a library, like that:

Code: Pascal  [Select][+][-]
  1. uos_LoadLib(Pchar('system'), Pchar('system'), Pchar('system'), Pchar('system'), Pchar('system'), Pchar('system')) ;
 
If you only deal with wav files, you need only PortAudio and SndFile libraries.
Those libraries are installed by default on nearly all Unix distro (including Linux and FreeBSD).

You should use this:

Code: Pascal  [Select][+][-]
  1. uos_LoadLib(Pchar('system'), Pchar('system'), nil, nil, nil, nil) ;

For Windows and Mac, or you may install the libraries from their site or simply dynamically load it from the uos lib-directory (that you included in your project).
« Last Edit: July 17, 2020, 03:16:37 pm by Fred vS »
I use Lazarus 2.0.6 32/64 and FPC 3.2.0 32/64 on Debian 10.2 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

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

 

TinyPortal © 2005-2018