Skip to content

v6.1.0

Latest

Choose a tag to compare

@zbdd zbdd released this 06 Dec 12:02
· 1 commit to main since this release

💾 Download

Installation:

npm install @pixi/sound@6.1.0

Development Build:

Documentation:

Changed

v6.0.3...v6.1.0

🚨 Behavior Change

  • Fix: Don't throw for an unknown alias or sprite by @zbdd in #378
    • An unknown alias or sprite no longer throws. play() returns null, volume(), speed() and duration() return NaN, and stop(), pause() and resume() return undefined.
  • Fix: Fade out before the window-blur pause by @zbdd in #393
    • A window blur now fades the output out over about a tenth of a second before it pauses, and the focus fades it back in. paused reads true as soon as the blur arrives.
  • Fix: Hold HTML audio played during pauseAll by @zbdd in #396
    • With HTML audio, a sound played during pauseAll() now waits for resumeAll(), as it already did with WebAudio.
  • Fix: Pause and resume HTML audio when context.paused is set by @zbdd in #397
    • With HTML audio, setting sound.context.paused now pauses and resumes the sounds that are playing.
  • Fix: Keep isPlaying false while a sound is paused by @zbdd in #409
    • isPlaying is now false while a sound is paused.
  • Fix: Hold a play into a paused sound by @zbdd in #410
    • A sound played while it is paused (pause() or paused = true) now starts paused and plays on resume(), as a sound in a paused channel does. Before, it was heard.
  • Fix: Silence sounds outside the library on close by @zbdd in #411
    • close() now also pauses sounds that aren't in the library, such as ones made with Sound.from and never added, so nothing keeps playing after it.
  • Fix: Keep the sine tone within full scale by @zbdd in #416
    • utils.sineTone() now writes a sine from -1 to 1 instead of -2 to 2, so the tone is no longer clipped and is a little quieter. Use volume to change its level.
  • Fix: Keep an app's pause made while the window is blurred by @zbdd in #420
    • pauseAll(), resumeAll() or context.paused called while the window is blurred, for example in your own blur listener, is now kept when the window gets focus again.

🎁 Added

  • Feature: Add sound channels by @zbdd in #403
    • A channel is a named group of sounds, such as music or effects, with its own volume, mute and pause. A sound joins a channel with the channel option, also in Assets data, and sound.channel(name) returns the channel, creating it the first time the name is used. The channel's volume multiplies with the sound's and the global volume, and volumeAll, muteAll and pauseAll don't change a channel's settings. A sound played into a paused channel starts paused.
    import { sound, filters } from '@pixi/sound';
    
    sound.add('theme', { url: 'theme.mp3', channel: 'music' });
    
    const music = sound.channel('music');
    
    music.volume = 0.5;
    music.muted = true;
    music.paused = true;
    music.filters = [new filters.TelephoneFilter()]; // WebAudio only
    music.stop(); // stops every sound in the channel
    music.isPlaying; // true while any sound in the channel is playing
  • Feature: Add filters to sound channels by @zbdd in #404
    • channel.filters runs a channel's sounds through its filters, then through filtersAll. WebAudio only: with HTML audio, setting it warns and does nothing.
  • Feature: Add stop and isPlaying to sound channels by @zbdd in #406
    • channel.stop() stops every sound in the channel, paused ones too. channel.isPlaying is true while any sound in the channel is playing, also while the channel is paused.
  • Feature: Add a streaming option for long sounds by @zbdd in #418
    • streaming: true starts a long sound, such as music, while it downloads, instead of after the whole file is downloaded and decoded. Volume, mute, speed, loop, pause, channels and the sound's and channel's filters still apply. A streaming sound plays one instance at a time (play() restarts it), ignores end and play filters, so a sprite plays from its start to the end of the file, and limits speed to 0.0625–16. start needs a server that supports range requests, and a file on another origin needs CORS headers.
    import { sound } from '@pixi/sound';
    import { Assets } from 'pixi.js';
    
    sound.add('music', { url: 'music.mp3', streaming: true, loop: true });
    sound.play('music');
    
    // or with Assets
    Assets.add({ alias: 'music', src: 'music.mp3', data: { streaming: true } });

🐛 Fixed

  • Chore: Allow null in the options that take it by @zbdd in #384
    • The options that already default to null (url, source, complete, loaded, end, sprite) now accept null in their types.
  • Fix: Keep an HTML sprite's end when it resumes by @zbdd in #390
  • Fix: Don't play the old volume after resumeAll by @zbdd in #395
  • Fix: Keep the HTML start when paused right after play() by @zbdd in #398
  • Fix: Don't seek a reused HTML instance to the old start by @zbdd in #399
  • Fix: End a sprite resumed after its end instead of throwing by @zbdd in #400
  • Fix: Let a start listener stop the instance by @zbdd in #401
  • Fix: Let a progress listener stop an HTML instance by @zbdd in #402
  • Fix: Disconnect cleared filters from their chain by @zbdd in #407
  • Fix: Allow a stop listener to stop its sound again by @zbdd in #412
  • Fix: Keep instance filters set while paused by @zbdd in #413
  • Fix: Stop playOnce asserting on a removed sound by @zbdd in #414
  • Fix: Stop disableAutoPause throwing without WebAudio by @zbdd in #417
  • Fix: Undo a blur pause on focus after autoPause is turned off by @zbdd in #419

🧹 Chores

  • Chore: Run the tests with Vitest in Chromium by @zbdd in #364
  • Chore: Bump shell-quote from 1.8.1 to 1.12.0 by @dependabot[bot] in #365
  • Chore: Update vulnerable dev dependencies by @zbdd in #373
  • Chore: Run the tests in Firefox too by @zbdd in #374
  • Chore: Run the tests in WebKit too by @zbdd in #375
  • Chore: Make a Firefox unlock test less flaky by @zbdd in #376
  • Chore: Update extension-scripts to 5.0.0 by @zbdd in #377
  • Chore: Mark v4 and v5 as no longer maintained by @zbdd in #379
  • Chore: Play the resume-loop tests faster by @zbdd in #380
  • Chore: Use inline type imports by @zbdd in #381
  • Chore: Use xs 5's strict tsconfig apart from strictNullChecks by @zbdd in #382
  • Chore: Fix strictNullChecks errors in filters and utils by @zbdd in #383
  • Chore: Wait for events in the instance-lifecycle tests by @zbdd in #385
  • Chore: Allow for the audio clock moving in the play test by @zbdd in #386
  • Chore: Fix strictNullChecks errors in htmlaudio by @zbdd in #387
  • Chore: Fix strictNullChecks errors in webaudio by @zbdd in #388
  • Chore: Fix strictNullChecks errors in Sound and SoundLibrary by @zbdd in #389
  • Chore: Fix strictNullChecks errors in the tests by @zbdd in #391
  • Chore: Turn on strictNullChecks by @zbdd in #392
  • Chore: Fix the README's PixiJS link and filter list by @zbdd in #394
  • Chore: Say that only the exported sound library is supported by @zbdd in #405
  • Chore: Update the example pages by @zbdd in #408
  • Fix: Make the blur-fade focus-during-fade test deterministic by @zbdd in #415