Initial audio support

This commit is contained in:
2026-05-04 14:32:29 +10:00
parent 44316b29c2
commit f836c53d10
17 changed files with 977 additions and 10 deletions

View File

@@ -16,6 +16,11 @@ struct ShaderContext
float bypass;
int sourceHistoryLength;
int temporalHistoryLength;
float2 audioRms;
float2 audioPeak;
float audioMonoRms;
float audioMonoPeak;
float4 audioBands;
};
cbuffer GlobalParams
@@ -28,15 +33,31 @@ cbuffer GlobalParams
float gBypass;
int gSourceHistoryLength;
int gTemporalHistoryLength;
float2 gAudioRms;
float2 gAudioPeak;
float gAudioMonoRms;
float gAudioMonoPeak;
float4 gAudioBands;
{{PARAMETER_UNIFORMS}}};
Sampler2D<float4> gVideoInput;
Sampler2D<float4> gAudioData;
{{SOURCE_HISTORY_SAMPLERS}}{{TEMPORAL_HISTORY_SAMPLERS}}{{TEXTURE_SAMPLERS}}
float4 sampleVideo(float2 tc)
{
return gVideoInput.Sample(tc);
}
float4 sampleAudioWaveform(float x)
{
return gAudioData.Sample(float2(saturate(x), 0.25));
}
float4 sampleAudioSpectrum(float x)
{
return gAudioData.Sample(float2(saturate(x), 0.75));
}
float4 sampleSourceHistory(int framesAgo, float2 tc)
{
if (gSourceHistoryLength <= 0)
@@ -83,6 +104,11 @@ float4 fragmentMain(FragmentInput input) : SV_Target
context.bypass = gBypass;
context.sourceHistoryLength = gSourceHistoryLength;
context.temporalHistoryLength = gTemporalHistoryLength;
context.audioRms = gAudioRms;
context.audioPeak = gAudioPeak;
context.audioMonoRms = gAudioMonoRms;
context.audioMonoPeak = gAudioMonoPeak;
context.audioBands = gAudioBands;
float4 effectedColor = {{ENTRY_POINT_CALL}};
float mixValue = clamp(gBypass > 0.5 ? 0.0 : gMixAmount, 0.0, 1.0);
return lerp(context.sourceColor, effectedColor, mixValue);