ChipVoices.cs
namespace PixelPusher;
/// <summary>Tiny play / UI blips. Full tracker stays in Chip Studio later.</summary>
public static class ChipVoices
{
static float _uiAt;
public static void Tick() => Play( "sounds/blips/tick", 0.08f );
public static void Push() => Play( "sounds/blips/push" );
public static void Jump() => Play( "sounds/blips/jump" );
public static void Land() => Play( "sounds/blips/land" );
public static void Coin() => Play( "sounds/blips/coin" );
public static void Spring() => Play( "sounds/blips/spring" );
public static void Hurt() => Play( "sounds/blips/hurt" );
public static void Clear() => Play( "sounds/blips/clear" );
public static void Hover()
{
if ( Time.Now - _uiAt < 0.08f )
return;
_uiAt = Time.Now;
Play( "sounds/blips/tick" );
}
public static void Tone( int channel, int note )
{
if ( note <= 0 )
return;
var path = channel switch
{
0 => "sounds/chip/pulse",
1 => "sounds/chip/tri",
2 => "sounds/chip/noise",
_ => "sounds/chip/drum"
};
var pitch = MathF.Pow( 2f, (note - 8) / 12f );
Play( path, 0f, pitch );
}
static void Play( string path, float cooldown = 0f, float pitch = 1f )
{
_ = cooldown;
try
{
var h = Sound.Play( path, Vector3.Zero );
if ( h.IsValid() )
{
h.ListenLocal = true;
h.SpacialBlend = 0f;
if ( pitch > 0.01f )
h.Pitch = pitch;
}
}
catch
{
// blip missing until the wav compiles
}
}
}