drum-machine add additional metronome values

This commit is contained in:
Trent Palmer 2020-05-29 08:31:31 -07:00
parent c17a49fbbe
commit d760af7cad
4 changed files with 201 additions and 30 deletions

View File

@ -11,5 +11,4 @@
### TODOS ### TODOS
* make sure metronome continues on volume, sound, or metronome BPM change * make sure metronome continues on volume, sound, or metronome BPM change
* add additional metronome speed values
* update bpm in drumpad when metronome playing * update bpm in drumpad when metronome playing

View File

@ -164,8 +164,7 @@ const metronome = (key) => {
}; };
const parseBPM = (key) => { const parseBPM = (key) => {
const bpm = parseInt(sessionStorage const bpm = parseInt(sessionStorage.getItem(key+'metronomeTempo'));
.getItem(key+'metronomeTempo').slice(-10).split(' ')[1]);
return Math.round(60000 / bpm); return Math.round(60000 / bpm);
}; };
@ -191,7 +190,7 @@ const initialSamples = () => {
sessionStorage.setItem(pad + "metronomeIsPlaying",false); sessionStorage.setItem(pad + "metronomeIsPlaying",false);
} }
if (!sessionStorage.hasOwnProperty(pad + "metronomeTempo")) { if (!sessionStorage.hasOwnProperty(pad + "metronomeTempo")) {
sessionStorage.setItem(pad + "metronomeTempo","Andante: 92 bpm"); sessionStorage.setItem(pad + "metronomeTempo","92");
} }
}); });
if (!sessionStorage.hasOwnProperty("Q")) { if (!sessionStorage.hasOwnProperty("Q")) {

View File

@ -44,8 +44,8 @@ const makeMetronomeSelection = (selection) => {
$('#display-middle-left-b').html((drumPadGrid)); $('#display-middle-left-b').html((drumPadGrid));
$('#menuScrollTip').remove(); $('#menuScrollTip').remove();
makeAudioControl(padSelectingFor); makeAudioControl(padSelectingFor);
} else if (selection.includes('bpm')) { } else if (selection.match(/\d{2,3}/)) {
sessionStorage.setItem(padSelectingFor + 'metronomeTempo',selection); sessionStorage.setItem(padSelectingFor + 'metronomeTempo',selection.split(':')[1]);
sessionStorage.setItem(padSelectingFor + 'isMetronome',true); sessionStorage.setItem(padSelectingFor + 'isMetronome',true);
metronomeMenuDisplayed = false; metronomeMenuDisplayed = false;
$('#display-middle-left-b').html((drumPadGrid)); $('#display-middle-left-b').html((drumPadGrid));
@ -67,7 +67,14 @@ const makeMetronomeSelection = (selection) => {
const showMetronomeMenu = () => { const showMetronomeMenu = () => {
const selectionMenu = Object.keys(metronomeTempos) const selectionMenu = Object.keys(metronomeTempos)
.map(item => (makeMetronomeSelectionMenuItem(item + ": " + metronomeTempos[item]))); .map(item => (makeMetronomeSelectionMenuItem((() => {
const metronomeStringArray = item.split(' ');
if (metronomeStringArray.length === 2) {
return metronomeStringArray[0] + ': ' + metronomeTempos[item].slice(0,-4);
} else {
return metronomeStringArray[0] + ' ' + metronomeStringArray[1] + ': ' + metronomeTempos[item].slice(0,-4);
}
})())));
selectionMenu.unshift(makeMetronomeSelectionMenuItem('Metronome Off')); selectionMenu.unshift(makeMetronomeSelectionMenuItem('Metronome Off'));
showMetronomeSelectionMenuItems(selectionMenu); showMetronomeSelectionMenuItems(selectionMenu);
@ -110,7 +117,7 @@ const makeMetronomeSelectionMenuItemToolTipContent = (text) => {
} else if (text === '( cancel -- back )') { } else if (text === '( cancel -- back )') {
return text; return text;
} else { } else {
return 'set metronome temp for ' + padSelectingFor + ': ' + text.split(':')[1]; return 'set metronome temp for ' + padSelectingFor + ': ' + text.split(':')[1] + ' bpm';
} }
} }

View File

@ -1,24 +1,190 @@
const metronomeTempos = { const metronomeTempos = {
'Larghissimo': '20 bpm', 'Larghissimo 20': '20 bpm',
'Adagissimo': '24 bpm', 'Larghissimo 21': '21 bpm',
'Grave': '35 bpm', 'Larghissimo 22': '22 bpm',
'Largo': '50 bpm', 'Larghissimo 23': '23 bpm',
'Lento': '53 bpm', 'Adagissimo 24': '24 bpm',
'Larghetto': '63 bpm', 'Adagissimo 25': '25 bpm',
'Adagio': '71 bpm', 'Adagissimo 26': '26 bpm',
'Adagietto': '75 bpm', 'Adagissimo 27': '27 bpm',
'Marcia moderato': '84 bpm', 'Adagissimo 28': '28 bpm',
'Andante': '92 bpm', 'Adagissimo 29': '29 bpm',
'Andantino': '94 bpm', 'Adagissimo 30': '30 bpm',
'Andante moderato': '95 bpm', 'Adagissimo 31': '31 bpm',
'Moderato': '105 bpm', 'Adagissimo 32': '32 bpm',
'Allegretto': '106 bpm', 'Adagissimo 33': '33 bpm',
'Allegro moderato': '118 bpm', 'Adagissimo 34': '34 bpm',
'Allegro': '138 bpm', 'Grave 35': '35 bpm',
'Vivace': '166 bpm', 'Grave 36': '36 bpm',
'Vivacissimo': '174 bpm', 'Grave 37': '37 bpm',
'Allegrissimo': '174 bpm', 'Grave 38': '38 bpm',
'Allegro vivace': '174 bpm', 'Grave 39': '39 bpm',
'Presto': '184 bpm', 'Grave 40': '40 bpm',
'Prestissimo': '205 bpm', 'Grave 41': '41 bpm',
'Grave 42': '42 bpm',
'Grave 43': '43 bpm',
'Grave 44': '44 bpm',
'Grave 45': '45 bpm',
'Grave 46': '46 bpm',
'Grave 47': '47 bpm',
'Grave 48': '48 bpm',
'Grave 49': '49 bpm',
'Largo 50': '50 bpm',
'Largo 51': '51 bpm',
'Largo 52': '52 bpm',
'Lento 53': '53 bpm',
'Lento 54': '54 bpm',
'Lento 55': '55 bpm',
'Lento 56': '56 bpm',
'Lento 57': '57 bpm',
'Lento 58': '58 bpm',
'Lento 59': '59 bpm',
'Lento 60': '60 bpm',
'Lento 61': '61 bpm',
'Lento 62': '62 bpm',
'Larghetto 63': '63 bpm',
'Larghetto 64': '64 bpm',
'Larghetto 65': '65 bpm',
'Larghetto 66': '66 bpm',
'Larghetto 67': '67 bpm',
'Larghetto 68': '68 bpm',
'Larghetto 69': '69 bpm',
'Larghetto 70': '70 bpm',
'Adagio 71': '71 bpm',
'Adagio 72': '72 bpm',
'Adagio 73': '73 bpm',
'Adagio 74': '74 bpm',
'Adagietto 75': '75 bpm',
'Adagietto 76': '76 bpm',
'Adagietto 77': '77 bpm',
'Adagietto 78': '78 bpm',
'Adagietto 79': '79 bpm',
'Adagietto 80': '80 bpm',
'Adagietto 81': '81 bpm',
'Adagietto 82': '82 bpm',
'Adagietto 83': '83 bpm',
'Marcia moderato 84': '84 bpm',
'Marcia moderato 85': '85 bpm',
'Marcia moderato 86': '86 bpm',
'Marcia moderato 87': '87 bpm',
'Marcia moderato 88': '88 bpm',
'Marcia moderato 89': '89 bpm',
'Marcia moderato 90': '90 bpm',
'Marcia moderato 91': '91 bpm',
'Andante 92': '92 bpm',
'Andante 93': '93 bpm',
'Andantino 94': '94 bpm',
'Andante moderato 95': '95 bpm',
'Andante moderato 96': '96 bpm',
'Andante moderato 97': '97 bpm',
'Andante moderato 98': '98 bpm',
'Andante moderato 99': '99 bpm',
'Andante moderato 100': '100 bpm',
'Andante moderato 101': '101 bpm',
'Andante moderato 102': '102 bpm',
'Andante moderato 103': '103 bpm',
'Andante moderato 104': '104 bpm',
'Moderato 105': '105 bpm',
'Allegretto 106': '106 bpm',
'Allegretto 107': '107 bpm',
'Allegretto 108': '108 bpm',
'Allegretto 109': '109 bpm',
'Allegretto 110': '110 bpm',
'Allegretto 111': '111 bpm',
'Allegretto 112': '112 bpm',
'Allegretto 113': '113 bpm',
'Allegretto 114': '114 bpm',
'Allegretto 115': '115 bpm',
'Allegretto 116': '116 bpm',
'Allegretto 117': '117 bpm',
'Allegro moderato 118': '118 bpm',
'Allegro moderato 119': '119 bpm',
'Allegro moderato 120': '120 bpm',
'Allegro moderato 121': '121 bpm',
'Allegro moderato 122': '122 bpm',
'Allegro moderato 123': '123 bpm',
'Allegro moderato 124': '124 bpm',
'Allegro moderato 125': '125 bpm',
'Allegro moderato 126': '126 bpm',
'Allegro moderato 127': '127 bpm',
'Allegro moderato 128': '128 bpm',
'Allegro moderato 129': '129 bpm',
'Allegro moderato 130': '130 bpm',
'Allegro moderato 131': '131 bpm',
'Allegro moderato 132': '132 bpm',
'Allegro moderato 133': '133 bpm',
'Allegro moderato 134': '134 bpm',
'Allegro moderato 135': '135 bpm',
'Allegro moderato 136': '136 bpm',
'Allegro moderato 137': '137 bpm',
'Allegro 138': '138 bpm',
'Allegro 139': '139 bpm',
'Allegro 140': '140 bpm',
'Allegro 141': '141 bpm',
'Allegro 142': '142 bpm',
'Allegro 143': '143 bpm',
'Allegro 144': '144 bpm',
'Allegro 145': '145 bpm',
'Allegro 146': '146 bpm',
'Allegro 147': '147 bpm',
'Allegro 148': '148 bpm',
'Allegro 149': '149 bpm',
'Allegro 150': '150 bpm',
'Allegro 151': '151 bpm',
'Allegro 152': '152 bpm',
'Allegro 153': '153 bpm',
'Allegro 154': '154 bpm',
'Allegro 155': '155 bpm',
'Allegro 156': '156 bpm',
'Allegro 157': '157 bpm',
'Allegro 158': '158 bpm',
'Allegro 159': '159 bpm',
'Allegro 160': '160 bpm',
'Allegro 161': '161 bpm',
'Allegro 162': '162 bpm',
'Allegro 163': '163 bpm',
'Allegro 164': '164 bpm',
'Allegro 165': '165 bpm',
'Vivace 166': '166 bpm',
'Vivace 167': '167 bpm',
'Vivace 168': '168 bpm',
'Vivace 169': '169 bpm',
'Vivace 170': '170 bpm',
'Vivace 171': '171 bpm',
'Vivace 172': '172 bpm',
'Vivace 173': '173 bpm',
'Vivacissimo 174': '174 bpm',
'Allegrissimo 174': '174 bpm',
'Allegro vivace 174': '174 bpm',
'Allegro vivace 175': '175 bpm',
'Allegro vivace 176': '176 bpm',
'Allegro vivace 177': '177 bpm',
'Allegro vivace 178': '178 bpm',
'Allegro vivace 179': '179 bpm',
'Allegro vivace 180': '180 bpm',
'Allegro vivace 181': '181 bpm',
'Allegro vivace 182': '182 bpm',
'Allegro vivace 183': '183 bpm',
'Presto 184': '184 bpm',
'Presto 185': '185 bpm',
'Presto 186': '186 bpm',
'Presto 187': '187 bpm',
'Presto 188': '188 bpm',
'Presto 189': '189 bpm',
'Presto 190': '190 bpm',
'Presto 191': '191 bpm',
'Presto 192': '192 bpm',
'Presto 193': '193 bpm',
'Presto 194': '194 bpm',
'Presto 195': '195 bpm',
'Presto 196': '196 bpm',
'Presto 197': '197 bpm',
'Presto 198': '198 bpm',
'Presto 199': '199 bpm',
'Presto 200': '200 bpm',
'Presto 201': '201 bpm',
'Presto 202': '202 bpm',
'Presto 203': '203 bpm',
'Presto 204': '204 bpm',
'Prestissimo 205': '205 bpm',
}; };