Files
secretsplash/Runtime/PSXAudioSource.cs
Jan Racek 4aa4e49424 psst
2026-03-24 13:00:54 +01:00

44 lines
1.4 KiB
C#

using UnityEngine;
namespace SplashEdit.RuntimeCode
{
/// <summary>
/// Pre-converted audio clip data ready for splashpack serialization.
/// Populated by the Editor (PSXSceneExporter) so Runtime code never
/// touches PSXAudioConverter.
/// </summary>
public struct AudioClipExport
{
public byte[] adpcmData;
public int sampleRate;
public bool loop;
public string clipName;
}
/// <summary>
/// Attach to a GameObject to include an audio clip in the PS1 build.
/// At export time, the AudioClip is converted to SPU ADPCM and packed
/// into the splashpack binary. Use Audio.Play(clipIndex) from Lua.
/// </summary>
[AddComponentMenu("PSX/Audio Source")]
public class PSXAudioSource : MonoBehaviour
{
[Tooltip("Name used to identify this clip in Lua (Audio.Play(\"name\"))." )]
public string ClipName = "";
[Tooltip("Unity AudioClip to convert to PS1 SPU ADPCM format.")]
public AudioClip Clip;
[Tooltip("Target sample rate for the PS1 (lower = smaller, max 44100).")]
[Range(8000, 44100)]
public int SampleRate = 22050;
[Tooltip("Whether this clip should loop when played.")]
public bool Loop = false;
[Tooltip("Default playback volume (0-127).")]
[Range(0, 127)]
public int DefaultVolume = 100;
}
}