What is XA Audio?
XA audio is a compressed audio format that:- Uses ADPCM compression (4:1 ratio compared to raw PCM)
- Streams directly from CD during gameplay
- Stores audio in 2336-byte Mode 2 Form 2 sectors
- Supports stereo or mono playback at various sample rates
- Interleaves multiple audio channels in a single file
XA Audio in ISO Images
XA files are mixed-mode files that require special handling:- Each sector contains a subheader defining its format
- Sectors are marked as Mode 2 Form 2 in the CD structure
- mkpsxiso properly encodes each sector based on its subheader
- Files must be in raw 2336-byte sector format
Adding XA Audio to Your ISO
Prepare XA Audio Files
Ensure your XA files are properly formatted:
- Files must be in raw 2336-byte sector format
- Must contain valid RIFF headers
- Each sector must have proper XA subheaders
- Use PlayStation SDK tools or converters to create XA files
Add Files to XML
Define XA files in your ISO project with
type="mixed":You can use
type="xa" as an alias for type="mixed". Both are functionally identical.XA File Format Details
Sector Structure
Each XA sector contains:- Subheader (8 bytes): Defines sector type and audio parameters
- Audio Data (2324 bytes): Compressed ADPCM samples
- EDC (4 bytes): Error detection code
Subheader Fields
The XA subheader specifies:- File Number: Which file this sector belongs to
- Channel Number: Which audio channel (for interleaving)
- Submode: Audio format and sector flags
- Coding Info: Sample rate, stereo/mono, bits per sample
Form 2 Encoding
XA audio uses Mode 2 Form 2 sectors:- No error correction (ECC)
- Optional error detection (EDC)
- More space for audio data
- Higher throughput for streaming
EDC Configuration
Control error detection code generation:If
xa_edc is not specified, it defaults to true. Most PlayStation games use EDC for better reliability.Channel Interleaving
XA files can contain multiple interleaved audio channels:- Multiple music tracks in one file
- Left/right channel separation
- Background music + sound effects
Creating XA Audio Files
From PlayStation SDK
Use official tools from the PsyQ SDK:Third-Party Tools
Several community tools can create XA files:- PSound: PlayStation sound tool
- jPSXdec: Extract and convert XA from disc images
- psximager: Alternative ISO creation with XA support
Extracting from Existing Games
Use dumpsxiso to extract XA files:- Used as reference for format
- Modified with hex editors
- Reused in your own projects
Common XA Audio Patterns
Background Music
Voice Acting
Interleaved Multi-Channel
Troubleshooting
RIFF Header Errors
If mkpsxiso reports RIFF header errors:- Verify files are genuine XA format, not WAV files renamed to .xa
- Check that files haven’t been corrupted during transfer
- Re-export from original source
Subheader Validation Failures
If subheader checks fail:- Files may be improperly ripped from a disc
- Sectors may not have valid XA subheaders
- Files might be in the wrong sector format
Audio Stuttering or Glitches
If audio playback has issues:- Check file placement: Move XA files closer to related game data
- Verify encoding: Ensure proper sample rate and format
- Test on hardware: Emulator behavior may differ from real hardware
Wrong Audio Playing
If the wrong audio plays:- Check channel numbers in subheaders
- Verify your game code is requesting the correct file
- Ensure file names match what the game expects
Performance Considerations
Streaming Reliability
For smooth playback:- Place frequently used XA files early on the disc
- Group related audio files together
- Avoid placing XA files after large data files
Seek Time Optimization
Multiple XA Files vs. Single Large File
Consider:- Multiple files: Easier to manage, better for selective loading
- Single interleaved file: Better streaming performance, less seeking
XA Audio Best Practices
Next Steps
- Learn about STR Video for full-motion video
- Explore CDDA Audio for CD-quality music
- Optimize LBA placement for all streaming media