Skip to content

Commit 4e301cd

Browse files
authored
Merge pull request #112 from ford442/claude/audit-module-format-compliance-QesFv
Refactor pattern shaders to use OpenMPT numeric note encoding
2 parents a5aa3a9 + 9cfe04b commit 4e301cd

File tree

9 files changed

+498
-149
lines changed

9 files changed

+498
-149
lines changed

components/PatternDisplay.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const isSinglePassCompositeShader = (shaderFile: string) => {
4343

4444
const isCircularLayoutShader = (shaderFile: string) => {
4545
// v0.39 and v0.40 are NOT circular (they're horizontal). v0.38 IS circular. v0.45 IS circular. v0.46 IS circular.
46-
return shaderFile.includes('v0.25') || shaderFile.includes('v0.26') || shaderFile.includes('v0.35') || shaderFile.includes('v0.37') || shaderFile.includes('v0.38') || shaderFile.includes('v0.45') || shaderFile.includes('v0.46') || shaderFile.includes('v0.47') || shaderFile.includes('v0.48') || shaderFile.includes('v0.49') || shaderFile.includes('v0.50');
46+
return shaderFile.includes('v0.25') || shaderFile.includes('v0.26') || shaderFile.includes('v0.35') || shaderFile.includes('v0.37') || shaderFile.includes('v0.38') || shaderFile.includes('v0.42') || shaderFile.includes('v0.45') || shaderFile.includes('v0.46') || shaderFile.includes('v0.47') || shaderFile.includes('v0.48') || shaderFile.includes('v0.49') || shaderFile.includes('v0.50');
4747
};
4848

4949
const shouldUseBackgroundPass = (shaderFile: string) => {
@@ -1318,7 +1318,7 @@ export const PatternDisplay: React.FC<PatternDisplayProps> = ({
13181318

13191319
deviceRef.current = device; contextRef.current = context; uniformBufferRef.current = uniformBuffer;
13201320

1321-
const isHighPrec = shaderFile.includes('v0.36') || shaderFile.includes('v0.37') || shaderFile.includes('v0.38') || shaderFile.includes('v0.39') || shaderFile.includes('v0.40') || shaderFile.includes('v0.43') || shaderFile.includes('v0.44') || shaderFile.includes('v0.45') || shaderFile.includes('v0.46') || shaderFile.includes('v0.47') || shaderFile.includes('v0.48') || shaderFile.includes('v0.49') || shaderFile.includes('v0.50');
1321+
const isHighPrec = shaderFile.includes('v0.36') || shaderFile.includes('v0.37') || shaderFile.includes('v0.38') || shaderFile.includes('v0.39') || shaderFile.includes('v0.40') || shaderFile.includes('v0.42') || shaderFile.includes('v0.43') || shaderFile.includes('v0.44') || shaderFile.includes('v0.45') || shaderFile.includes('v0.46') || shaderFile.includes('v0.47') || shaderFile.includes('v0.48') || shaderFile.includes('v0.49') || shaderFile.includes('v0.50');
13221322
const packFunc = isHighPrec ? packPatternMatrixHighPrecision : packPatternMatrix;
13231323
cellsBufferRef.current = createBufferWithData(device, packFunc(matrix, padTopChannel), GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST);
13241324

@@ -1409,7 +1409,7 @@ export const PatternDisplay: React.FC<PatternDisplayProps> = ({
14091409
console.log(`[PatternDisplay] Updating cells buffer: matrix=${matrix ? 'yes' : 'null'}, rows=${matrix?.numRows}, channels=${matrix?.numChannels}`);
14101410

14111411
if (cellsBufferRef.current) cellsBufferRef.current.destroy();
1412-
const isHighPrec = shaderFile.includes('v0.36') || shaderFile.includes('v0.37') || shaderFile.includes('v0.38') || shaderFile.includes('v0.39') || shaderFile.includes('v0.40') || shaderFile.includes('v0.43') || shaderFile.includes('v0.44') || shaderFile.includes('v0.45') || shaderFile.includes('v0.46') || shaderFile.includes('v0.47') || shaderFile.includes('v0.48') || shaderFile.includes('v0.49') || shaderFile.includes('v0.50');
1412+
const isHighPrec = shaderFile.includes('v0.36') || shaderFile.includes('v0.37') || shaderFile.includes('v0.38') || shaderFile.includes('v0.39') || shaderFile.includes('v0.40') || shaderFile.includes('v0.42') || shaderFile.includes('v0.43') || shaderFile.includes('v0.44') || shaderFile.includes('v0.45') || shaderFile.includes('v0.46') || shaderFile.includes('v0.47') || shaderFile.includes('v0.48') || shaderFile.includes('v0.49') || shaderFile.includes('v0.50');
14131413
const packFunc = isHighPrec ? packPatternMatrixHighPrecision : packPatternMatrix;
14141414
const packedData = packFunc(matrix, padTopChannel);
14151415

public/shaders/patternv0.38.wgsl

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,15 +238,18 @@ fn fs(in: VertexOut) -> @location(0) vec4<f32> {
238238
let effCmd = (in.packedB >> 8) & 255u;
239239
let effVal = in.packedB & 255u;
240240

241-
let hasNote = (note > 0u);
241+
// OpenMPT numeric encoding: 1-120 = regular notes, 121 = OFF, 122 = CUT, 123 = FADE
242+
let hasNote = (note > 0u) && (note <= 120u);
243+
let isNoteOff = (note == 121u);
244+
let isNoteCut = (note == 122u) || (note == 123u);
242245
let hasExpression = (volCmd > 0u) || (effCmd > 0u);
243246
let ch = channels[in.channel];
244247
let isMuted = (ch.isMuted == 1u);
245248

246249
let topUV = btnUV - vec2(0.5, 0.16);
247250
let topSize = vec2(0.20, 0.20);
248251
let isDataPresent = hasExpression && !isMuted;
249-
let topColorBase = vec3(0.0, 0.9, 1.0);
252+
let topColorBase = vec3(1.0, 0.65, 0.10); // amber = volume/expression indicator
250253
let topColor = topColorBase * select(0.0, 1.5 + bloom, isDataPresent);
251254
let topLed = drawChromeIndicator(topUV, topSize, topColor, isDataPresent, aa);
252255
finalColor = mix(finalColor, topLed.rgb, topLed.a);
@@ -257,7 +260,14 @@ fn fs(in: VertexOut) -> @location(0) vec4<f32> {
257260
var noteColor = vec3(0.2);
258261
var lightAmount = 0.0;
259262

260-
if (hasNote) {
263+
// Note-off / note-cut: show as dim red/orange main indicator
264+
if (isNoteOff) {
265+
noteColor = vec3(0.45, 0.05, 0.05);
266+
lightAmount = 0.6;
267+
} else if (isNoteCut) {
268+
noteColor = vec3(0.60, 0.20, 0.02);
269+
lightAmount = 0.5;
270+
} else if (hasNote) {
261271
let pitchHue = pitchClassFromIndex(note);
262272
let baseColor = neonPalette(pitchHue);
263273
let instBand = inst & 15u;

0 commit comments

Comments
 (0)