SoLoud-based BlitzMax Audio driver

Brucey 0537f8c203 Merge pull request #21 from bmx-ng/task/fix-stream-loop-crash 11 tháng trước cách đây
audiominiaudio.mod fa69a61aef [Misc] Replace shorthand codes ($, %...) with their long versions 2 năm trước cách đây
audiosdl.mod fa69a61aef [Misc] Replace shorthand codes ($, %...) with their long versions 2 năm trước cách đây
examples ffc0709716 Added a queued sound source. 1 năm trước cách đây
libopenmpt.mod 44a40f44a3 Updated libopenmpt. 3 năm trước cách đây
midi.mod d78a86dc06 Audio.Midi. Initial Import. 2 năm trước cách đây
modloader.mod ee74ffcf13 Update to woollybah/soloud.571fde0 3 năm trước cách đây
soloud.mod f625102318 Fixed stream loop crash. 11 tháng trước cách đây
soloudaudio.mod ffc0709716 Added a queued sound source. 1 năm trước cách đây
soloudminiaudio.mod ee74ffcf13 Update to woollybah/soloud.571fde0 3 năm trước cách đây
soloudsdl.mod f77be07d99 Date bump. 3 năm trước cách đây
.gitignore 47e1b9d7da Updated to latest SoLoud. 3 năm trước cách đây
README.md 47e1b9d7da Updated to latest SoLoud. 3 năm trước cách đây

README.md

BlitzMax Audio

The Audio modules provide a more comprehensive audio experience in BlitzMax than the original and default audio drivers, adding support for more backends, more audio file types, and streaming.

The Audio framework is built on top of the open source SoLoud audio engine, which itself integrates with various different audio formats and libraries.

Supported Audio Formats

Wave Sounds

Wave sounds are sound files loaded directly into memory. These are converted to float samples, which means that every second of a 44100Hz stereo sound takes about 350kB of memory. Although they require a lot of memory, processing them requires very few resources.

Because of the memory requirements, these are more suited to sound effects and short clips, rather than long audio tracks. For large samples, consider using Streaming.

The following file formats are supported : wav, flac, mp3, and ogg.

Streaming

Streaming allows audio to be played directly from the device by loading a section of it at a time. Although this requires more resources to process the audio, it uses much less memory.

The following file formats can be streamed : wav, flac, mp3, and ogg.

MODs

By importing Audio.ModLoader, you gain access to a multitude of MOD/tracker music, with support for the following MOD file formats: 669, amf, ams, dbm, digi, dmf, dsm, far, gdm, ice, imf, it, itp, j2b, m15, mdl, med, mid, mo3, mod, mptm, mt2, mtm, okt, plm, psm, ptm, s3m, stm, ult, umx, wow and xm.

Selecting an Audio Driver

Depending on what platform you are targeting and what system backend you are using there are up to two audio drivers available to choose from.

Different audio backends are available on different platforms, and for Linux specifically, only if the relevant packages have been installed on the system.

Each has a "default" backend which will be automatically enabled when audio is initialised.

Audio.AudioSDL

This driver is only available if the SDL backend for rendering and events is in use, although it's not specifically required if you are using the SDL backend.

Available Backends

Win32

  • SoLoud::DirectSound / SoLoud (default)
  • SoLoud::WinMM

Linux

  • SoLoud::ALSA
  • SoLoud::PulseAudio / SoLoud (default)
  • SoLoud::OSS
  • SoLoud::NAS

macOS

  • SoLoud::CoreAudio / SoLoud (default)

Audio.AudioMiniAudio

This driver is backed by the MiniAudio library.

Available Backends

Win32

  • SoLoud::DirectSound / SoLoud (default)
  • SoLoud::WinMM
  • SoLoud::WASAPI

Linux

  • SoLoud::ALSA
  • SoLoud::PulseAudio / SoLoud (default)
  • SoLoud::JACK

macOS

  • SoLoud::CoreAudio / SoLoud (default)

Examples

The following highlight some basic examples of using the Audio modules.

See BRL.Audio for more detailed examples of TSound and TChannel usage.

Listing Drivers

Output the names of available audio drivers on the current platform.

SuperStrict

Framework audio.AudioMiniAudio
Import BRL.StandardIO

Local drivers:String[] = AudioDrivers()

Print "Available Audio Drivers : "
For Local i:Int = 0 Until drivers.length
	Print "~t" + drivers[i]
Next

Playing a Sound

SuperStrict

Framework audio.AudioMiniAudio

Local sound:TSound = LoadSound("crash.ogg")
Local channel:TChannel = PlaySound(sound)

Repeat
    Delay 100
Until Not channel.Playing()

Streaming a Sound

SuperStrict

Framework audio.AudioMiniAudio

Local sound:TSound = LoadSound("music.ogg", SOUND_STREAM)
Local channel:TChannel = PlaySound(sound)

Repeat
    Delay 100
Until Not channel.Playing()