Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Compress and generate sound sprites #83

Open
furic opened this issue Aug 29, 2024 · 0 comments
Open

Feature: Compress and generate sound sprites #83

furic opened this issue Aug 29, 2024 · 0 comments

Comments

@furic
Copy link
Contributor

furic commented Aug 29, 2024

We've been using sound sprites with Hawler.js but it's great that PixiJS Sound supports it in the first place too, and we're considering switch to it. Currently, we compress and generate the sound sprites with gulp-audiosprite and a custom gulp script. It would be nice if Asset Pack could do that for us so we can automate this process.

Expected Behaviour

All raw sounds with .wav file format are in raw-assets folder, with a sps tag for example. Asset Pack packs and compresses them into merged sound files in different file formats, and a .json config file.

assetpack-sound-sprite-expect-behaviour

P.S. If Cache Buster is used, the sound files should also include the hash and update every time the raw files change.

Further Implementation (in Pixi-Sound)

This is optional but great to have so manual code can be reduced. PixiJS Sound should understand the manifest generated, and create the sound sprite from the .json config file, which is ready to be used to play the sound.

// Init the manifest
PIXI.Assets.init({ manifest });

// Load the bundle
const loadingScreenAssets = await PIXI.Assets.loadBundle('loading-screen');

// Create a new sound
const sound = PIXI.sound.Sound.from(loadingScreenAssets.sounds); // Pixi should understand it's sound sprites, and add all sprites automatically. No need to use `addSprites()`

// Use the sprite alias to play
sound.play('bgm_main');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant