feat: emit per-note matrix trigger for glow

This commit is contained in:
clement
2026-06-28 17:56:58 +02:00
parent df2bceca74
commit f9d64cd7a5
2 changed files with 27 additions and 2 deletions
+12 -2
View File
@@ -44,7 +44,7 @@
// NOTE: voices that compute \freq via Pfunc (ignoring \octave) will not respond
// to the octave variation — acceptable for v1; tune the palette at the live gate.
// Single function so all variation logic lives in one place.
~matVariation = { |name, color|
~matVariation = { |name, color, vi = 0|
(color == 0).if({ nil }, {
var base = ~matBaseFor.(name);
base.notNil.if({
@@ -60,6 +60,10 @@
spec.notNil.if({
Pchain(
Pbind(
\matGlow, Pfunc { |e|
~matEmitTrig.(vi, (e[\amp] ? spec[\amp]).clip(0, 1));
0
},
\stretch, spec[\stretch],
\octave, spec[\octave],
\amp, spec[\amp]
@@ -85,7 +89,7 @@
},
{
(color != ~matLastColor[vi]).if({
var pat = ~matVariation.(name, color);
var pat = ~matVariation.(name, color, vi);
pat.notNil.if({
~matLastColor[vi] = color;
Pdef(key, pat);
@@ -106,6 +110,12 @@
~toscSend !? { ~toscSend.("/matrix/playhead", ~lp[\matBar]) }
};
// -- ~matEmitTrig : push a per-note amplitude pulse to web/TouchOSC clients --
// vi = voice index, amp clipped to 0..1. Same ~toscSend path as /matrix/playhead.
~matEmitTrig = { |vi, amp|
~toscSend !? { ~toscSend.("/matrix/trig", vi, amp.clip(0, 1)) }
};
// -- ~matStop : halt the playhead Routine and silence all matrix voices --
~matStop = {
~matRoutine !? { ~matRoutine.stop };
+15
View File
@@ -62,6 +62,21 @@ try {
("EXCEPTION in ~matStop: " ++ e.class.name).postln
};
// ~matEmitTrig must be defined and emit /matrix/trig with amp clipped to 0..1
pass = pass and: { ~matEmitTrig.notNil };
~trigLog = nil;
~toscSend = { |path ...args| ~trigLog = ([path] ++ args) }; // capturing stub
try {
~matEmitTrig.(3, 1.5)
} { |e|
pass = false;
("EXCEPTION in ~matEmitTrig: " ++ e.class.name).postln
};
pass = pass and: { ~trigLog.notNil };
pass = pass and: { ~trigLog[0] == "/matrix/trig" };
pass = pass and: { ~trigLog[1] == 3 };
pass = pass and: { ~trigLog[2] == 1.0 }; // 1.5 clipped to 1.0
pass.if(
{ "TEST PASS".postln },
{ "TEST FAIL".postln }