pixi-effects 0.16.0 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -536,6 +536,23 @@ declare function react(env: AudioEnvelope, options: ReactOptions): Keyframe[];
536
536
  */
537
537
  declare function musicEnvelope(music: MusicOptions, options?: EnvelopeOptions): Promise<AudioEnvelope>;
538
538
 
539
+ /**
540
+ * The sound of `music` as a Web Audio `AudioBuffer` you can play yourself (a music box page, a jingle on a button, your own player):
541
+ *
542
+ * ```js
543
+ * const buffer = await musicBuffer({ bpm: 96, tracks: [{ inst: 'keys', notes: 'Cmaj7:4 Am7:4' }] });
544
+ * const src = audioContext.createBufferSource(); src.buffer = buffer; src.connect(audioContext.destination); src.start();
545
+ * ```
546
+ *
547
+ * `sampleRate` defaults to 44100; `duration` (seconds) cuts it or, with `loop: true`, repeats the music up to it. Warnings are printed
548
+ * like for an audio layer; throws, saying why, when the score cannot play (no `bpm`, no notes). Async: the synthesiser is its own chunk.
549
+ */
550
+ declare function musicBuffer(music: MusicOptions, options?: {
551
+ sampleRate?: number;
552
+ duration?: number;
553
+ loop?: boolean;
554
+ }): Promise<AudioBuffer>;
555
+
539
556
  interface DeckPage {
540
557
  /** The page's name: shown by the Presenter, and in the stops list. */
541
558
  name?: string;
@@ -667,4 +684,4 @@ interface WithFadeOptions {
667
684
  */
668
685
  declare function withFade<T extends SequenceCommon>(spec: T, opts: WithFadeOptions): T;
669
686
 
670
- export { type AnimateTextOptions, type AnimateTextTween, type AudioEnvelope, type AudioEnvelopeSource, CameraSequenceSpec, CompositionSpec, type DeckOptions, type DeckPage, type DeckResult, type DeckTransition, type EnvelopeOptions, type FollowPathOptions, ImageSequenceSpec, type KenBurnsOptions, Keyframe, type MeasureStyle, MusicOptions, type OrbitOptions, type ParticlesOptions, Props, type ReactOptions, type ReactProp, SequenceCommon, type SequenceCtor, SequenceSpec, type SplitOptions, type StaggerOptions, type TextPiece, type TextPreset, TextSequenceSpec, type TextSize, TransitionSpec, type WiggleOptions, type WiggleProp, type WithFadeOptions, animateText, audioEnvelope, bpmEnvelope, computeEnvelope, deck, followPath, kenBurns, measureText, musicEnvelope, noise, orbit, particles, rand, random, react, registerSequenceType, splitText, stagger, wiggle, withFade };
687
+ export { type AnimateTextOptions, type AnimateTextTween, type AudioEnvelope, type AudioEnvelopeSource, CameraSequenceSpec, CompositionSpec, type DeckOptions, type DeckPage, type DeckResult, type DeckTransition, type EnvelopeOptions, type FollowPathOptions, ImageSequenceSpec, type KenBurnsOptions, Keyframe, type MeasureStyle, MusicOptions, type OrbitOptions, type ParticlesOptions, Props, type ReactOptions, type ReactProp, SequenceCommon, type SequenceCtor, SequenceSpec, type SplitOptions, type StaggerOptions, type TextPiece, type TextPreset, TextSequenceSpec, type TextSize, TransitionSpec, type WiggleOptions, type WiggleProp, type WithFadeOptions, animateText, audioEnvelope, bpmEnvelope, computeEnvelope, deck, followPath, kenBurns, measureText, musicBuffer, musicEnvelope, noise, orbit, particles, rand, random, react, registerSequenceType, splitText, stagger, wiggle, withFade };
package/dist/index.d.ts CHANGED
@@ -536,6 +536,23 @@ declare function react(env: AudioEnvelope, options: ReactOptions): Keyframe[];
536
536
  */
537
537
  declare function musicEnvelope(music: MusicOptions, options?: EnvelopeOptions): Promise<AudioEnvelope>;
538
538
 
539
+ /**
540
+ * The sound of `music` as a Web Audio `AudioBuffer` you can play yourself (a music box page, a jingle on a button, your own player):
541
+ *
542
+ * ```js
543
+ * const buffer = await musicBuffer({ bpm: 96, tracks: [{ inst: 'keys', notes: 'Cmaj7:4 Am7:4' }] });
544
+ * const src = audioContext.createBufferSource(); src.buffer = buffer; src.connect(audioContext.destination); src.start();
545
+ * ```
546
+ *
547
+ * `sampleRate` defaults to 44100; `duration` (seconds) cuts it or, with `loop: true`, repeats the music up to it. Warnings are printed
548
+ * like for an audio layer; throws, saying why, when the score cannot play (no `bpm`, no notes). Async: the synthesiser is its own chunk.
549
+ */
550
+ declare function musicBuffer(music: MusicOptions, options?: {
551
+ sampleRate?: number;
552
+ duration?: number;
553
+ loop?: boolean;
554
+ }): Promise<AudioBuffer>;
555
+
539
556
  interface DeckPage {
540
557
  /** The page's name: shown by the Presenter, and in the stops list. */
541
558
  name?: string;
@@ -667,4 +684,4 @@ interface WithFadeOptions {
667
684
  */
668
685
  declare function withFade<T extends SequenceCommon>(spec: T, opts: WithFadeOptions): T;
669
686
 
670
- export { type AnimateTextOptions, type AnimateTextTween, type AudioEnvelope, type AudioEnvelopeSource, CameraSequenceSpec, CompositionSpec, type DeckOptions, type DeckPage, type DeckResult, type DeckTransition, type EnvelopeOptions, type FollowPathOptions, ImageSequenceSpec, type KenBurnsOptions, Keyframe, type MeasureStyle, MusicOptions, type OrbitOptions, type ParticlesOptions, Props, type ReactOptions, type ReactProp, SequenceCommon, type SequenceCtor, SequenceSpec, type SplitOptions, type StaggerOptions, type TextPiece, type TextPreset, TextSequenceSpec, type TextSize, TransitionSpec, type WiggleOptions, type WiggleProp, type WithFadeOptions, animateText, audioEnvelope, bpmEnvelope, computeEnvelope, deck, followPath, kenBurns, measureText, musicEnvelope, noise, orbit, particles, rand, random, react, registerSequenceType, splitText, stagger, wiggle, withFade };
687
+ export { type AnimateTextOptions, type AnimateTextTween, type AudioEnvelope, type AudioEnvelopeSource, CameraSequenceSpec, CompositionSpec, type DeckOptions, type DeckPage, type DeckResult, type DeckTransition, type EnvelopeOptions, type FollowPathOptions, ImageSequenceSpec, type KenBurnsOptions, Keyframe, type MeasureStyle, MusicOptions, type OrbitOptions, type ParticlesOptions, Props, type ReactOptions, type ReactProp, SequenceCommon, type SequenceCtor, SequenceSpec, type SplitOptions, type StaggerOptions, type TextPiece, type TextPreset, TextSequenceSpec, type TextSize, TransitionSpec, type WiggleOptions, type WiggleProp, type WithFadeOptions, animateText, audioEnvelope, bpmEnvelope, computeEnvelope, deck, followPath, kenBurns, measureText, musicBuffer, musicEnvelope, noise, orbit, particles, rand, random, react, registerSequenceType, splitText, stagger, wiggle, withFade };
package/dist/index.js CHANGED
@@ -3249,6 +3249,23 @@ async function musicEnvelope(music, options = {}) {
3249
3249
  return { ...env, beats: musicBeatTimes(m, env.duration), bpm: Math.round(new TempoMap(m.tempo).bpmAt(0) * 100) / 100 };
3250
3250
  }
3251
3251
 
3252
+ // src/audio/musicBuffer.ts
3253
+ async function musicBuffer(music, options = {}) {
3254
+ const { resolveMusic, renderMusic, musicLength } = await import('./music-4HDFULNR.js');
3255
+ const messages = [];
3256
+ const m = resolveMusic(music, "musicBuffer()", (msg) => messages.push(msg));
3257
+ if (!m) throw new Error(`pixi-effects: musicBuffer(): ${messages.join(" ") || "the music has nothing to play"}`);
3258
+ for (const msg of messages) console.warn(msg);
3259
+ const sampleRate = options.sampleRate ?? 44100;
3260
+ const length = options.duration ?? musicLength(m);
3261
+ if (!(Number.isFinite(length) && length > 0)) throw new Error(`pixi-effects: musicBuffer(): duration must be a positive number of seconds, got ${String(options.duration)}`);
3262
+ const [left, right] = renderMusic(m, sampleRate, length, !!options.loop);
3263
+ const buffer = typeof AudioBuffer === "function" ? new AudioBuffer({ length: left.length, sampleRate, numberOfChannels: 2 }) : new OfflineAudioContext(2, left.length, sampleRate).createBuffer(2, left.length, sampleRate);
3264
+ buffer.copyToChannel(left, 0);
3265
+ buffer.copyToChannel(right, 1);
3266
+ return buffer;
3267
+ }
3268
+
3252
3269
  // src/presets/deck.ts
3253
3270
  var PAGE_KEYS = ["name", "duration", "sequences", "stops", "notes", "advance", "initial", "keyframes", "filters", "filterArea", "blendMode", "mask", "maskInverted"];
3254
3271
  var DECK_KEYS = ["pages", "transition", "width", "height", "frameRate", "background", "canvas", "assets", "poster", "motionBlur", "loader"];
@@ -3330,6 +3347,6 @@ function withFade(spec, opts) {
3330
3347
  return spec;
3331
3348
  }
3332
3349
 
3333
- export { Movie, animateText, audioEnvelope, bpmEnvelope, computeEnvelope, deck, dismissLoader, failLoader, followPath, kenBurns, measureText, musicEnvelope, normalizeStops, orbit, particles, pictureStops, react, resolveLoader, splitText, stagger, wiggle, withFade };
3350
+ export { Movie, animateText, audioEnvelope, bpmEnvelope, computeEnvelope, deck, dismissLoader, failLoader, followPath, kenBurns, measureText, musicBuffer, musicEnvelope, normalizeStops, orbit, particles, pictureStops, react, resolveLoader, splitText, stagger, wiggle, withFade };
3334
3351
  //# sourceMappingURL=index.js.map
3335
3352
  //# sourceMappingURL=index.js.map