just_audio_engine 1.1.0
just_audio_engine: ^1.1.0 copied to clipboard
Game audio for Flutter: sound effects, music, streams and 3D sound, worked out in Dart and played natively by XAudio2, AVAudioEngine, OpenAL Soft, SoundPool and Web Audio.
1.1.0 #
3D audio, worked out once in Dart and the same on every platform; Linux builds; and fixes on every platform.
3D audio #
AudioSpatialsays how a 3-D sound is heard: full volume withinminDistance, silent beyondmaxDistance, faded between byAudioRolloff(inverse,linear,none);dopplerLevel(pitch from how fast the sound and the listener move, atAudioEngine.speedOfSound);farCutoff(a low-pass that muffles it with distance).AudioSpatial.mixworks out a sound's volume, pan, pitch and cutoff from a listener — public, for tools and tests.playSfx(position3d:, spatial:)places a sound from its first sample (it used to start centred and full, and move a message later).updateSfxPositionandsetListener3Dtake effect at the nextupdate, which places every 3-D sound and sends what changed in one platform call (AudioBackend.setVoiceMixes), instead of one call per sound per frame.update({dt})takes the frame's time for velocities;setSfxSpatialchanges a playing sound's settings.- The platforms' own 3-D engines are gone (X3DAudio, AVAudioEnvironmentNode, OpenAL positions, the web's PannerNode): every platform now pans at equal power, folds a stereo file to mono for a 3-D sound (not Android), and has a low-pass on 3-D sounds (not Android). Before, Windows ignored the listener and reset pitch on every move, macOS and iOS never placed a sound, Android panned by x alone, and Linux attenuated even music by where the listener stood.
Playback #
playSfx(channel:)plays on any channel, with its volume (and, on the web, its bus); every sound effect used to play onsfx.- Master volume is applied once, by the platform (it was applied two or three times); channel volumes once, in Dart (the web applied them twice). A sound played while muted is heard after unmute.
- A sound effect that plays to its end, or is evicted for another, is forgotten (
isSfxPlaying); finished clips used to stay forever, and a paused one could be dropped. - Audio from a package's assets plays: a path like
packages/<name>/sfx/jump.wavis used as the asset key it already is, on every backend, instead of being read asassets/packages/…. Asset Store items ship their sounds this way. setLoopworks on a sound that is playing on Windows, iOS and macOS (it was only kept for the next play): set to loop, it carries on past its end; set back, it ends after the pass that is playing.cancelFadeSfx/cancelFadeMusicstop a fade on every native platform; they threwMissingPluginExceptionthere. A new fade on a voice also stops the one already running instead of fighting it.- A hot restart no longer crashes the app or leaves the last session's sounds playing. The native player outlives the Dart isolate, and a restarted app initializes it again without having disposed it: every platform now disposes the old session first (on Windows a second XAudio2 engine was released under live voices, crashing the next dispose; on Linux a second poller thread was
std::terminate). - With no audio plugin (a test, a headless run) nothing loads, plays or throws, and a sound asked for later does not try to start the backend again; a method a platform's plugin does not have is a no-op there instead of an exception in the game.
isInitializedsays whether the backend has started. stopAllSfxand the channel-volume update are one platform call each, not one per voice.
Platforms #
- Updates the minimum supported SDK version to Flutter 3.44/Dart 3.12.
- Windows: pitch and speed no longer overwrite each other (the rate is their product); pan works on a device with more than two channels; the voice's volume no longer carries the master volume too.
- macOS and iOS: sounds load — assets are looked up in
flutter_assetsthroughFlutterDartProject.lookupKey(forAsset:), as Android and Windows already did, instead of in the app bundle's own resources, where they never are. The volume is no longer squared, a fade-in is heard, and a sound's audio nodes are let go when it ends (they were only freed bystop). iOS builds again: the player referred to a class from another plugin (FlutterLocalNotificationsPlugin). - Android: migrates to built-in Kotlin — the plugin no longer applies the Kotlin Gradle plugin, which future Flutter versions refuse to build; it builds with AGP 9.1 and Kotlin 2.4, in apps with
android.builtInKotlinon or off.loadSourceanswers once SoundPool has decoded the sound (a sound played straight after loading — the first play of every sound effect — was silent, "sample not READY"). Changing a voice's volume or the master volume no longer resets its pan, pitch × speed is honoured, a finished sound effect sendsvoiceEnded, fades no longer queue behind each other, and the unused media3 dependencies are gone. - Linux builds: its public header was missing and it did not compile; it now does, and plays assets (it cut their
assets/prefix), with HRTF off so it pans like every other platform. - Web: clearing a voice's effects no longer silences it. Depends on
flutter_web_plugins: an app using the package on the web without it failed to build (the generated plugin registrant imports it).
Breaking #
AudioBackend:setVoiceMixes,playVoice(spatial:, lowPass:);setVoice3DPositionandsetListener3Dare gone, as isAudioClip.set3DPosition.- Native method channel:
playtakesspatialandlowPass; newsetVoiceMixes,setVolumes,stopMany;set3DPositionandsetListener3Dare gone.
1.0.1 #
- Shifted memory management responsibilities to the
just_memorypackage for cleaner separation of concerns and improved maintainability.
1.0.0 #
- Initial release of
just_audio_engine— high-performance audio processing pipeline forjust_game_engine. - Multi-platform support with platform-native backends:
- iOS / macOS — AVAudioEngine
- Windows — XAudio2
- Linux — OpenAL Soft
- Android — Oboe / SoundPool
- Web — Web Audio API (
dart:js_interop, no WASM required)
AudioEnginecentral facade: initialise, play, pause, resume, stop, and dispose audio from a single object.- Five logical audio channels:
master,music,sfx,voice, andambient. - Per-channel and master volume control; global mute/unmute.
AudioBus/AudioBusGraphfor named mixer-bus routing with per-bus volume.AudioCliplifecycle management withAudioState(stopped,playing,paused).AudioStreamfor streaming long-form audio without full preload.SoundEffectManagerandMusicManagerhigh-level helpers.VoicePoolfor efficient voice reuse and limiting concurrent playback.- 3D spatial audio via
Audio3DPositionandAudio3DListener(position, forward, up vectors). - DSP effects pipeline —
AudioEffectsupports:reverb,lowpass,highpass,bandpass,eq,distortion,chorus,delay. - Asset-path source cache to avoid redundant backend loads.
AudioEngine.withBackend()constructor for injecting a test double backend.