Skip to content

Commit

Permalink
option to force using all tracks
Browse files Browse the repository at this point in the history
  • Loading branch information
EFHIII committed Dec 5, 2023
1 parent ac416b3 commit 9a30aa0
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions drums/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ if(!(window.File && window.FileReader && window.FileList && window.Blob)) {
let currentMidi = null;
let settings;

FORCE_ALL_TRACKS = false;

(new URL(window.location.href)).searchParams.forEach((value, name) => {
switch(name) {
case 'all-tracks':
case 'all':
if(value.toLowerCase() === 'true') {
FORCE_ALL_TRACKS = true;
}
break;
}
});


function parseFile(file) {
//read the file
const reader = new FileReader()
Expand Down Expand Up @@ -420,9 +434,16 @@ function loadHTMLcontent() {
};
for(let i = currentMidi.tracks.length - 1; i >= 0; i--) {
// check if the instrument is empty
if(currentMidi.tracks[i].notes.length == 0 ||
!currentMidi.tracks[i].instrument.percussion) {
currentMidi.tracks.splice(i, 1);
if(FORCE_ALL_TRACKS) {
if(currentMidi.tracks[i].notes.length == 0) {
currentMidi.tracks.splice(i, 1);
}
}
else {
if(currentMidi.tracks[i].notes.length == 0 ||
!currentMidi.tracks[i].instrument.percussion) {
currentMidi.tracks.splice(i, 1);
}
}
}

Expand Down

0 comments on commit 9a30aa0

Please sign in to comment.