diff --git a/abstractions/receive_mpe.maxpat b/abstractions/receive_mpe.maxpat index cb5f856..636e858 100644 --- a/abstractions/receive_mpe.maxpat +++ b/abstractions/receive_mpe.maxpat @@ -45,8 +45,8 @@ "numinlets" : 1, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 50.0, 100.0, 83.0, 22.0 ], - "text" : "prepend track" + "patching_rect" : [ 50.0, 100.0, 107.0, 22.0 ], + "text" : "prepend mpe_port" } } diff --git a/abstractions/send_mpe.maxpat b/abstractions/send_mpe.maxpat index ad76ac6..ec42413 100644 --- a/abstractions/send_mpe.maxpat +++ b/abstractions/send_mpe.maxpat @@ -44,8 +44,8 @@ "numinlets" : 1, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 99.0, 100.0, 83.0, 22.0 ], - "text" : "prepend track" + "patching_rect" : [ 99.0, 100.0, 107.0, 22.0 ], + "text" : "prepend mpe_port" } } @@ -88,7 +88,7 @@ "box" : { "comment" : "data_to_send: any", "id" : "obj-12", - "index" : 0, + "index" : 1, "maxclass" : "inlet", "numinlets" : 0, "numoutlets" : 1, @@ -99,9 +99,9 @@ } , { "box" : { - "comment" : "track_id: int | symbol", + "comment" : "target_id: int | symbol", "id" : "obj-13", - "index" : 0, + "index" : 2, "maxclass" : "inlet", "numinlets" : 0, "numoutlets" : 1, @@ -146,9 +146,7 @@ } } - ], - "dependency_cache" : [ ], - "autosave" : 0 + ] } } diff --git a/projects/test/code/convert_nn_to_freq.test.js b/projects/test/code/convert_nn_to_freq.test.js index 72a1163..1cae4b2 100644 --- a/projects/test/code/convert_nn_to_freq.test.js +++ b/projects/test/code/convert_nn_to_freq.test.js @@ -55,5 +55,21 @@ module.exports = { parser.freq(44), 0.1 ); + }, + testMicroTone: function*(maxAPI) { + maxAPI.outlet({ + convert_nn_to_freq: { inlet0: 60, inlet1: 8192 + 8192 / 4, inlet2: 1 } + }); + expect(yield, 'Eighth higher than C=60').to.be.closeTo( + parser.freq(60.25), + 0.1 + ); + maxAPI.outlet({ + convert_nn_to_freq: { inlet0: 65, inlet1: 8192 - 8192 / 2, inlet2: 1 } + }); + expect(yield, 'Quarter lower than F=65').to.be.closeTo( + parser.freq(64.5), + 0.1 + ); } }; diff --git a/projects/test/code/receive_mpe.test.js b/projects/test/code/receive_mpe.test.js new file mode 100644 index 0000000..c2be94a --- /dev/null +++ b/projects/test/code/receive_mpe.test.js @@ -0,0 +1,56 @@ +const { assert } = require('chai'); + +module.exports = { + // Name of the patcher which you want to test + target: 'receive_mpe', + + // `initPatcher` will be executed just before each test function. + initPatcher: function*(maxAPI) { + maxAPI.outlet({ + send_mpe: { inlet1: 8888 }, + receive_mpe: { inlet0: 8888 } + }); + setTimeout(() => { + maxAPI.outlet({ send_mpe: { inlet0: 1 } }); + }, 50); + assert.notEqual(yield, null, 'isOk'); + }, + + // The key of each test generator function should start with 'test' + testReceiveNumber: function*(maxAPI) { + maxAPI.outlet({ + send_mpe: { inlet0: 178 } + }); + assert.deepEqual(yield, { outlet0: 178 }, 'natural number'); + maxAPI.outlet({ + send_mpe: { inlet1: 145 }, + receive_mpe: { inlet0: 145 } + }); + setTimeout(() => { + maxAPI.outlet({ send_mpe: { inlet0: -78.5 } }); + }, 50); + assert.deepEqual(yield, { outlet0: -78.5 }, 'negative float'); + }, + testReceiveContinuously: function*(maxAPI) { + for (let i = 0; i < 3000; i++) { + maxAPI.outlet({ + send_mpe: { inlet0: i } + }); + assert.deepEqual(yield, { outlet0: i }); + } + }, + testReceiveList: function*(maxAPI) { + maxAPI.outlet({ + send_mpe: { inlet1: 277 }, + receive_mpe: { inlet0: 277 } + }); + setTimeout(() => { + maxAPI.outlet({ send_mpe: { inlet0: [-0.3, 'hi', 5] } }); + }, 50); + assert.deepEqual( + yield, + { outlet0: [-0.3, 'hi', 5] }, + 'list of mixed types' + ); + } +}; diff --git a/projects/test/test.maxpat b/projects/test/test.maxpat index 7258aa3..4c3adcd 100644 --- a/projects/test/test.maxpat +++ b/projects/test/test.maxpat @@ -10,7 +10,7 @@ } , "classnamespace" : "box", - "rect" : [ 34.0, 78.0, 942.0, 788.0 ], + "rect" : [ 1474.0, -102.0, 1420.0, 968.0 ], "bglocked" : 0, "openinpresentation" : 0, "default_fontsize" : 12.0, @@ -38,6 +38,79 @@ "style" : "", "subpatcher_template" : "", "boxes" : [ { + "box" : { + "id" : "obj-1", + "maxclass" : "newobj", + "numinlets" : 1, + "numoutlets" : 1, + "outlettype" : [ "dictionary" ], + "patching_rect" : [ 575.0, 387.0, 99.0, 22.0 ], + "text" : "dict.pack outlet0:" + } + + } +, { + "box" : { + "id" : "obj-6", + "maxclass" : "newobj", + "numinlets" : 1, + "numoutlets" : 1, + "outlettype" : [ "" ], + "patching_rect" : [ 575.0, 431.0, 125.0, 22.0 ], + "text" : "prepend receive_mpe" + } + + } +, { + "box" : { + "id" : "obj-5", + "maxclass" : "newobj", + "numinlets" : 1, + "numoutlets" : 1, + "outlettype" : [ "" ], + "patching_rect" : [ 575.0, 280.0, 105.0, 22.0 ], + "text" : "dict.unpack inlet0:" + } + + } +, { + "box" : { + "id" : "obj-4", + "maxclass" : "newobj", + "numinlets" : 1, + "numoutlets" : 2, + "outlettype" : [ "", "" ], + "patching_rect" : [ 319.5, 280.0, 140.0, 22.0 ], + "text" : "dict.unpack inlet0: inlet1:" + } + + } +, { + "box" : { + "color" : [ 0.96078431372549, 0.588235294117647, 0.152941176470588, 1.0 ], + "id" : "obj-3", + "maxclass" : "newobj", + "numinlets" : 1, + "numoutlets" : 1, + "outlettype" : [ "" ], + "patching_rect" : [ 575.0, 334.0, 77.0, 22.0 ], + "text" : "receive_mpe" + } + + } +, { + "box" : { + "color" : [ 0.96078431372549, 0.588235294117647, 0.152941176470588, 1.0 ], + "id" : "obj-2", + "maxclass" : "newobj", + "numinlets" : 2, + "numoutlets" : 0, + "patching_rect" : [ 319.5, 334.0, 140.0, 22.0 ], + "text" : "send_mpe" + } + + } +, { "box" : { "id" : "obj-8", "maxclass" : "message", @@ -72,18 +145,6 @@ "text" : "tdd" } - } -, { - "box" : { - "id" : "obj-1", - "maxclass" : "newobj", - "numinlets" : 2, - "numoutlets" : 1, - "outlettype" : [ "dictionary" ], - "patching_rect" : [ 252.0, 494.0, 217.0, 22.0 ], - "text" : "dict.pack outlet0: outlet1: @triggers 0 1" - } - } , { "box" : { @@ -127,15 +188,22 @@ "id" : "obj-12", "maxclass" : "newobj", "numinlets" : 1, - "numoutlets" : 1, - "outlettype" : [ "" ], - "patching_rect" : [ 64.0, 194.0, 179.0, 22.0 ], - "text" : "dict.unpack convert_nn_to_freq:" + "numoutlets" : 3, + "outlettype" : [ "", "", "" ], + "patching_rect" : [ 64.0, 194.0, 530.0, 22.0 ], + "text" : "dict.unpack convert_nn_to_freq: send_mpe: receive_mpe:" } } ], "lines" : [ { + "patchline" : { + "destination" : [ "obj-6", 0 ], + "source" : [ "obj-1", 0 ] + } + + } +, { "patchline" : { "destination" : [ "obj-9", 2 ], "source" : [ "obj-11", 2 ] @@ -162,6 +230,20 @@ "source" : [ "obj-12", 0 ] } + } +, { + "patchline" : { + "destination" : [ "obj-4", 0 ], + "source" : [ "obj-12", 1 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-5", 0 ], + "source" : [ "obj-12", 2 ] + } + } , { "patchline" : { @@ -170,6 +252,13 @@ "source" : [ "obj-14", 0 ] } + } +, { + "patchline" : { + "destination" : [ "obj-1", 0 ], + "source" : [ "obj-3", 0 ] + } + } , { "patchline" : { @@ -177,6 +266,35 @@ "source" : [ "obj-30", 0 ] } + } +, { + "patchline" : { + "destination" : [ "obj-2", 1 ], + "source" : [ "obj-4", 1 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-2", 0 ], + "source" : [ "obj-4", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-3", 0 ], + "source" : [ "obj-5", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-30", 0 ], + "midpoints" : [ 584.5, 512.0, 49.0, 512.0, 49.0, 77.0, 73.5, 77.0 ], + "source" : [ "obj-6", 0 ] + } + } , { "patchline" : { @@ -228,6 +346,20 @@ "type" : "TEXT", "implicit" : 1 } +, { + "name" : "send_mpe.maxpat", + "bootpath" : "~/repos/m4l-mpe-tools/abstractions", + "patcherrelativepath" : "../../abstractions", + "type" : "JSON", + "implicit" : 1 + } +, { + "name" : "receive_mpe.maxpat", + "bootpath" : "~/repos/m4l-mpe-tools/abstractions", + "patcherrelativepath" : "../../abstractions", + "type" : "JSON", + "implicit" : 1 + } ], "autosave" : 0 } diff --git a/projects/test/test.maxproj b/projects/test/test.maxproj index 6d32e7f..8a0804d 100644 --- a/projects/test/test.maxproj +++ b/projects/test/test.maxproj @@ -2,7 +2,7 @@ "name" : "test", "version" : 1, "creationdate" : 3642055787, - "modificationdate" : 3642075359, + "modificationdate" : 3642082862, "viewrect" : [ 0.0, 44.0, 361.0, 533.0 ], "autoorganize" : 0, "hideprojectwindow" : 0, @@ -35,17 +35,17 @@ , "searchpath" : { "0" : { - "bootpath" : "~/repos/m4l-mpe-tools/node_modules/tdd-max", - "projectrelativepath" : "../../node_modules/tdd-max", - "label" : "node_modules/tdd-max", + "bootpath" : "~/repos/m4l-mpe-tools/abstractions", + "projectrelativepath" : "../../abstractions", + "label" : "", "recursive" : 1, "enabled" : 1, "includeincollective" : 0 } , "1" : { - "bootpath" : "~/repos/m4l-mpe-tools/abstractions", - "projectrelativepath" : "../../abstractions", + "bootpath" : "~/repos/m4l-mpe-tools/node_modules/tdd-max", + "projectrelativepath" : "../../node_modules/tdd-max", "label" : "", "recursive" : 1, "enabled" : 1,