diff --git a/sound_algo/data_only/matrix.scd b/sound_algo/data_only/matrix.scd index b928fd0..e357b96 100644 --- a/sound_algo/data_only/matrix.scd +++ b/sound_algo/data_only/matrix.scd @@ -588,7 +588,7 @@ OSCdef(\mat_steps_get, { |msg, time, addr| ((raw.isArray.not) and: { raw[\mods].notNil }).if({ raw[\mods].do { |m, vi| (m != \none and: { m.isArray and: { m.size == 3 } and: { vi < ~matVoices.size } }).if({ - (1..6).do { |c| ~matColorDefs[vi][c][\mod] = (source: m[0], target: m[1], depth: m[2]) } + (1..6).do { |c| (~matColorDefs[vi][c][\mod].isNil).if({ ~matColorDefs[vi][c][\mod] = (source: m[0], target: m[1], depth: m[2]) }) } }) } }); @@ -597,7 +597,7 @@ OSCdef(\mat_steps_get, { |msg, time, addr| (list.isArray and: { vi < ~matVoices.size }).if({ list.do { |b| (b.isArray and: { b.size == 3 }).if({ var c = b[2].asInteger.clip(1, 6); - ~matColorDefs[vi][c][\pose] = ~matColorDefs[vi][c][\pose] ++ [ (poseId: b[0], action: b[1]) ] + (~matColorDefs[vi][c][\pose].isEmpty).if({ ~matColorDefs[vi][c][\pose] = ~matColorDefs[vi][c][\pose] ++ [ (poseId: b[0], action: b[1]) ] }) }) } }) } @@ -722,9 +722,13 @@ OSCdef(\mat_colormod, { |msg, time, addr| (msg[3] ? \none).asSymbol, (msg[4] ? \none).asSymbol, (msg[5] ? 0).asFloat) }, '/matrix/colormod'); OSCdef(\mat_colorpose, { |msg, time, addr| + var vi = (msg[1] ? 0).asInteger, color = (msg[2] ? 1).asInteger, n = (msg[3] ? 0).asInteger; ~toscTouch !? { ~toscTouch.(addr) }; - ~matSetColorPose.((msg[1] ? 0).asInteger, (msg[2] ? 1).asInteger, - (msg[3] ? \none).asSymbol, (msg[4] ? \trigger).asSymbol) + ((vi >= 0 and: { vi < ~matVoices.size }) and: { color >= 1 and: { color <= 6 } }).if({ + ~matColorDefs[vi][color][\pose] = Array.fill(n, { |k| + (poseId: (msg[4 + (k * 2)] ? \none).asSymbol, action: (msg[5 + (k * 2)] ? \trigger).asSymbol) }); + ~matColorPosePush.(vi, color) + }) }, '/matrix/colorpose'); OSCdef(\mat_colorpose_get, { |msg, time, addr| ~toscTouch !? { ~toscTouch.(addr) }; diff --git a/sound_algo/data_only/test/test_matrix.scd b/sound_algo/data_only/test/test_matrix.scd index 13e5a51..bd79314 100644 --- a/sound_algo/data_only/test/test_matrix.scd +++ b/sound_algo/data_only/test/test_matrix.scd @@ -480,6 +480,17 @@ pass = pass and: { ~matColorDefs[4][1][\mod][\target] == \cutoff }; // voice m pass = pass and: { ~matColorDefs[4][3][\pose][0][\poseId] == \poseL }; // pose -> its color File.delete(~matDir +/+ "legc.matrix"); +// colorpose OSCdef list-format parse (web sends vi color n pairs) +~cpMsg = ["/matrix/colorpose", 5, 2, 2, "poseA", "trigger", "poseB", "gate"]; +~matColorDefs[5][2][\pose] = Array.fill((~cpMsg[3]).asInteger, { |k| + (poseId: (~cpMsg[4 + (k*2)]).asSymbol, action: (~cpMsg[5 + (k*2)]).asSymbol) }); +pass = pass and: { ~matColorDefs[5][2][\pose].size == 2 }; +pass = pass and: { ~matColorDefs[5][2][\pose][1][\poseId] == \poseB }; +pass = pass and: { ~matColorDefs[5][2][\pose][1][\action] == \gate }; +// n=0 clears +~matColorDefs[5][2][\pose] = Array.fill(0, { nil }); +pass = pass and: { ~matColorDefs[5][2][\pose].isEmpty }; + pass.if( { "TEST PASS".postln }, { "TEST FAIL".postln }