import { NON_HARMONIC_GM_ENTRIES } from './generalMIDI';
import looksLikeDrums from './looksLikeDrums';
import { NoteLane } from './types';

const drumNames = [
  "drum",
  "perc",
  "hat",
  "cym",
  "snare",
  "snr",
  "tom",
  "crash",
  "ride",
  "kick",
];

const removeDrumLanes = (noteLanes: NoteLane[]): NoteLane[] => {
  return noteLanes.filter((noteLane, index) => {
    if (drumNames.find((s) => noteLane.trackName.toLowerCase().includes(s))) {
      return false;
    }

    if (
      noteLane.program !== null &&
      NON_HARMONIC_GM_ENTRIES.includes(noteLane.program)
    ) {
      return;
    }

    if (looksLikeDrums(noteLane.notes)) {
      return false;
    }

    return true;
  });
}

export default removeDrumLanes;
