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: Add audio packing #21

Open
Zyie opened this issue Feb 17, 2023 · 3 comments
Open

Feature: Add audio packing #21

Zyie opened this issue Feb 17, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@Zyie
Copy link
Member

Zyie commented Feb 17, 2023

Add support for converting audio into audio sprites

@Zyie Zyie added the enhancement New feature or request label Feb 17, 2023
@Zyie Zyie changed the title Add audio packing Feature: Add audio packing Feb 17, 2023
@reececomo
Copy link

Could we wrap tonistiigi/audiosprite?

@reececomo
Copy link

reececomo commented Jun 19, 2024

cc @Zyie

Have published a little wrapper plugin for audiosprite: assetpack-plugin-audiosprite

npm install assetpack-plugin-audiosprite --save-dev

Basic usage

// .assetpack.js
const { audiosprite } = require('assetpack-plugin-audiosprite');

module.exports = {
  audiosprite: audiosprite()
};

Example usage

Input files

raw-assets/
    my_sounds{sfx}/
        cry.m4a
        laugh.wav
        sneeze.mp3
        whine.mp3
        yell.aiff

.assetpack.js config

  audiosprite: audiosprite({
    tags: { audiosprite: 'sfx' }, // default: 'audiosprite'
    audiosprite: {
      // configure 'audiosprite' options:
      export: 'mp3,ogg',
      bitrate: 64,
      samplerate: 32_000
    }
  }),

Output:

assets/
    my_sounds/
        my_sounds.json
        my_sounds.mp3
        my_sounds.ogg

@reececomo
Copy link

reececomo commented Jun 19, 2024

Here's a quick extension to load the files audiospriteAsset.ts (pixi v7, but should be same/pretty close to v8)

Usage

// register loader
extensions.add(audiospriteAsset);
// load sprites
const mySounds = await Assets.load('assets/sfx.json');
mySounds.play('bark');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants