This commit is contained in:
Jan Racek
2026-03-24 13:00:54 +01:00
parent 53e993f58e
commit 4aa4e49424
145 changed files with 10853 additions and 2965 deletions

43
Runtime/PSXAudioSource.cs Normal file
View File

@@ -0,0 +1,43 @@
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;
}
}