or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

global-audio.mdindex.mdsound-playback.mdspatial-audio.md
tile.json

global-audio.mddocs/

Global Audio Control

The global Howler instance provides centralized control over the audio system, including global volume management, codec detection, and audio context lifecycle management.

Capabilities

Global Volume Control

Get or set the global volume for all sounds currently playing or will be played in the future.

/**
 * Get/set the global volume for all sounds
 * @param vol - Volume from 0.0 to 1.0 (optional)
 * @returns Current volume if no parameter provided, otherwise returns Howler instance
 */
Howler.volume(vol?: number): Howler | number;

Usage Examples:

import { Howler } from "howler";

// Get current global volume
const currentVolume = Howler.volume(); // returns number

// Set global volume to 50%
Howler.volume(0.5);

// Chain global volume setting
Howler.volume(0.8).mute(false);

Global Mute Control

Mute or unmute all sounds globally while preserving individual volume settings.

/**
 * Handle muting and unmuting globally
 * @param muted - True to mute all sounds, false to unmute
 * @returns Howler instance for chaining
 */
Howler.mute(muted: boolean): Howler;

Usage Examples:

// Mute all sounds
Howler.mute(true);

// Unmute all sounds
Howler.mute(false);

Global Stop Control

Stop all currently playing sounds across all Howl instances.

/**
 * Handle stopping all sounds globally
 * @returns Howler instance for chaining
 */
Howler.stop(): Howler;

Global Unload

Unload and destroy all currently loaded Howl objects, freeing memory and cleaning up audio resources.

/**
 * Unload and destroy all currently loaded Howl objects
 * @returns Howler instance for chaining
 */
Howler.unload(): Howler;

Codec Detection

Check browser support for specific audio file formats.

/**
 * Check for codec support of specific extension
 * @param ext - Audio file extension (e.g., 'mp3', 'ogg', 'wav')
 * @returns True if codec is supported, false otherwise
 */
Howler.codecs(ext: string): boolean;

Usage Examples:

// Check codec support
if (Howler.codecs('mp3')) {
  console.log('MP3 is supported');
}

if (Howler.codecs('ogg')) {
  console.log('OGG is supported');
}

// Use codec detection for source selection
const sources = [];
if (Howler.codecs('webm')) {
  sources.push('audio.webm');
}
if (Howler.codecs('mp3')) {
  sources.push('audio.mp3');
}

const sound = new Howl({ src: sources });

Global Properties

Audio Context Information

interface HowlerGlobal {
  /** Web Audio master gain node */
  readonly masterGain: GainNode | null;
  /** Boolean indicating if audio is unavailable */
  readonly noAudio: boolean;
  /** Boolean indicating if Web Audio API is being used */
  readonly usingWebAudio: boolean;
  /** Boolean for automatic audio context suspension */
  autoSuspend: boolean;
  /** Web Audio context instance */
  readonly ctx: AudioContext | null;
  /** Boolean for automatic audio unlocking on mobile */
  autoUnlock: boolean;
  /** Size of HTML5 audio pool */
  html5PoolSize: number;
  /** Current audio context state */
  readonly state: 'suspended' | 'running' | 'closed';
}

Usage Examples:

// Check audio capabilities
if (Howler.noAudio) {
  console.log('Audio is not available');
}

if (Howler.usingWebAudio) {
  console.log('Using Web Audio API');
} else {
  console.log('Using HTML5 Audio');
}

// Check audio context state
if (Howler.state === 'suspended') {
  console.log('Audio context is suspended');
}

// Configure audio pool size
Howler.html5PoolSize = 20; // Increase pool size for more concurrent sounds

// Disable auto-suspend for continuous audio applications
Howler.autoSuspend = false;

Supported Audio Formats

Howler.js automatically detects browser support for the following audio formats:

  • MP3 - Widely supported, good compression
  • OGG/Vorbis - Open format, good for Firefox
  • WAV - Uncompressed, universal support
  • AAC/M4A - Apple format, good compression
  • WEBM - Modern format with excellent compression
  • FLAC - Lossless compression
  • OPUS - Modern, efficient codec

Format Selection Strategy:

const sound = new Howl({
  src: [
    'audio.webm', // Modern browsers
    'audio.mp3',  // Fallback for older browsers
    'audio.ogg'   // Firefox fallback
  ]
});