From eae24038937a0a223c140608316f78e7f289f9ee Mon Sep 17 00:00:00 2001 From: jeremy Date: Thu, 18 Dec 2014 12:00:52 -0500 Subject: [PATCH] added Notegroup to URL Creating a link now allows you to hold what notegroup (eg, scale, arpeggio) the fretboard will paint notes with instead of just Cmajor --- ScaleDictionary.js | 88 +++++++++++++++++++++++++++++++++++----------- boxfrets.js | 74 +++++++++++++++++++++++++++----------- 2 files changed, 122 insertions(+), 40 deletions(-) diff --git a/ScaleDictionary.js b/ScaleDictionary.js index 6798430..dfe7640 100644 --- a/ScaleDictionary.js +++ b/ScaleDictionary.js @@ -48,19 +48,24 @@ var dictKeys = { "Gsharp" : kGsharp, "Asharp" : kAsharp}; -var INTS_FLATS = ['R', '♭9', '9', '♭3', '3', '11', '♭5', '5', '♭13', '13', '♭7', '7']; -var INTS_SHARP4 = ['R', '♭9', '9', '♭3', '3', '11', '♯11', '5', '♭13', '13', '♭7', '7']; -var INTS_DOM = ['R', '♭9', '9', '♯9', '3', '11', '♭5', '5', '+5', '13', '♭7', '7']; -var INTS_SHARP4AUG = ['R', '♭9', '9', '♭3', '3', '11', '♯11', '5', '+5', '13', '♭7', '7']; -var INTS_DIM = ['R', '♭9', '9', '♭3', '3', '11', '♯4', '5', '+5', '♭♭7', '♭7', '7']; -var INTS_SUPERLOCRIAN = ['R', '♭9', '9', '♭3', '♭4', '11', '♭5', '5', '♭13', '13', '♭7', '7']; + +// old +//var INTS_FLATS = ['R', '♭9', '9', '♭3', '3', '11', '♭5', '5', '♭13', '13', '♭7', '7']; +//var INTS_SHARP4 = ['R', '♭9', '9', '♭3', '3', '11', '♯11', '5', '♭13', '13', '♭7', '7']; +//var INTS_DOM = ['R', '♭9', '9', '♯9', '3', '11', '♭5', '5', '+5', '13', '♭7', '7']; + +//var INTS_SHARP4AUG = ['R', '♭9', '9', '♭3', '3', '11', '♯11', '5', '+5', '13', '♭7', '7']; +//var INTS_DIM = ['R', '♭9', '9', '♭3', '3', '11', '♭5', '5', '+5', '♭♭7', '♭7', '7']; +//var INTS_SUPERLOCRIAN = ['R', '♭9', '9', '♭3', '♭4', '11', '♭5', '5', '♭13', '13', '♭7', '7']; + + var dictInt = { 'ROOT': { 'SEMI' : 0, 'INT' : 'R', - 'CLR' : 'i__ROOT' + 'CLR' : 'i_root' }, 'FLATNINE' : { @@ -77,7 +82,7 @@ var dictInt = { 'SHARPNINE' : { 'SEMI' : 3, - 'INT' : '♯11', + 'INT' : '♯9', 'CLR' : 'i_sharpnine' }, @@ -147,6 +152,12 @@ var dictInt = { 'CLR' : 'i_sixth' }, +'DBLFLATSEVEN' : { + 'SEMI' : 10, + 'INT' : '♭♭7', + 'CLR' : 'i_seventh' +}, + 'FLATSEVEN' : { 'SEMI' : 10, 'INT' : '♭7', @@ -181,14 +192,24 @@ var dictInt = { } } +var INTS_FLATS = [dictInt.ROOT.INT, dictInt.FLATNINE.INT, dictInt.NINE.INT, dictInt.FLATTHREE.INT, dictInt.THIRD.INT, dictInt.ELEVEN.INT, dictInt.FLATFIVE.INT, dictInt.FIFTH.INT, dictInt.FLATTHIRTEEN.INT, dictInt.THIRTEEN.INT, dictInt.FLATSEVEN.INT, dictInt.SEVENTH.INT]; +var INTS_SHARP4 = [dictInt.ROOT.INT, dictInt.FLATNINE.INT, dictInt.NINE.INT, dictInt.FLATTHREE.INT, dictInt.THIRD.INT, dictInt.ELEVEN.INT, dictInt.SHARPELEVEN.INT, dictInt.FIFTH.INT, dictInt.FLATTHIRTEEN.INT, dictInt.THIRTEEN.INT, dictInt.FLATSEVEN.INT, dictInt.SEVENTH.INT]; +var INTS_DOM = [dictInt.ROOT.INT, dictInt.FLATNINE.INT, dictInt.NINE.INT, dictInt.SHARPNINE.INT, dictInt.THIRD.INT, dictInt.ELEVEN.INT, dictInt.FLATFIVE.INT, dictInt.FIFTH.INT, dictInt.AUGFIVE.INT, dictInt.THIRTEEN.INT, dictInt.FLATSEVEN.INT, dictInt.SEVENTH.INT]; + +var INTS_SHARP4AUG = [dictInt.ROOT.INT, dictInt.FLATNINE.INT, dictInt.NINE.INT, dictInt.FLATTHREE.INT, dictInt.THIRD.INT, dictInt.ELEVEN.INT, dictInt.SHARPELEVEN.INT, dictInt.FIFTH.INT, dictInt.AUGFIVE.INT, dictInt.THIRTEEN.INT, dictInt.FLATSEVEN.INT, dictInt.SEVENTH.INT]; +var INTS_DIM = [dictInt.ROOT.INT, dictInt.FLATNINE.INT, dictInt.NINE.INT, dictInt.FLATTHREE.INT, dictInt.THIRD.INT, dictInt.ELEVEN.INT, dictInt.FLATFIVE.INT, dictInt.FIFTH.INT, dictInt.AUGFIVE.INT, dictInt.DBLFLATSEVEN.INT, dictInt.FLATSEVEN.INT, dictInt.SEVENTH.INT]; +var INTS_SUPERLOCRIAN = [dictInt.ROOT.INT, dictInt.FLATNINE.INT, dictInt.NINE.INT, dictInt.FLATTHREE.INT, dictInt.DIMELEVEN.INT, dictInt.ELEVEN.INT, dictInt.FLATFIVE.INT, dictInt.FIFTH.INT, dictInt.FLATTHIRTEEN.INT, dictInt.THIRTEEN.INT, dictInt.FLATSEVEN.INT, dictInt.SEVENTH.INT]; + + + // Scale Formulas -var IF_IONIAN = [dictInt._ROOT, dictInt.TX, dictInt.TI, dictInt.TX, dictInt.THIRD, dictInt.TI, dictInt.TX, dictInt.FIFTH, dictInt.TX, dictInt.TI, dictInt.TX, dictInt.SEVENTH]; -var IF_LYDIAN = [dictInt._ROOT, dictInt.TX, dictInt.TI, dictInt.TX, dictInt.THIRD, dictInt.TX, dictInt.SHARPELEVEN, dictInt.FIFTH, dictInt.TX, dictInt.TI, dictInt.TX, dictInt.SEVENTH]; -var IF_MIXOLYDIAN = [dictInt._ROOT, dictInt.TX, dictInt.TI, dictInt.TX, dictInt.THIRD, dictInt.TI, dictInt.TX, dictInt.FIFTH, dictInt.TX, dictInt.TI, dictInt.FLATSEVEN, dictInt.TX]; -var IF_DORIAN = [dictInt._ROOT, dictInt.TX, dictInt.TI, dictInt.FLATTHREE, dictInt.TX, dictInt.TI, dictInt.TX, dictInt.FIFTH, dictInt.TX, dictInt.TI, dictInt.FLATSEVEN, dictInt.TX]; -var IF_AEOLIAN = [dictInt._ROOT, dictInt.TX, dictInt.TI, dictInt.FLATTHREE, dictInt.TX, dictInt.TI, dictInt.TX, dictInt.FIFTH, dictInt.FLATTHIRTEEN, dictInt.TX, dictInt.FLATSEVEN, dictInt.TX]; -var IF_PHRYGIAN = [dictInt._ROOT, dictInt.FLATNINE, dictInt.TX, dictInt.FLATTHREE, dictInt.TX, dictInt.TI, dictInt.TX, dictInt.FIFTH, dictInt.FLATTHIRTEEN, dictInt.TX, dictInt.FLATSEVEN, dictInt.TX]; -var IF_LOCRIAN = [dictInt._ROOT, dictInt.FLATNINE, dictInt.TX, dictInt.FLATTHREE, dictInt.TX, dictInt.TI, dictInt.FLATFIVE, dictInt.TX, dictInt.FLATTHIRTEEN, dictInt.TX, dictInt.FLATSEVEN, dictInt.TX]; +var IF_IONIAN = [dictInt.ROOT, dictInt.TX, dictInt.TI, dictInt.TX, dictInt.THIRD, dictInt.TI, dictInt.TX, dictInt.FIFTH, dictInt.TX, dictInt.TI, dictInt.TX, dictInt.SEVENTH]; +var IF_LYDIAN = [dictInt.ROOT, dictInt.TX, dictInt.TI, dictInt.TX, dictInt.THIRD, dictInt.TX, dictInt.SHARPELEVEN, dictInt.FIFTH, dictInt.TX, dictInt.TI, dictInt.TX, dictInt.SEVENTH]; +var IF_MIXOLYDIAN = [dictInt.ROOT, dictInt.TX, dictInt.TI, dictInt.TX, dictInt.THIRD, dictInt.TI, dictInt.TX, dictInt.FIFTH, dictInt.TX, dictInt.TI, dictInt.FLATSEVEN, dictInt.TX]; +var IF_DORIAN = [dictInt.ROOT, dictInt.TX, dictInt.TI, dictInt.FLATTHREE, dictInt.TX, dictInt.TI, dictInt.TX, dictInt.FIFTH, dictInt.TX, dictInt.TI, dictInt.FLATSEVEN, dictInt.TX]; +var IF_AEOLIAN = [dictInt.ROOT, dictInt.TX, dictInt.TI, dictInt.FLATTHREE, dictInt.TX, dictInt.TI, dictInt.TX, dictInt.FIFTH, dictInt.FLATTHIRTEEN, dictInt.TX, dictInt.FLATSEVEN, dictInt.TX]; +var IF_PHRYGIAN = [dictInt.ROOT, dictInt.FLATNINE, dictInt.TX, dictInt.FLATTHREE, dictInt.TX, dictInt.TI, dictInt.TX, dictInt.FIFTH, dictInt.FLATTHIRTEEN, dictInt.TX, dictInt.FLATSEVEN, dictInt.TX]; +var IF_LOCRIAN = [dictInt.ROOT, dictInt.FLATNINE, dictInt.TX, dictInt.FLATTHREE, dictInt.TX, dictInt.TI, dictInt.FLATFIVE, dictInt.TX, dictInt.FLATTHIRTEEN, dictInt.TX, dictInt.FLATSEVEN, dictInt.TX]; // scales @@ -214,10 +235,9 @@ var INTCLR_PENTMAJ = ["i_root", "white","black","white","i_third","white","white var INTCLR_PENTDOM = ["i_root", "white","black","white","i_third","white","white","i_fifth","white","white","black","white"]; var INTCLR_PENTMINMEL = ["i_root", "white","black","i_third","white","white","white","i_fifth","white","black","white","white"]; - var SC_MAJOR = { "ngtype": SCALE, "varname" : "MAJOR", "name" : "Ionian", "intnames": INTS_FLATS, "color" : INTCLR_IONIAN }; var SC_LYDIAN = { "ngtype": SCALE, "varname" : "LYDIAN", "name" : "Lydian", "intnames": INTS_SHARP4, "color" : INTCLR_LYDIAN }; -var SC_MIXOLYDIAN = { "ngtype": SCALE, "varname" : "MIXOLYDIAN", "name" : "Mixolydian", "intnames": INTS_FLATS, "color" : INTCLR_MIXOLYDIAN }; +var SC_MIXOLYDIAN = { "ngtype": SCALE, "varname" : "MIXOLYDIAN", "name" : "Mixolydian", "intnames": INTS_DOM, "color" : INTCLR_MIXOLYDIAN }; var SC_DORIAN = { "ngtype": SCALE,"varname" : "DORIAN", "name" : "Dorian", "intnames": INTS_FLATS, "color" : INTCLR_DORIAN }; var SC_AEOLIAN = { "ngtype": SCALE, "varname" : "AEOLIAN", "name" : "Aeolian", "intnames": INTS_FLATS, "color" : INTCLR_AEOLIAN }; var SC_PHRYGIAN = { "ngtype": SCALE, "varname" : "PHRYGIAN", "name" : "Phrygian", "intnames": INTS_FLATS, "color" : INTCLR_PHRYGIAN }; @@ -326,6 +346,36 @@ var dictChords={ //"CHD_MAJDROP2" : CHD_MAJDROP2 } +var Notegroups = { + "MAJ":ARP_MAJ, + "MAJ7":ARP_MAJ7, + "DOM7":ARP_DOM7, + "MIN":ARP_MIN, + "MIN7":ARP_MIN7, + "MIN7b5":ARP_MIN7b5, + "DIM":ARP_DIM, + "MAJOR":SC_MAJOR, + "LYDIAN":SC_LYDIAN, + "MIXOLYDIAN":SC_MIXOLYDIAN, + "DORIAN":SC_DORIAN, + "AEOLIAN":SC_AEOLIAN, + "PHRYGIAN":SC_PHRYGIAN, + "LOCRIAN":SC_LOCRIAN, + "DIMINISHED":SC_DIMINISHED, + "MINHARM":SC_MINHARM, + "MINMEL":SC_MINMEL, + "ALTERED":SC_ALTERED, + "LYDIANDOM":SC_LYDIANDOM, + "PHRYGDOM":SC_PHRYGDOM, + "LYDIANAUG":SC_LYDIANAUG, + "MINNAT":SC_MINNAT, + "MINJAZZ":SC_MINJAZZ, + "PENTMIN":SC_PENTMIN, + "PENTMAJ":SC_PENTMAJ, + "PENTDOM":SC_PENTDOM, + "PENTMELMIN":SC_PENTMELMIN +} + var FretboardModel = { // model to hold current Key, Notegroup and NG type for fretboard "chromNames" : CHROMFLAT, @@ -420,9 +470,7 @@ var FretboardModel = { }, "getNGintcolor" : function(){ - var dict = this["ngType"]; - var ng = dict[this["ng"]]; - return ng["color"]; // returns array of css colors + return this["ngType"][this["ng"]]["color"]; }, "getNGintnames" : function(){ var dict = this["ngType"]; diff --git a/boxfrets.js b/boxfrets.js index 24007b8..d541fcf 100644 --- a/boxfrets.js +++ b/boxfrets.js @@ -200,6 +200,7 @@ var create_link_from_fretboard = function(){ href += '#'; href += "strings=" + uri_diagram_repr(GUITAR_STRINGS); href += "&key="+mFB.getKeyObj().safename; + href +="&ng="+mFB.getNotegroup().varname; href += "&intColor="+COLORBYINTERVALS; href += "&intNames="+INTERVALMODE; href += "&diagram_title=" + escape($('#diagram_title').val()); @@ -446,6 +447,7 @@ var set_notespans = function(){ var ctrl_updateMessage = function(){ if(COLORBYINTERVALS){ var msg = "Painting notes for "+mFB.getKeyTextName(); + // update link url if(mFB.getNotegroupDict() != dictArps){msg += " ";} msg += mFB.getNotegroup().name+""; $('#message').html(msg); @@ -1278,20 +1280,6 @@ $('input[name=sp_Color][value=pallete]').prop("checked",true); var url_params = get_url_parameters(); var loadFromUrl = function(){ -// interval color or pallete color switched by url params - if (is_defined(url_params['intColor'])){ - if(url_params['intColor'] == "true"){ - - ctl_updateColorIntMode(true); - } - } - -// interval names or note names switched by url params - if (is_defined(url_params['intNames'])){ - if(url_params['intNames'] == "true"){ - ctl_updateIntervalMode(true); - } - } // per url params, put notegroups in abridged dashboard playermodel area if (is_defined(url_params['dash'])){ var arrNotgroups = url_params['dash']; @@ -1323,6 +1311,31 @@ $('input[name=sp_Color][value=pallete]').prop("checked",true); // key should use safename, eg 'Cnatural' ctl_change_key.setRoot(getKeyObjFromSafeName(url_params['key'])); } + + // Change painting as Notegroup (scale or arp) by url params + if (is_defined(url_params['ng'])){ + // check for valid notegroup and add to validNG + var validNG = false; + var keys =[]; + for (var key in Notegroups) { + if (Notegroups.hasOwnProperty(key)) { + keys.push(key); + } + } + for (var i = 0; i < keys.length; i++){ + if(url_params['ng'] == keys[i]){ + validNG =Notegroups[url_params['ng']]; + var s = validNG; + } + } + + if(validNG){ + // set notegroup in fretboard model to notegroup from URL + set_notes_per_notegroup(mFB.getKeySafeName(), validNG.ngtype, validNG.varname); + //mFB.setNotegroup(validNG, validNG.ngtype); + //ctrl_updateMessage(); + } + } } loadFromUrl(); update_link(); @@ -1594,15 +1607,36 @@ $('input[name=sp_Color][value=pallete]').prop("checked",true); // set start UI per Pref Model if(mPref.aPrefs.startNoteLabel != "note" ){ - // assumes we are not in interval mode - $('#modeNoteInt').click(); - $('input[name=sp_Label][value=int]').prop("checked",true); // set radio button in pref tab + if(!INTERVALMODE){ + // assumes we are not in interval mode + $('#modeNoteInt').click(); + $('input[name=sp_Label][value=int]').prop("checked",true); // set radio button in pref tab + } } if(mPref.aPrefs.startNoteColor != "pallete" ){ - // assumes we are not in color by interval mode - $('#colorByInterval').click(); - $('input[name=sp_Color][value=interval]').prop("checked",true);// set in pref tab + if(!COLORBYINTERVALS){ + // assumes we are not in color by interval mode + $('#colorByInterval').click(); + $('input[name=sp_Color][value=interval]').prop("checked",true);// set in pref tab + } } + + // interval color or pallete color switched by url params + if (is_defined(url_params['intColor'])){ + if(url_params['intColor'] == "true"){ + + ctl_updateColorIntMode(true); + } + } + +// interval names or note names switched by url params + if (is_defined(url_params['intNames'])){ + if(url_params['intNames'] == "true"){ + ctl_updateIntervalMode(true); + } + } + + // TODO: generate jTab // TODO: show chord in standard notation });