From ee64e9d1e9108a16be06816b74bfa2ed92ea6e5c Mon Sep 17 00:00:00 2001 From: Todd Treece Date: Mon, 19 Sep 2011 17:04:20 -0600 Subject: [PATCH] Small tweaks --- blodeJazz.maxpat | 489 ++++++++++++++++++++++++++++++++++++++--------- jazz.js | 8 +- lib/blodeJazz.js | 4 +- lib/chord.js | 6 +- 4 files changed, 407 insertions(+), 100 deletions(-) diff --git a/blodeJazz.maxpat b/blodeJazz.maxpat index 14715b9..2d93fcf 100644 --- a/blodeJazz.maxpat +++ b/blodeJazz.maxpat @@ -1,11 +1,11 @@ { "patcher" : { "fileversion" : 1, - "rect" : [ 584.0, 1350.0, 868.0, 341.0 ], + "rect" : [ 282.0, 1105.0, 396.0, 198.0 ], "bglocked" : 0, - "defrect" : [ 584.0, 1350.0, 868.0, 341.0 ], + "defrect" : [ 282.0, 1105.0, 396.0, 198.0 ], "openrect" : [ 0.0, 0.0, 0.0, 0.0 ], - "openinpresentation" : 0, + "openinpresentation" : 1, "default_fontsize" : 12.0, "default_fontface" : 0, "default_fontname" : "Arial", @@ -20,29 +20,130 @@ "devicewidth" : 0.0, "boxes" : [ { "box" : { - "maxclass" : "message", - "text" : "2", - "id" : "obj-30", - "fontname" : "Arial", - "numinlets" : 2, + "maxclass" : "newobj", + "text" : "loadbang", + "numinlets" : 1, + "patching_rect" : [ 180.0, 30.0, 60.0, 20.0 ], "numoutlets" : 1, + "id" : "obj-16", + "fontname" : "Arial", + "outlettype" : [ "bang" ], + "fontsize" : 12.0 + } + + } +, { + "box" : { + "maxclass" : "comment", + "text" : " _ _ _ ___ \n| | | | | | |_ | \n| |__ | | ___ __| | ___ | | __ _ ________\n| '_ \\| |/ _ \\ / _` |/ _ \\ | |/ _` |_ /_ /\n| |_) | | (_) | (_| | __/\\__/ / (_| |/ / / / \n|_.__/|_|\\___/ \\__,_|\\___\\____/ \\__,_/___/___|", + "linecount" : 6, + "presentation_linecount" : 6, + "numinlets" : 1, + "patching_rect" : [ 255.0, 15.0, 343.0, 78.0 ], + "numoutlets" : 0, + "presentation" : 1, + "id" : "obj-34", + "fontname" : "Courier", "fontsize" : 12.0, - "outlettype" : [ "" ], - "patching_rect" : [ 684.0, 276.0, 32.5, 18.0 ] + "presentation_rect" : [ 30.0, 0.0, 342.0, 78.0 ] } } , { "box" : { - "maxclass" : "message", - "text" : "0", - "id" : "obj-29", + "maxclass" : "comment", + "text" : "Organ", + "numinlets" : 1, + "patching_rect" : [ 360.0, 330.0, 73.0, 29.0 ], + "numoutlets" : 0, + "presentation" : 1, + "id" : "obj-33", + "fontname" : "Arial", + "fontsize" : 20.0, + "presentation_rect" : [ 300.0, 150.0, 65.0, 29.0 ] + } + + } +, { + "box" : { + "maxclass" : "comment", + "text" : "Keys", + "numinlets" : 1, + "patching_rect" : [ 210.0, 330.0, 65.0, 29.0 ], + "numoutlets" : 0, + "presentation" : 1, + "id" : "obj-32", "fontname" : "Arial", + "fontsize" : 20.0, + "presentation_rect" : [ 165.0, 150.0, 58.0, 29.0 ] + } + + } +, { + "box" : { + "maxclass" : "comment", + "text" : "Bass\n", + "numinlets" : 1, + "patching_rect" : [ 60.0, 330.0, 65.0, 29.0 ], + "numoutlets" : 0, + "presentation" : 1, + "id" : "obj-26", + "fontname" : "Arial", + "fontsize" : 20.0, + "presentation_rect" : [ 30.0, 150.0, 65.0, 29.0 ] + } + + } +, { + "box" : { + "maxclass" : "button", + "numinlets" : 1, + "patching_rect" : [ 360.0, 270.0, 50.0, 50.0 ], + "numoutlets" : 1, + "presentation" : 1, + "id" : "obj-20", + "outlettype" : [ "bang" ], + "presentation_rect" : [ 300.0, 90.0, 50.0, 50.0 ] + } + + } +, { + "box" : { + "maxclass" : "button", + "numinlets" : 1, + "patching_rect" : [ 210.0, 270.0, 50.0, 50.0 ], + "numoutlets" : 1, + "presentation" : 1, + "id" : "obj-19", + "outlettype" : [ "bang" ], + "presentation_rect" : [ 165.0, 90.0, 50.0, 50.0 ] + } + + } +, { + "box" : { + "maxclass" : "button", + "numinlets" : 1, + "patching_rect" : [ 60.0, 270.0, 50.0, 50.0 ], + "numoutlets" : 1, + "presentation" : 1, + "id" : "obj-18", + "outlettype" : [ "bang" ], + "presentation_rect" : [ 30.0, 90.0, 50.0, 50.0 ] + } + + } +, { + "box" : { + "maxclass" : "message", + "text" : "127", "numinlets" : 2, + "patching_rect" : [ 375.0, 195.0, 32.5, 18.0 ], "numoutlets" : 1, - "fontsize" : 12.0, + "id" : "obj-15", + "fontname" : "Arial", "outlettype" : [ "" ], - "patching_rect" : [ 635.0, 258.0, 32.5, 18.0 ] + "fontsize" : 12.0 } } @@ -50,51 +151,123 @@ "box" : { "maxclass" : "newobj", "text" : "noteout", - "id" : "obj-28", - "fontname" : "Arial", "numinlets" : 3, + "patching_rect" : [ 60.0, 225.0, 51.0, 20.0 ], "numoutlets" : 0, - "fontsize" : 12.0, - "patching_rect" : [ 617.0, 287.0, 51.0, 20.0 ] + "id" : "obj-3", + "fontname" : "Arial", + "fontsize" : 12.0 + } + + } +, { + "box" : { + "maxclass" : "message", + "text" : "3", + "numinlets" : 2, + "patching_rect" : [ 120.0, 180.0, 32.5, 18.0 ], + "numoutlets" : 1, + "id" : "obj-9", + "fontname" : "Arial", + "outlettype" : [ "" ], + "fontsize" : 12.0 } } , { "box" : { "maxclass" : "newobj", - "text" : "unpack 0 0 0 0", - "id" : "obj-27", + "text" : "makenote 127 5000", + "numinlets" : 3, + "patching_rect" : [ 60.0, 150.0, 117.0, 20.0 ], + "numoutlets" : 2, + "id" : "obj-11", "fontname" : "Arial", - "numinlets" : 1, - "numoutlets" : 4, - "fontsize" : 12.0, - "outlettype" : [ "int", "int", "int", "int" ], - "patching_rect" : [ 643.0, 182.0, 89.0, 20.0 ] + "outlettype" : [ "float", "float" ], + "fontsize" : 12.0 } } , { "box" : { - "maxclass" : "slider", - "id" : "obj-23", + "maxclass" : "newobj", + "text" : "route /blode/bass", "numinlets" : 1, + "patching_rect" : [ 60.0, 120.0, 103.0, 20.0 ], + "numoutlets" : 2, + "id" : "obj-14", + "fontname" : "Arial", + "outlettype" : [ "", "" ], + "fontsize" : 12.0 + } + + } +, { + "box" : { + "maxclass" : "message", + "text" : "2", + "numinlets" : 2, + "patching_rect" : [ 570.0, 195.0, 32.5, 18.0 ], "numoutlets" : 1, + "id" : "obj-30", + "fontname" : "Arial", "outlettype" : [ "" ], - "patching_rect" : [ 460.0, -40.0, 20.0, 140.0 ] + "fontsize" : 12.0 + } + + } +, { + "box" : { + "maxclass" : "message", + "text" : "0", + "numinlets" : 2, + "patching_rect" : [ 525.0, 195.0, 32.5, 18.0 ], + "numoutlets" : 1, + "id" : "obj-29", + "fontname" : "Arial", + "outlettype" : [ "" ], + "fontsize" : 12.0 } } , { "box" : { "maxclass" : "newobj", - "text" : "route /blode/chord/off", - "id" : "obj-13", + "text" : "noteout", + "numinlets" : 3, + "patching_rect" : [ 510.0, 240.0, 51.0, 20.0 ], + "numoutlets" : 0, + "id" : "obj-28", "fontname" : "Arial", + "fontsize" : 12.0 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "unpack 0 0 0 0", "numinlets" : 1, + "patching_rect" : [ 510.0, 150.0, 89.0, 20.0 ], + "numoutlets" : 4, + "id" : "obj-27", + "fontname" : "Arial", + "outlettype" : [ "int", "int", "int", "int" ], + "fontsize" : 12.0 + } + + } +, { + "box" : { + "maxclass" : "newobj", + "text" : "route /blode/chord/off", + "numinlets" : 1, + "patching_rect" : [ 510.0, 120.0, 124.0, 20.0 ], "numoutlets" : 2, - "fontsize" : 12.0, + "id" : "obj-13", + "fontname" : "Arial", "outlettype" : [ "", "" ], - "patching_rect" : [ 556.0, 119.0, 124.0, 20.0 ] + "fontsize" : 12.0 } } @@ -102,13 +275,13 @@ "box" : { "maxclass" : "message", "text" : "2", - "id" : "obj-12", - "fontname" : "Arial", "numinlets" : 2, + "patching_rect" : [ 420.0, 195.0, 32.5, 18.0 ], "numoutlets" : 1, - "fontsize" : 12.0, + "id" : "obj-12", + "fontname" : "Arial", "outlettype" : [ "" ], - "patching_rect" : [ 564.0, 206.0, 32.5, 18.0 ] + "fontsize" : 12.0 } } @@ -116,12 +289,12 @@ "box" : { "maxclass" : "newobj", "text" : "noteout", - "id" : "obj-10", - "fontname" : "Arial", "numinlets" : 3, + "patching_rect" : [ 360.0, 240.0, 51.0, 20.0 ], "numoutlets" : 0, - "fontsize" : 12.0, - "patching_rect" : [ 464.0, 285.0, 51.0, 20.0 ] + "id" : "obj-10", + "fontname" : "Arial", + "fontsize" : 12.0 } } @@ -129,12 +302,12 @@ "box" : { "maxclass" : "newobj", "text" : "noteout", - "id" : "obj-8", - "fontname" : "Arial", "numinlets" : 3, + "patching_rect" : [ 210.0, 225.0, 51.0, 20.0 ], "numoutlets" : 0, - "fontsize" : 12.0, - "patching_rect" : [ 215.0, 262.0, 51.0, 20.0 ] + "id" : "obj-8", + "fontname" : "Arial", + "fontsize" : 12.0 } } @@ -142,13 +315,13 @@ "box" : { "maxclass" : "newobj", "text" : "unpack 0 0 0 0", - "id" : "obj-7", - "fontname" : "Arial", "numinlets" : 1, + "patching_rect" : [ 360.0, 150.0, 89.0, 20.0 ], "numoutlets" : 4, - "fontsize" : 12.0, + "id" : "obj-7", + "fontname" : "Arial", "outlettype" : [ "int", "int", "int", "int" ], - "patching_rect" : [ 402.0, 154.0, 89.0, 20.0 ] + "fontsize" : 12.0 } } @@ -156,13 +329,13 @@ "box" : { "maxclass" : "newobj", "text" : "route /blode/chord/on", - "id" : "obj-6", - "fontname" : "Arial", "numinlets" : 1, + "patching_rect" : [ 360.0, 120.0, 124.0, 20.0 ], "numoutlets" : 2, - "fontsize" : 12.0, + "id" : "obj-6", + "fontname" : "Arial", "outlettype" : [ "", "" ], - "patching_rect" : [ 394.0, 120.0, 124.0, 20.0 ] + "fontsize" : 12.0 } } @@ -170,13 +343,13 @@ "box" : { "maxclass" : "message", "text" : "1", - "id" : "obj-4", - "fontname" : "Arial", "numinlets" : 2, + "patching_rect" : [ 270.0, 180.0, 32.5, 18.0 ], "numoutlets" : 1, - "fontsize" : 12.0, + "id" : "obj-4", + "fontname" : "Arial", "outlettype" : [ "" ], - "patching_rect" : [ 279.0, 228.0, 32.5, 18.0 ] + "fontsize" : 12.0 } } @@ -184,13 +357,13 @@ "box" : { "maxclass" : "newobj", "text" : "makenote 127 2000", - "id" : "obj-2", - "fontname" : "Arial", "numinlets" : 3, + "patching_rect" : [ 210.0, 150.0, 117.0, 20.0 ], "numoutlets" : 2, - "fontsize" : 12.0, + "id" : "obj-2", + "fontname" : "Arial", "outlettype" : [ "float", "float" ], - "patching_rect" : [ 215.0, 155.0, 117.0, 20.0 ] + "fontsize" : 12.0 } } @@ -198,13 +371,13 @@ "box" : { "maxclass" : "newobj", "text" : "route /blode/melody", - "id" : "obj-5", - "fontname" : "Arial", "numinlets" : 1, + "patching_rect" : [ 210.0, 120.0, 116.0, 20.0 ], "numoutlets" : 2, - "fontsize" : 12.0, + "id" : "obj-5", + "fontname" : "Arial", "outlettype" : [ "", "" ], - "patching_rect" : [ 214.0, 120.0, 116.0, 20.0 ] + "fontsize" : 12.0 } } @@ -212,23 +385,104 @@ "box" : { "maxclass" : "newobj", "text" : "udpreceive 3333", - "id" : "obj-1", - "fontname" : "Arial", "numinlets" : 1, + "patching_rect" : [ 60.0, 30.0, 99.0, 20.0 ], "numoutlets" : 1, - "fontsize" : 12.0, + "id" : "obj-1", + "fontname" : "Arial", "outlettype" : [ "" ], - "patching_rect" : [ 209.0, 8.0, 99.0, 20.0 ] + "fontsize" : 12.0 } } ], "lines" : [ { + "patchline" : { + "source" : [ "obj-14", 0 ], + "destination" : [ "obj-11", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-11", 1 ], + "destination" : [ "obj-3", 1 ], + "hidden" : 0, + "midpoints" : [ 167.5, 210.0, 85.5, 210.0 ] + } + + } +, { + "patchline" : { + "source" : [ "obj-11", 0 ], + "destination" : [ "obj-3", 0 ], + "hidden" : 0, + "midpoints" : [ 69.5, 171.0, 69.5, 171.0 ] + } + + } +, { + "patchline" : { + "source" : [ "obj-16", 0 ], + "destination" : [ "obj-30", 0 ], + "hidden" : 0, + "midpoints" : [ 189.5, 105.0, 495.0, 105.0, 495.0, 180.0, 579.5, 180.0 ] + } + + } +, { + "patchline" : { + "source" : [ "obj-16", 0 ], + "destination" : [ "obj-29", 0 ], + "hidden" : 0, + "midpoints" : [ 189.5, 105.0, 495.0, 105.0, 495.0, 180.0, 534.5, 180.0 ] + } + + } +, { + "patchline" : { + "source" : [ "obj-16", 0 ], + "destination" : [ "obj-12", 0 ], + "hidden" : 0, + "midpoints" : [ 189.5, 105.0, 345.0, 105.0, 345.0, 180.0, 429.5, 180.0 ] + } + + } +, { + "patchline" : { + "source" : [ "obj-16", 0 ], + "destination" : [ "obj-15", 0 ], + "hidden" : 0, + "midpoints" : [ 189.5, 105.0, 345.0, 105.0, 345.0, 180.0, 384.5, 180.0 ] + } + + } +, { + "patchline" : { + "source" : [ "obj-16", 0 ], + "destination" : [ "obj-4", 0 ], + "hidden" : 0, + "midpoints" : [ 189.5, 180.0, 267.0, 180.0, 267.0, 177.0, 279.5, 177.0 ] + } + + } +, { + "patchline" : { + "source" : [ "obj-16", 0 ], + "destination" : [ "obj-9", 0 ], + "hidden" : 0, + "midpoints" : [ 189.5, 180.0, 153.0, 180.0, 153.0, 177.0, 129.5, 177.0 ] + } + + } +, { "patchline" : { "source" : [ "obj-30", 0 ], "destination" : [ "obj-28", 2 ], "hidden" : 0, - "midpoints" : [ ] + "midpoints" : [ 579.5, 225.0, 551.5, 225.0 ] } } @@ -246,7 +500,7 @@ "source" : [ "obj-27", 3 ], "destination" : [ "obj-28", 0 ], "hidden" : 0, - "midpoints" : [ ] + "midpoints" : [ 589.5, 180.0, 510.0, 180.0, 510.0, 225.0, 519.5, 225.0 ] } } @@ -255,7 +509,7 @@ "source" : [ "obj-27", 2 ], "destination" : [ "obj-28", 0 ], "hidden" : 0, - "midpoints" : [ ] + "midpoints" : [ 566.166687, 180.0, 510.0, 180.0, 510.0, 225.0, 519.5, 225.0 ] } } @@ -264,7 +518,7 @@ "source" : [ "obj-27", 1 ], "destination" : [ "obj-28", 0 ], "hidden" : 0, - "midpoints" : [ ] + "midpoints" : [ 542.833313, 180.0, 510.0, 180.0, 510.0, 225.0, 519.5, 225.0 ] } } @@ -273,7 +527,7 @@ "source" : [ "obj-27", 0 ], "destination" : [ "obj-28", 0 ], "hidden" : 0, - "midpoints" : [ ] + "midpoints" : [ 519.5, 180.0, 510.0, 180.0, 510.0, 225.0, 519.5, 225.0 ] } } @@ -282,7 +536,7 @@ "source" : [ "obj-29", 0 ], "destination" : [ "obj-28", 1 ], "hidden" : 0, - "midpoints" : [ ] + "midpoints" : [ 534.5, 213.0, 535.5, 213.0 ] } } @@ -291,7 +545,7 @@ "source" : [ "obj-7", 3 ], "destination" : [ "obj-10", 0 ], "hidden" : 0, - "midpoints" : [ ] + "midpoints" : [ 439.5, 180.0, 369.5, 180.0 ] } } @@ -300,7 +554,7 @@ "source" : [ "obj-7", 2 ], "destination" : [ "obj-10", 0 ], "hidden" : 0, - "midpoints" : [ ] + "midpoints" : [ 416.166656, 180.0, 369.5, 180.0 ] } } @@ -309,7 +563,7 @@ "source" : [ "obj-7", 1 ], "destination" : [ "obj-10", 0 ], "hidden" : 0, - "midpoints" : [ ] + "midpoints" : [ 392.833344, 180.0, 369.5, 180.0 ] } } @@ -318,16 +572,7 @@ "source" : [ "obj-7", 0 ], "destination" : [ "obj-10", 0 ], "hidden" : 0, - "midpoints" : [ ] - } - - } -, { - "patchline" : { - "source" : [ "obj-23", 0 ], - "destination" : [ "obj-10", 1 ], - "hidden" : 0, - "midpoints" : [ ] + "midpoints" : [ 369.5, 171.0, 369.5, 171.0 ] } } @@ -336,7 +581,7 @@ "source" : [ "obj-4", 0 ], "destination" : [ "obj-8", 2 ], "hidden" : 0, - "midpoints" : [ 288.5, 258.0, 256.5, 258.0 ] + "midpoints" : [ 279.5, 210.0, 251.5, 210.0 ] } } @@ -345,7 +590,7 @@ "source" : [ "obj-2", 1 ], "destination" : [ "obj-8", 1 ], "hidden" : 0, - "midpoints" : [ 322.5, 207.0, 258.0, 207.0, 258.0, 255.0, 240.5, 255.0 ] + "midpoints" : [ 317.5, 207.0, 235.5, 207.0 ] } } @@ -354,7 +599,7 @@ "source" : [ "obj-2", 0 ], "destination" : [ "obj-8", 0 ], "hidden" : 0, - "midpoints" : [ 224.5, 246.0, 224.5, 246.0 ] + "midpoints" : [ 219.5, 195.0, 219.5, 195.0 ] } } @@ -363,7 +608,7 @@ "source" : [ "obj-12", 0 ], "destination" : [ "obj-10", 2 ], "hidden" : 0, - "midpoints" : [ 573.5, 246.0, 505.5, 246.0 ] + "midpoints" : [ 429.5, 225.0, 401.5, 225.0 ] } } @@ -372,7 +617,7 @@ "source" : [ "obj-1", 0 ], "destination" : [ "obj-13", 0 ], "hidden" : 0, - "midpoints" : [ 218.5, 105.0, 565.5, 105.0 ] + "midpoints" : [ 69.5, 105.0, 519.5, 105.0 ] } } @@ -381,7 +626,7 @@ "source" : [ "obj-1", 0 ], "destination" : [ "obj-6", 0 ], "hidden" : 0, - "midpoints" : [ 218.5, 105.0, 403.5, 105.0 ] + "midpoints" : [ 69.5, 105.0, 369.5, 105.0 ] } } @@ -399,7 +644,7 @@ "source" : [ "obj-1", 0 ], "destination" : [ "obj-5", 0 ], "hidden" : 0, - "midpoints" : [ 218.5, 105.0, 223.5, 105.0 ] + "midpoints" : [ 69.5, 105.0, 219.5, 105.0 ] } } @@ -411,6 +656,60 @@ "midpoints" : [ ] } + } +, { + "patchline" : { + "source" : [ "obj-9", 0 ], + "destination" : [ "obj-3", 2 ], + "hidden" : 0, + "midpoints" : [ 129.5, 210.0, 101.5, 210.0 ] + } + + } +, { + "patchline" : { + "source" : [ "obj-1", 0 ], + "destination" : [ "obj-14", 0 ], + "hidden" : 0, + "midpoints" : [ ] + } + + } +, { + "patchline" : { + "source" : [ "obj-15", 0 ], + "destination" : [ "obj-10", 1 ], + "hidden" : 0, + "midpoints" : [ 384.5, 213.0, 385.5, 213.0 ] + } + + } +, { + "patchline" : { + "source" : [ "obj-14", 0 ], + "destination" : [ "obj-18", 0 ], + "hidden" : 0, + "midpoints" : [ 69.5, 141.0, 45.0, 141.0, 45.0, 255.0, 69.5, 255.0 ] + } + + } +, { + "patchline" : { + "source" : [ "obj-5", 0 ], + "destination" : [ "obj-19", 0 ], + "hidden" : 0, + "midpoints" : [ 219.5, 141.0, 195.0, 141.0, 195.0, 255.0, 219.5, 255.0 ] + } + + } +, { + "patchline" : { + "source" : [ "obj-6", 0 ], + "destination" : [ "obj-20", 0 ], + "hidden" : 0, + "midpoints" : [ 369.5, 141.0, 345.0, 141.0, 345.0, 267.0, 369.5, 267.0 ] + } + } ] } diff --git a/jazz.js b/jazz.js index 617e606..0e64de7 100644 --- a/jazz.js +++ b/jazz.js @@ -1,7 +1,13 @@ var p = require('./lib/progression.js'); var b = require('./lib/blodeJazz.js'); -var progression = new p.progression('C','II,V,I'); +var input_key = process.argv[2]; +var input_progression = process.argv[3]; +if(input_key == undefined || input_progression == undefined) { + console.log('You must provide a key and progression'); + process.exit(0); +} +var progression = new p.progression(input_key,input_progression); var jazz = new b.blodeJazz(progression); jazz.init(); diff --git a/lib/blodeJazz.js b/lib/blodeJazz.js index 7d7756f..1f39c96 100644 --- a/lib/blodeJazz.js +++ b/lib/blodeJazz.js @@ -68,11 +68,13 @@ exports.blodeJazz = function(p) { } else if (message.session_auth_attempt != undefined) { var last_off = this.progression.advance(); var chord = this.progression.chord(); - + var bass = this.progression.bass(); if(last_off != false) this.osc_client.send(last_off); + this.osc_client.send(bass); this.osc_client.send(chord); + } }; diff --git a/lib/chord.js b/lib/chord.js index b1bda05..69ac686 100644 --- a/lib/chord.js +++ b/lib/chord.js @@ -39,17 +39,17 @@ exports.chord = function(root_note,intervals) { }; this.getChordOctave = function() { - var random = Math.floor(Math.random() * 3 + 1) - 1; + var random = Math.floor(Math.random() * this.chord_octaves.length + 1) - 1; return this.root + this.chord_octaves[random]; }; this.getMelodyOctave = function() { - var random = Math.floor(Math.random() * 3 + 1) - 1; + var random = Math.floor(Math.random() * this.melody_octaves.length + 1) - 1; return this.root + this.melody_octaves[random]; }; this.getBassOctave = function() { - var random = Math.floor(Math.random() * 2 + 1) - 1; + var random = Math.floor(Math.random() * this.bass_octaves.length + 1) - 1; return this.root + this.bass_octaves[random]; };