Audio¶
SplashEdit converts Unity AudioClips to PS1 SPU ADPCM format for playback on real hardware.
Adding Audio¶
- Add a
PSXAudioClipcomponent to any GameObject in your scene - Assign a Unity AudioClip
- Configure settings
You can put multiple PSXAudioClip components on the same GameObject or spread them across different objects - placement doesn't matter, they're all collected at export time.
PSXAudioClip Settings¶
| Field | Default | Description |
|---|---|---|
| Clip Name | (required) | Unique identifier used in Lua. Audio.Play("clip_name") |
| Clip | (required) | Unity AudioClip source |
| Sample Rate | 22050 | Target sample rate in Hz (8000-44100). Lower = smaller, worse quality. |
| Loop | false | Whether the clip loops when played |
| Default Volume | 100 | Default playback volume (0-127) |
Playing Audio from Lua¶
-- Play by name with volume and pan
Audio.Play("collect", 127, 64) -- full volume, centered
Audio.Play("music", 80, 0) -- 80 volume, left channel
Audio.Play("ambience", 60, 127) -- 60 volume, right channel
-- Audio.Play returns a channel number (0-23) or -1 if all voices are busy
local ch = Audio.Play("music", 100, 64)
-- Find clip index by name
local idx = Audio.Find("collect")
-- Stop a specific channel
Audio.Stop(ch)
-- Adjust volume and pan mid-playback
Audio.SetVolume(ch, 50, 64)
-- Stop everything
Audio.StopAll()
PS1 Audio Constraints¶
| Resource | Limit |
|---|---|
| SPU RAM | 512KB total for all audio samples |
| Hardware voices | 24 simultaneous channels |
| Format | ADPCM (lossy compression) |
Voice limit
Audio.Play returns -1 if all 24 hardware voices are busy. Check the return value if you need to know whether playback started.
Volume and Pan¶
| Parameter | Range | Description |
|---|---|---|
| Volume | 0-128 | 0 = silent, 128 = maximum |
| Pan | 0-127 | 0 = full left, 64 = center, 127 = full right |
Default values if not specified: volume 100, pan 64 (center).
CD-DA Music¶
For longer music tracks, you can use CD-DA (Red Book audio) instead of SPU ADPCM. CD-DA tracks are burned directly onto the disc as standard audio tracks, so they do not consume any SPU RAM.
Setup¶
- Open the SplashEdit Control Panel (Ctrl+Shift+L)
- Go to the Music (CD-DA) tab
- Add audio clips (MP3, WAV) using the + Add Audio Clip button or by dragging files from the Project window
- Reorder tracks with the arrow buttons. Track numbering starts at 2 because the data track is always track 1.
(Currently you may experience issues. Please import the audio file into your Assets folder first before assigning it.)
Playing CD-DA from Lua¶
-- Play track 2 (the first audio track on the disc)
Audio.PlayCDDA(2)
-- Pause and resume
Audio.PauseCDDA()
Audio.ResumeCDDA()
-- Stop playback
Audio.StopCDDA()
-- Set volume (left, right)
Audio.SetCDDAVolume(16383, 16383)
-- Query playback position
Audio.TellCDDA(function(position)
Debug.Log("Position: " .. position)
end)
Limitations¶
| Constraint | Details |
|---|---|
| ISO builds only | CD-DA does not work via PCdrv. You must build an ISO. |
| Reading pauses audio | The PS1 cannot read data from the disc and play CD-DA at the same time. Scene loads will interrupt playback. |
| One track at a time | Only one CD-DA track can play. Starting a new track stops the previous one. |
ISO requirement
CD-DA tracks are embedded in the disc image during ISO builds. They will not play when using the Emulator or Real Hardware build targets.
Tips¶
Sample rate
11025 Hz is fine for short sound effects (clicks, hits, pickups). 22050 Hz is good for voice and music. 44100 Hz uses double the SPU RAM of 22050 Hz - only use it if quality really matters.
Keep clips short
SPU RAM is only 512KB. A 5-second clip at 22050 Hz uses roughly 20KB in ADPCM. A 30-second music track uses roughly 120KB. Budget carefully.
Audio in cutscenes
Cutscenes have built-in audio events that trigger at specific frames. Use those for synchronized audio instead of playing clips from Lua callbacks.
CD-DA for background music
Use SPU ADPCM for short sound effects and CD-DA for background music. This keeps SPU RAM free for more sound effects while still having full quality music.