# Audio (sound, music) on the web, sound API improvements (arbitrary channels, float frequency etc.)

**URL:** https://forum.castle-engine.io/t/audio-sound-music-on-the-web-sound-api-improvements-arbitrary-channels-float-frequency-etc/2150
**Category:** News
**Created:** [May 15, 2026, 7:18am UTC](https://forum.castle-engine.io/t/audio-sound-music-on-the-web-sound-api-improvements-arbitrary-channels-float-frequency-etc/2150 "2026-05-15T07:18:19Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)
#### Post date: [May 15, 2026, 7:18am UTC](https://forum.castle-engine.io/t/audio-sound-music-on-the-web-sound-api-improvements-arbitrary-channels-float-frequency-etc/2150/1 "2026-05-15T07:18:19Z")

</div>

| [![game_3d_sounds example](https://forum.castle-engine.io/uploads/default/original/2X/2/27f041dee18feb98e81c0587d643a8024122d28a.png)](https://castle-engine.io/wp/wp-content/uploads/2026/05/game_3d_sounds.png "game\_3d\_sounds example") |
| [![play_sounds example](https://forum.castle-engine.io/uploads/default/original/2X/a/a1ce029d0d2f689369d6a75e111c9f8a1971a582.png)](https://castle-engine.io/wp/wp-content/uploads/2026/05/play_sounds.png "play\_sounds example") |

We have implemented audio playback on the [web](https://castle-engine.io/web). Underneath we use [WebAudio API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API) but you don’t really need to know anything about it — just use [Castle Game Engine sound API and components](https://castle-engine.io/sound) and everything will work on the web.

Try these examples (links below lead to ready builds — they should work out-of-the-box in your browser):

- [Platformer game](https://castle-engine.io/web-demos/examples/2d_games/platformer) ([Source code](https://github.com/castle-engine/castle-engine/tree/master/examples/2d_games/platformer))

- [Play Sounds](https://castle-engine.io/web-demos/examples/audio/play_sounds/) ([Source code](https://github.com/castle-engine/castle-engine/tree/master/examples/audio/play_sounds))

- [3D Sound Demo](https://castle-engine.io/web-demos/examples/audio/game_3d_sound/) ([Source code](https://github.com/castle-engine/castle-engine/tree/master/examples/audio/game_3d_sound))

We have documented some [important notes about WebAudio here](https://castle-engine.io/web#audio), a short recap:

- Audio playback will be in a _suspended_ state when loading the page in modern web browsers. Audio starts in response to _user interaction_ with a page, like clicking any button. You can solve it also by putting your web application inside an `iframe` with `allow="autoplay"`, which is done e.g. by wrapper generated for [HTML games on itch.io](https://itch.io/).

- _OggVorbis_ and other formats support relies on the sound decoding support on the browser side. The exception is WAV format support, which we decode on the engine side.

We also did a few improvements around the sound formats API, which benefits all platforms by improving our cross-platform API.

- The old `TSoundDataFormat` enum (with 4 values: mono 8-bit, stereo 8-bit, mono 16-bit, stereo 16-bit) is now gone. It was needlessly limiting us to 4 arbitrary combinations of channels/format.

- We expose new property `TCastleSound.Channels`, as `Cardinal`. This can express sound files with more than 2 channels, like _Quadraphonic_. Already playable by some backends, like [FMOD](https://castle-engine.io/fmod) and new [WebAudio](https://castle-engine.io/web). Our [OpenAL](https://castle-engine.io/openal) could also play them in the future, see [extensions to provide surround sound buffer formats](https://github.com/kcat/openal-soft/blob/83ea7236c6f23fc98e2b62eb9c5b3abfd4b2be86/include/AL/alext.h#L120).

- We have an internal sound sample format (not exposed by public API), which describes just _formats we decode on the engine side right now_. It’s right now just _pcm 8-bit (unsigned)_ or _pcm 16-bit (signed)_ but can be easily extended. Moreover, it is now only used when we decode on the engine side — because some backends ([FMOD](https://castle-engine.io/fmod) and [WebAudio](https://castle-engine.io/web)) are capable of decompressing + playing without passing through our engine, so are not limited to these formats. E.g. [FMOD can also use float sound data](https://www.fmod.com/docs/2.03/api/core-api-sound.html#fmod_sound_format).

- Sound frequency in `TCastleSound.Frequency` type changed from `Cardinal` to `Single`. This again matches better full _FMOD_ and _WebAudio_ backends capabilities. Prefer to express it as `TSoundFrequency` type, in case in the future we need to upgrade this to `Double`.

- We tested and documented that some backends (again _FMOD_ and _WebAudio_) [support more sound formats (like mp3 and flac)](https://castle-engine.io/sound#format).

We hope you like our work and we [appreciate your support on Patreon](https://www.patreon.com/c/castleengine)!

---

<div class="post-metadata">

### Author: ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)
#### Post date: [May 15, 2026, 7:25am UTC](https://forum.castle-engine.io/t/audio-sound-music-on-the-web-sound-api-improvements-arbitrary-channels-float-frequency-etc/2150/2 "2026-05-15T07:25:16Z")

</div>


