Lazarus

Programming => Graphics and Multimedia => Audio and Video => Topic started by: process_1 on July 16, 2020, 02:23:16 pm

Title: Full, or partial WAV playing - mulit-platform file or memory
Post by: process_1 on July 16, 2020, 02:23:16 pm
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.

Title: Re: Full, or partial WAV playing - mulit-platform file or memory
Post by: Seenkao 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.
Title: Re: Full, or partial WAV playing - mulit-platform file or memory
Post by: process_1 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.
Title: Re: Full, or partial WAV playing - mulit-platform file or memory
Post by: trev on July 17, 2020, 02:37:04 am
Here are your Cross-Platform (https://wiki.lazarus.freepascal.org/Multimedia_Programming#Cross_Platform) options, but you may have to bite the proverbial bullet and go with a mix of cross-platform and Native (https://wiki.lazarus.freepascal.org/Multimedia_Programming#Native_solutions) (Windows, macOS) options.
Title: Re: Full, or partial WAV playing - mulit-platform file or memory
Post by: alaa123456789 on July 17, 2020, 07:20:14 am
https://www.youtube.com/watch?v=g98_SbLnBAw&list=PLUIPhGMf8-xogHPrOc5rt5-7ALxJzQesr&index=12&t=0s
Title: Re: Full, or partial WAV playing - mulit-platform file or memory
Post by: Fred vS 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).
TinyPortal © 2005-2018