Advertisement
okoda

PJSMP (RE) - module: player - v1.0

Sep 7th, 2020 (edited)
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         PJSMP (RE) - module: player
  3. // @version      1.0
  4. // @description  PJSMP (RE) - Pure JavaScript Midi Player (Remake), PJSMP module that plays MIDI files in Multiplayer Piano
  5. // @author       NaN-NaN-senpai(BR)
  6. // @include      *://www.multiplayerpiano.com/*
  7. // @include      *://piano.ourworldofpixels.com/*
  8. // @include      *://mpp.terrium.net/*
  9. // @grant        none
  10. // ==/UserScript==
  11.  
  12. window.PJSMP_mp__version = "1.0";
  13. window.PJSMP_mp__moduleName = "PJSMP (RE) - module: player";
  14. window.PJSMP_mp__moduleFullName = "Pure JavaScript Midi Player (Remake) - module: player";
  15. window.PJSMP_mp__changeLog = `
  16.                                     MIDI TO JSON, MADE BY ToneJs: https://tonejs.github.io/
  17.                                     ToneJs's GITHUB: https://github.com/Tonejs
  18.                                    SCRIPT FOR MULTIPLEYR PIANO BY: Luís Henrique de Almeida
  19.                                    (aka NaN-NaN-senpai(BR), HN Sine and Okóda Bérich)
  20.  
  21.                                    Luís Henrique's SOCIAL MIDIAS:
  22.                                         GITHUB: https://github.com/NaN-NaN-sempai
  23.                                         PASTEBIN: https://pastebin.com/u/okoda
  24.                                         YOUTUBE: https://www.youtube.com/user/sonic9818
  25.                                         SOUNDCLOUD: https://soundcloud.com/hn-sine
  26.                                         FACEBOOK: https://www.facebook.com/luisinho.crei.crei
  27.                                         INSTAGRAM: https://www.instagram.com/luis_hnrique/
  28.                                         TWITTER: https://twitter.com/LuisHN4444
  29.  
  30.  
  31. STAY UPDATED WITH NEWER VERSIONS OF THIS AND OTHERS SCRIPTS IN MY PASTEBIN PAGE: https://pastebin.com/u/okoda
  32.  
  33.  
  34. _________________________________________________________DESCRIPTION_____________________________________________________________
  35.  
  36. THIS IS THE NEW VERSION OF THE PJSMP - Pure JavaScript Midi Player, PJSMP (RE) - Pure JavaScript Midi Player (Remake).
  37. THE OLD VERSION IN BEEING DISCONTINUED AND TRANSLATED TO THIS NEW VERSION.
  38.  
  39. PJSMP (RE) IS A MIDI PLAYER FOR MULTIPLAYER PIANO, IT IS MODULAR SO EACH MODULE OPERATES A DIFRENT FUNCTION.
  40. THE NEW VERSION ALSO WORKS WITH OUR WORLD OF PIXELS PIANO: https://piano.ourworldofpixels.com/
  41. AND MPP.TERRIUM: https://mpp.terrium.net/
  42.  
  43. PJSMP (RE) - module: player (THIS ONE)
  44.     THE MAIN MODULE THAT READ AND PLAY THE MIDI FILES.
  45.  
  46.  
  47. _________________________________________________________HOW TO USE______________________________________________________________
  48.  
  49. TO INSTAL AND USE THIS SCRIPT IS REALLY SIMPLY.
  50. METHOD 1:
  51.     THIS METHOD WORKS ONCE PER PAGE, IF YOU REFRESH OR QUITE THE MULTIPLAYER PIANO TAB YOU WILL NEED TO DO THIS METHOD AGAIN.
  52.     - COPY THIS WHOLE CODE.
  53.     - ON THE MULTIPLAYER PIANO TAB, OPEN YOUR BROWSER'S DEV TOOLS:
  54.        > IF YOU ARE ON WINDOWS AND USING GOOGLE CHROME, JUST PRESS  CTRL + SHIFT + I OR F12. IN ANOTHERS BROWSERS THIS MAY WORK TOO.
  55.        > IF YOU ARE IN GOOGLE CHROME, USING THE MOUSE, CLICK IN THE "CUSTOMIZE AND CONTROL" BUTTON (THE THREE DOTS IN THE TOP RIGHT CORNER) AND PRESS IN "MORE TOOLS", THEN IN "DEVELOPER TOOLS". MIGHT WORK IN ANOTHERS BROWSERS TOO.
  56.        > IF YOU ARE NOT ON WINDOWS, RIGHT CLICK SOMEWHERE IN THE PAGE, THEN CLICK IN "INSPECT".
  57.        > IF NONE OF THESE WAYS WORKED, SEARCH HOW TO OPEN THE DEVELOPER TOOLS TAB IN YOU BROWSER.
  58.    - NAVIGATE TO THE "CONSOLE" TAB IN THE TOP OF THE DEV TOOLS WINDOW.
  59.    - PASTE THE CODE IN THE TEXTAREA IN THE BOTTOM OF THE CONSOLE AND PRESS ENTER.
  60.  
  61. METHOD 2:
  62.    THIS METHOD WILL AWAYS WORK EVEN IF YOU REFRESH THE PAGE.
  63.    - COPY THIS WHOLE CODE.
  64.    - INSTALL TAMPERMONKEY OR GREASYMONEKY EXTENSIONS TO YOUR BROWSER, THIS MIGHT WORK WITH OTHERS USERSCRIPTS TOOLS.
  65.    - CLICK ON THE EXTENSION ICON. IN GOOGLE CHROME, IT STAYS AT THE TOP RIGHT OF THE WINDOW, IF IT DOESN'T SHOW UP, CLICK IN THE EXTENSION ICON (A PUZZLE FIGURE).
  66.     - CLICK IN "ADD NEW SCRIPT...".
  67.     - DELETE THE PRE CREATED SCRIPT.
  68.     - PASTE THE NEW SCRIPT AND SAVE, CTRL + S OR CLICK IN "FILE", THEN "SAVE".
  69.     - IF THE MULTIPLAYER PIANO TAB IS OPENED, REFRESH IT AND THE CODE WILL BE WORKING JUST FINE.
  70.  
  71. IF THE CODE DIDN'T WORK OR YOU CAUGHT ANY BUG OR ERROR THAT IS NOT LISTED IN THE "BUGS AND ISSUES" AREA, IN THE BOTTOM OF THE CHANGE LOG TEXT, THEN CONTACT ME IN ANY OF MY SOCIAL MIDIAS, THEY ARE IN THE TOP OF THIS TEXT.
  72.  
  73. STAY UPDATED WITH NEWER VERSIONS OF THIS AND OTHERS SCRIPTS IN MY PASTEBIN PAGE: https://pastebin.com/u/okoda
  74.  
  75.  
  76. _____________________________________________________WORKING IN PROGRESS_________________________________________________________
  77.  
  78. WORKING IN PROGRESS:
  79.    WORKING ON THE MIDI CONTROLLER MODULE!
  80.  
  81. FUTURE IDEAS:
  82.    - TRACK CONTROLLER MODULE: CONTROL EACH TRACK SEPARADATELY.
  83.    - MIDI CONTROL MODULE: MODULE TO ADD EFFECTS TO THE NOTES.
  84.  
  85.  
  86. __________________________________________________________CHANGE LOG_____________________________________________________________
  87.  
  88. 1.0 FEATURE [FINAL VERSION]:
  89.    - SCRIPT: OVERALL CODE ORGANIZATION.
  90.    - MINIMIZE PROGRAM: IF YOU HOVER THE MOUSE IN THE "PJSMP (RE) - module: player" TEXT A LITTLE BUTTON WILL APPEAR IN THE RIGHT CORNER, BY CLICKNG IT THE PROGRAM WILL MINIMIZE TO A SMALL VERSION. IF YOU HOVER THE MINIMIZED PRGRAM, YOU SEE THE NAME OF THE MIDI FILE AND THE DURATION OF THE SONG.
  91.    - DRAG AND DROP: BY HOLDING THE CLICK IN THE "PJSMP (RE) - module: player" TEXT, IN THE TOP OF THE PROGRAM WINDOW, YOU CAN MOVE THE PROGRAM AND PLACE IR WHATEVER YOU WANT.
  92.    - UI CHANGES: THE PROGRAM WINDOW FINALLY HAVE A BORDER.
  93.    - OPEN CHANGE LOG: BY CLICKING IN THE "MADE BY: NaN-NaN-senpai(BR)" TEXT IN THE BOTTOM OF THE PROGRAM WINDOW, A NEW TAB WILL OPEN CONTAINIG THE CHAGELOG.
  94.  
  95. 0.09  FEATURES [NOTES PER SECOND]:
  96.    - NOTE PER SECOND: LITTLE TAB TO SHOW THE NOTES BEEING PLAYED BY THIS SCRIPT.
  97.  
  98. 0.08 FEATURES [TRANSPOSE AND MORE]:
  99.    - ASYNCHRONY BUTTON: NEW BUTTON TO GIVE A RANDOM TIMING TO THE NOTES.
  100.    - NOTEQUOTA BUTTON: NEW BUTTON TO PREVENT THE SONG OF STOPING WHILLE PLAYING A LOT OF NOTES, IT WORKS ONLY FOR THE MIDI PLAYER USER, THE OTHER PLAYERS WILL HEAR IT BEEING CUTTED.
  101.    - FILE INFO: HOVER THE SONG TITLE TO GET SOME INFO FROM THE MIDI FILE, THE AMOUNT OF TRACKS AND NOTES.
  102.    - TRANSPOSE INPUT: NEW INPUT TO CHANGE THE PITCH OF THE SONG.
  103.    - DURATION FEEDBACK: NOW THE DURATION OF THE SON IS VISIBLE IN THE PROGRAM WINDOW.
  104.    (0.08.5) => {
  105.        - (ERROR FIX) => NOTE AMOUNT: NOTE AMOUNT DOES NOT RETURN TO ZERO WHEN PLAYING OR PAUSING THE SONG ANYMORE.
  106.    }
  107.  
  108. 0.07 FEATURES [OCTAVE]:
  109.    - OCTAVE CHANGE: NEW INPUT TO CHANGE THE OCTAVE FROM THE SONG.
  110.    - mpp.terrium.net: NOW THE SCRIPT WORKS WITH MPP.TERRIUM.
  111.    - SPEED IMPROVEMENT: NOW THE SPEED INPUT CAN GO TO 0 WITHOUT ERRORS.
  112.  
  113. 0.06 FEATURES [LOOPS]:
  114.    - VERSION NAME: NEW VERSION NAMES IN THE FEATURES TO DESCRIBE THE VERSION FOCUS: "VERSION FEATURES [VERSION NAME]:", CAN ALSO BE USED IN SUBVERSIONS: "(VERSION)[VERSION NAME] => {...".
  115.    - SHOW VERSION AND MODULE: DISPLAYS IN THE CHAT THE VERSION BY SENDING THE MESSAGE "PJSMP VERSION".
  116.    - LOOP BUTTON: NEW LOOP SONG FUNCTION, RESTART THE SONG AT IT'S END IF ITS ON.
  117.     - NEW SYNTHAX FOR BUGS AND ISSUES: NEW SYNTHAX FOR ERRORS, GO TO THE BUGS AND ISSUES TO SEE MORE EXAMPLES:
  118.         [NEW SYNTHAX] => {
  119.             - ERROR NAME:
  120.             [REPORTED IN VERSION] [FIXED IN VERSION]<if its fixed>
  121.             [ATEMPT TO FIX OR TO RELIEVE IT IN VERSION] => ATEMPT DESCRIPTION.<if an atempt was done>
  122.             (! CRITICAL !)<if can stop the script> (ERROR HARM) (SINCE VERSION)
  123.                 (VERSION) => DESCRIPITION OR COMMENT ABOUT ERROR IN THIS VERSION.
  124.                 ERROR DESCRIPTION IN THE FIRST REPORTED VERSION.  
  125.         }
  126.     - MINNOR UI CHANGE: MOVED SLIDERS A BIT TO THE RIGHT, MORE CLOSER TO THE NEW OPTIONS BUTTONS DIV: "PJSMP_mp__fileDropContainer_textContainer".
  127.     - DEFAULTS IN HTML CREATION: NOW THE HTML ELEMENT IS USING THE CONTROLLERS DEFAULTS AS PARAMETERS.
  128.  
  129.  
  130. 0.05 FEATURES [SPEED]:
  131.     - SPEED INPUT: NEW SLIDER TO CHANGE SONGS SPEED.
  132.     - UI CHANGE (GOOGLE CHROME): NOW THE BUTTON OF THE INPUT NUMBERS DOESNT CUT IT'S VALUES ANYMORE, AND REMOVED ANIMATION.
  133.    (0.05.8)[TRANSLATION FIXES] => {
  134.        - UI UPDATES: LESS SPACE BETWEEN SLIDER'S BUTTONS, NEW EFECTS IN BUTTONS HOVER AND CLICK, GLOW IN SWITCHERS BUTTONS, AND BLUR IN THE PROGRAM BODY.
  135.         - CHANGE LOG: NEW "FIXED BUGS & ISSUES" IN THE BUGS AND ISSUES AREA TO SHOW THE ERRORS THAT HAS ALREADY BEEN FIXED.
  136.         - (ERROR FIX) => BACKGROUND COLOR: NOW IF THE COLOR URNS GRAY, THEN IT IS CHANGED TO A RANDOM COLOR.
  137.         - TRANSLATION: NOW ERRORS TEXTS CAN BE TRANSLATED. EXAMPLE: "PJSMP_mp__translate("text.error.midiPlayError")".
  138.         - TRANSLATION: NEW TRANSLATIONS SECTIONS. EXEMPLE: "PJSMP_mp__translate("sliders.speed")".
  139.         - TRANSLATION: NEW DEBUG OPTION FOR TRANSLATIONS: "PJSMP_mp__debugLenguage".
  140.     }
  141.     (0.05.7) => {
  142.         - CHANGE LOG: THE NEW "HOW TO USE" AREA, IN THE CHANGE LOG TEXT, SHOWS HOW TO INSTAL AND USE THE SCRIPT.
  143.     }
  144.     (0.05.6) => {
  145.         - (ERROR FIX) => TAMPERMONKEY/GREASEMONKEY: NOW PJSMP FULLY WORKS WITH TAMPERMONKEY AND GREASYMONKEY.
  146.         - CHANGE LOG: SOME NEW SYNTHAX FOR THE CHANGE LOG TEXT:
  147.             [NEW SYNTHAXES] = {
  148.                 HYPHEN BEFORE ITENS: "- ITEN NAME: ITEN TEXT DESCRIPITION".
  149.                 MULTI ITENS CANTAINERS: "TEXT: [CONTAINER TITLE] = { ITEN: DESCRIPITION. ANOTHER ITEN: DESCRIPITION. ETC... }".
  150.                 FEATURES FOR ERROR FIXES: "- (ERROR FIX) => NAME OF THE ERROR: ERROR TEXT DESCRIPITION".
  151.                 BUGS AND ISSUES: "optional->{[FIX STAGE]} optional->{=> FIX DESCRIPTION} - ERROR NAME: optional->{(! CRITICAL !)} (ERROR HARM) (SINCE VERSION) ERROR DESCRIPITION.".
  152.             }
  153.     }
  154.     (0.05.5) => {
  155.         - (ERROR FIX) => TRANSLATION: FIXED THE ERROR WITH THE NON SUPORTED LENGUAGES, NOW THE PROGRAM WILL BE TRANSLATED TO ENGLISH IF THE LENGUAGE IS NOT SUPORTED.
  156.     }
  157.  
  158. 0.04 FEATURES [VELOCITY SLIDER]:
  159.     - VELOCITY INCREMENT: A NEW SLIDER TO INCREMENT THE VELOCITY OF THE NOTES.
  160.         [IN THIS NEW SCRIPT THE SLIDERS WILL HAVE A NEW PATTER] = {
  161.             SLIDER: SLIDER TO CHANGE THE VALUE WITH SOME LIMITS.
  162.             INPUT: INPUT TO CHANGE THE VALUE INFINITELY.
  163.             FIX BUTTON: RETURNS VALUE TO DEFAULT VALUE.
  164.             STATE SWITCHER BUTTON: DISPLAY THE NAME OF THE EFFECT AND TURNS ON OR OFF THE EFFECT.
  165.         }
  166.     - COLOR SET: NEW VARIABLE TO SAVE AND REUSE COLORS FOR THE SCRIPT.
  167.     - COLOR EFFECT: THE BUTTONS THAT ARE ON BECOME GREEN, AND THE ONE THAT ARE OFF TURNS RED.
  168.  
  169. 0.03 FEATURES [PAUSE]:
  170.     - PLAY/PAUSE/STOP: ALL BASIC FUNCTIONS ARE NOW WORKING JUST FINE.
  171.     - ERROR CATCHERS: PREVENT AND CATCH ERRORS AND BUGS.
  172.  
  173. 0.02 FEATURES [PLAY AND STOP]:
  174.     - PLAY/PAUSE/STOP: THE PLAY AND STOP BUTTONS ARE WORKING JUST FINE, THE PAUSE STILL NEED SOME WORK.
  175.     - UI STYLE: STYLIZED THE FILE NAME FIELD. COPYED FROM THE OLD VERSION.
  176.  
  177. 0.01 FEATURES [FIRST WORKING VERSION]:
  178.     - WORKING: THE SCRIPT PLAYS MIDI FILES WHEN THEY ARE LOADED.
  179.     - TRANSLATIONS: THE SCRIPT CAN SUPORT TRANSLATIONS. RIGHT NOW THERE ARE THREE LENGUAGES: ENGLISH, PORTUGUESE AND RUSSIAN
  180.  
  181.  
  182. ________________________________________________________BUGS AND ISSUES__________________________________________________________
  183.    
  184. KNOWN BUGS & ISSUES:
  185.     - FREEZE TAB:
  186.     [REPORTED IN 0.06]
  187.     (SLIGHT DANGEROUS) (SINCE 0.01)
  188.         THE PAGE FREEZES WHEN BIG MIDI FILES LOADS, STARTS TO PLAY AND CHANGE SPEED. IT, POSSIBLE, CAN CRASH THE BROWSER.
  189.         TO PREVENT THE FREEZE WHEN THE SPEED IS BEEING CHANGED: PAUSE THE SONG, THEN CHANGE THE SPEED, THEN PLAY IT AGAIN.
  190.  
  191.     - DESYNCHRONIZATION IN TRACKS:
  192.     [REPORTED IN 0.05.6]
  193.     (SLIGHT ANNOYING) (SINCE 0.01)
  194.         (0.06) => HAPPENS MORE OFTEN WHEN THE BROWSER DEVELOPER TAB IS OPENED.
  195.         SOMETIMES THE TRACKS GET DESYNCHRONIZED, IT APPEAR TO BE THE LACK OF PROCESSING POWER OR SOMETHING TAKEING MUCH RAM ON THE PC.
  196.  
  197.     - BACKGROUND COLOR:
  198.     [REPORTED IN 0.05.6]
  199.     [PREVENT ERROR IMPROVISATION IN 0.05.8] => IF THE PROGRAM CATCHS THE GRAY COLOR AS THE PLAYER COLOR, IT TURNS TO A RANDOM COLOR INSTEAD.
  200.     (NOT HARMFUL) (SINCE 0.01)
  201.         SOMETIMES THE BACKGROUND COLOR DOESN'T GET THE PLAYER COLOR AND TURNS TO GRAY.
  202.  
  203.  
  204. FIXED BUGS & ISSUES:
  205.    - TAMPERMONKEY/GREASYMONKEY:
  206.    [REPORTED IN 0.05.6] [FIXED IN 0.05.6]
  207.    (! CRITICAL !) (RUNS BUT DOESN'T PLAY) (SINCE 0.01)
  208.         THE CODE DOESN'T REALLY WORKS AS A USERSCRIPT WITH TAMPERMONKEY OR GREASYMONKEY, IT RUNS ONLY BY PASTING IN THE CONSOLE.
  209.    
  210.    - TRANSLATIONS:
  211.    [REPORTED IN 0.05.6] [FIDED IN 0.05.6]
  212.    (! CRITICAL !) (DOESN'T RUN) (SINCE 0.01)
  213.         CODE GET TRANSLATION AS UNDEFINED AND SCRIPT CRASHES.
  214.  
  215.  
  216. _________________________________________________________________________________________________________________________________
  217.  
  218.  
  219.                                                 FEEL FREE TO EDIT THIS CODE.
  220. `;
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260. //____________________________________________________CODE STARTS HERE___________________________________________________________
  261.  
  262. window.PJSMP_mp__debugLenguage = undefined; //CHANGE THIS VALUE TO CHANGE THE LENGUAGE OF THE PROGRAM (BEFORE LOADING THE CODE)
  263. window.PJSMP_mp__translations = {
  264.     en: /* DEFALT LENGUAGE IN CASE OF UNDEFINED TRANSLATIONS */ {
  265.         play: "Play",
  266.         pause: "Pause",
  267.         stop: "Stop",
  268.         fix: "Fix",
  269.         options: {
  270.             sustain: "Sustain",
  271.             sustainTitle: "Keep notes sustained",
  272.             loop: "Loop",
  273.             loopTitle: "Restart the song at it's end",
  274.             asynchrony: "Asynchrony",
  275.             asynchronyTitle: "Add or remove a random asynchrony to the notes",
  276.             notequota: "NoteQuota",
  277.             notequotaTitle: "Remove the Client Side note quota\nBut the Server Side one still there\nYou will not be heard from others playes if it get in its's limit"
  278.         },
  279.         sliders: {
  280.             velocityIncrement: "Velocity Increment",
  281.             speed: "Song Speed"
  282.         },
  283.         origin: {
  284.             octave: "Origin Octave",
  285.             transpose: "Origin Pitch"
  286.         },
  287.         text: {
  288.             noMidiLoad: "No midi file loaded",
  289.             chooseMidi: "Choose a midi file",
  290.             error: {
  291.                 midiPlayError: "Unable to play midi file",
  292.                 midiLoadError: "Unable to load midi file"
  293.             },
  294.             tracks: "Tracks",
  295.             notes: "Notes",
  296.             notePerSecond: "Amount of notes per second requested by "+PJSMP_mp__moduleName+"\nDisable sustain for less requests",
  297.             openWindow: "Open program window",
  298.             closeWindow: "Minimize program window",
  299.             playing: "Now playing"
  300.         }
  301.     },
  302.     pt: {
  303.         play: "Tocar",
  304.         pause: "Pausar",
  305.         stop: "Parar",
  306.         fix: "Padrão",
  307.         options: {
  308.             sustain: "Sustentar",
  309.             sustainTitle: "Manter teclas precionadas",
  310.             loop: "Ciclo",
  311.             loopTitle: "Tocar novamente ao fim da música",
  312.             asynchrony: "Assincronia",
  313.             asynchronyTitle: "Adiciona ou remove uma assincronia aleatória nas notas",
  314.             notequota: "Limitador",
  315.             notequotaTitle: "Remove o limitador de notas do site\nMas o limitador do servido continua existindo\nVocê não sera ouvido pelos outros jogadores se o limite for ultrapassado"
  316.         },
  317.         sliders: {
  318.             velocityIncrement: "Acrescentar Velocidade",
  319.             speed: "Velocidade da Música"
  320.         },
  321.         origin: {
  322.             octave: "Origem da Oitava",
  323.             transpose: "Origem do Tom"
  324.         },
  325.         text: {
  326.             noMidiLoad: "Nem um arquivo midi",
  327.             chooseMidi: "Escolha um arquivo",
  328.             error: {
  329.                 midiPlayError: "Incapaz de tocar este arquivo",
  330.                 midiLoadError: "Incapar de carregar este arquivo"
  331.             },
  332.             tracks: "Trilhas",
  333.             notes: "Notas",
  334.             notePerSecond: "Quantidade de notas sendo enviadas pelo modulo "+PJSMP_mp__moduleName+"\nDesabilite o sustenar para enviar menos notas",
  335.             openWindow: "Abir programa",
  336.             closeWindow: "Minimizar programa",
  337.             playing: "Tocando"
  338.         }
  339.     },
  340.     /*
  341.         Извините, друзья русские, это просто гугл переводчик
  342.         Sorry russians friends, it is just Google Translator
  343.     */
  344.     ru: {
  345.         play: "Играть",
  346.         pause: "Пауза",
  347.         stop: "Стоп",
  348.         sustain: "Держать",
  349.         fix: "Шаблон",
  350.         sliders: {
  351.             velocityIncrement: "Добавить скорость",
  352.             speed: "Скорость музыки"
  353.         },
  354.         text: {
  355.             noMidiLoad:  "Midi-файл не загружен",
  356.             chooseMidi: "Выберите файл"
  357.         }
  358.     }
  359. };
  360.  
  361. window.PJSMP_mp__translate = (text) => {
  362.     var userLanguage = window.PJSMP_mp__debugLenguage || navigator.language || navigator.userLanguage;
  363.  
  364.     var selectedLeng = typeof PJSMP_mp__translations[userLanguage.substr(0,2)] == "undefined"? PJSMP_mp__translations["en"]:
  365.                     typeof leng == "string"? PJSMP_mp__translations[leng]:
  366.                     PJSMP_mp__translations[userLanguage.substr(0,2)];
  367.  
  368.     var textObj = text.replace(/\./g," ").split(" ");
  369.  
  370.     var returnTranslation;
  371.     var fixedReturnTranslation;
  372.     textObj.forEach((e)=>{
  373.         returnTranslation = (returnTranslation==undefined?selectedLeng:returnTranslation)[e];
  374.         fixedReturnTranslation = (fixedReturnTranslation==undefined?PJSMP_mp__translations["en"]:fixedReturnTranslation)[e];
  375.     });
  376.  
  377.     return returnTranslation == undefined? fixedReturnTranslation: returnTranslation;
  378. }
  379.  
  380. window.PJSMP_mp__playerColor = MPP.client.getOwnParticipant().color=="#777"?Math.floor(Math.random()*16777215).toString(16):MPP.client.getOwnParticipant().color;
  381. window.PJSMP_mp__convertHex = (hex, opacity) => {
  382.     if(hex.length == 4){
  383.         hex = hex[0] + hex[1] + hex[1] + hex[2] + hex[2] + hex[3] + hex[3];
  384.     }
  385.     hex = hex.replace('#','');
  386.     r = parseInt(hex.substring(0,2), 16);
  387.     g = parseInt(hex.substring(2,4), 16);
  388.     b = parseInt(hex.substring(4,6), 16);
  389.     return 'rgba('+r+','+g+','+b+','+(typeof opacity != "number"? 0.5: opacity)+')';
  390. }
  391.  
  392. window.PJSMP_mp__colors = { //PRESETED COLORS
  393.     on: "rgba(11, 133, 0, 1)",
  394.     off: "rgba(255, 34, 31, 1)",
  395.     darkerOn: "rgba(11, 50, 0, 1)",
  396.     darkerOff: "rgba(90, 14, 11, 1)",
  397.     darkerBg: "rgba(20, 20, 20, .7)",
  398.     secondBg: "rgba(157, 154, 150, 0.35)",
  399.  
  400.     bgColor: PJSMP_mp__convertHex(PJSMP_mp__playerColor),
  401.     bgColor2: PJSMP_mp__convertHex(PJSMP_mp__playerColor, .9)
  402. };
  403.  
  404. MPP.client.on("a", function (msg) { //SHOW VERSION COMMAND
  405.     if(["player version", "player v", "pjsmp version", "pjsmp v", "pjsmp module", "pjsmp m"].includes(msg.a.toLowerCase())){
  406.         var chatVHour = String(new Date().getHours()).padStart(2, "0")+":"+String(new Date().getMinutes()).padStart(2, "0");
  407.         var chatV = "("+chatVHour+"): ";
  408.         MPP.chat.send(chatV+"using "+PJSMP_mp__moduleName+" - v"+PJSMP_mp__version);
  409.     }
  410. });
  411.  
  412. window.PJSMP_mp__setBtnTextColor = (button, color, blur) => { //SET BUTTON COLLOR
  413.     button.style.color = color;
  414.     button.style.textShadow = "0px 0px "+(typeof blur != "number"? "5px": blur+"px")+" "+color;
  415. }
  416.  
  417. window.PJSMP_mp__controllers = { //PROGRAM CONTROLLERS
  418.     //BUTTONS
  419.     sustain: {
  420.         state: true
  421.     },
  422.     loop: {
  423.         state: false
  424.     },
  425.     asynchrony: {
  426.         state: false
  427.     },
  428.     notequota: {
  429.         state: false
  430.     },
  431.  
  432.     //SLIDERS
  433.     velocityIncrement: {
  434.         state: false,
  435.         value: 0,
  436.         default: 0
  437.     },
  438.     speed: {
  439.         state: false,
  440.         value: 1,
  441.         default: 1
  442.     },
  443.  
  444.     //ORIGIN CONTROLLERS
  445.     originOctave: {
  446.         state: true,
  447.         value: 0,
  448.         default: 0
  449.     },
  450.     originTranspose: {
  451.         state: true,
  452.         value: 0,
  453.         default: 0
  454.     }
  455. }
  456.  
  457. window.PJSMP_mp__windowMinimized = false;
  458.  
  459. window.PJSMP_mp__NPS = 0;
  460. var PJSMP_mp__NPS_interval = setInterval(()=>{ //NOTES PER SECOND
  461.     var retNPS = PJSMP_mp__NPS * (PJSMP_mp__controllers.sustain.state? 2: 1);
  462.     document.querySelector("#PJSMP_mp__NPSContainer_text").innerHTML = retNPS;
  463.     PJSMP_mp__NPS = 0;
  464. }, 1000);
  465.  
  466. if(!document.querySelector("#PJSMP_mp__mainContainer")){
  467.     //PROGRAM MAIN CONTAINER
  468.     var PJSMP_mp__mainContainer = document.createElement("div");
  469.     PJSMP_mp__mainContainer.id = "PJSMP_mp__mainContainer";
  470.     PJSMP_mp__mainContainer.style.position = "fixed";
  471.     PJSMP_mp__mainContainer.style.top = "30px";
  472.     PJSMP_mp__mainContainer.style.right = "30px";
  473.     PJSMP_mp__mainContainer.style.backdropFilter = "blur(1.5px)";
  474.  
  475.     //CSS STYLE TAG
  476.     var PJSMP_mp__CSS = document.createElement("style");
  477.     PJSMP_mp__CSS.innerHTML = `
  478.         #PJSMP_mp__window {
  479.             display: inline-block;
  480.             border: solid `+PJSMP_mp__colors.darkerBg+`;
  481.             border-radius: 10px 0px 10px 0px;
  482.             transition: .2s;
  483.         }
  484.  
  485.         #PJSMP_mp__mainContainer{
  486.             width: fit-content;
  487.         }
  488.         #PJSMP_mp__mainContainer .PJSMP_mp__buttonClass{
  489.             margin: 0px 0px 5px 5px;
  490.             padding: 5px;
  491.         }
  492.         #PJSMP_mp__mainContainer button{
  493.             background: rgba(60, 60, 60, 0.7);
  494.             border: 1px solid `+PJSMP_mp__colors.darkerBg+`;
  495.             cursor: pointer;
  496.             border-radius: 3px;
  497.             -webkit-border-radius: 3px;
  498.             -moz-border-radius: 3px;
  499.             color: white;
  500.             overflow: hidden;
  501.             white-space:nowrap;
  502.             outline: none;
  503.             text-shadow: none;
  504.             transition: background .2s, color .3s, text-shadow .3s;
  505.         }
  506.         #PJSMP_mp__mainContainer button:hover{
  507.             text-shadow: 0px 0px 2px white;
  508.             background: `+PJSMP_mp__colors.secondBg+`;
  509.         }
  510.         #PJSMP_mp__mainContainer button:active{
  511.             text-shadow: 0px 0px 5px white;
  512.             background: `+PJSMP_mp__colors.darkerBg+`;
  513.         }
  514.         #PJSMP_mp__mainContainer input[type=file]{
  515.             opacity: 0;
  516.             width: 0px;
  517.             height: 0px;
  518.             position: absolute;
  519.             pointer-events: none;
  520.         }
  521.  
  522.         #PJSMP_mp__fileDropContainer_textContainer{
  523.             font-size: 15px;
  524.             background: `+PJSMP_mp__colors.darkerBg+`;
  525.             border-radius: 7px 0px 0px 0px;
  526.             max-height: 30px;
  527.             overflow-y: auto;
  528.             width: 350px;
  529.         }
  530.         #PJSMP_mp__fileDropContainer_textContainer_text{
  531.             margin-left: 5px;
  532.             margin-right: 5px;
  533.         }
  534.         #PJSMP_mp__fileDropContainer_textContainer::-webkit-scrollbar-track{
  535.             -webkit-box-shadow: inset 0 0 6px rgba(255,255,255,0.3);
  536.             border-radius: 10px;
  537.             background-color: rgba(255, 255, 255, .1);
  538.         }
  539.         #PJSMP_mp__fileDropContainer_textContainer::-webkit-scrollbar{
  540.             width: 5px;
  541.             height: 5px;
  542.         }
  543.         #PJSMP_mp__fileDropContainer_textContainer::-webkit-scrollbar-thumb{
  544.             border-radius: 10px;
  545.             -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3);
  546.             background-color: `+PJSMP_mp__colors.darkerBg+`;
  547.         }
  548.  
  549.  
  550.         #PJSMP_mp__basicControllersContainer_options{
  551.             display: grid;
  552.             grid-template-columns: auto;
  553.             position: relative;
  554.             top: -10px;
  555.         }
  556.  
  557.         .inputRangeContainer{
  558.             display: grid;
  559.             grid-template-columns: auto auto auto;
  560.         }
  561.         .inputRangeContainer *{
  562.             outline: none;
  563.         }
  564.         .inputRangeSubContainer{
  565.             display: grid;
  566.             grid-gap: 5px;
  567.             position: relative;
  568.             bottom: 35px;
  569.             width: 43px;
  570.             overflow: hidden;
  571.             background-color: `+PJSMP_mp__colors.darkerBg+`;
  572.             border: `+PJSMP_mp__colors.darkerBg+` solid;
  573.             border-radius: 20px;
  574.             margin-left: 5px;
  575.         }
  576.         .inputRangeContainer input[type=range][orient=vertical]{
  577.             writing-mode: bt-lr; /* IE */
  578.             -webkit-appearance: slider-vertical; /* WebKit */
  579.             width: 8px;
  580.             height: 60px;
  581.             position: relative;
  582.             left: 50%;
  583.             bottom: -2px;
  584.             transform: translateX(-50%);
  585.         }
  586.         .inputRangeContainer input[type=number]{
  587.             background: `+PJSMP_mp__colors.darkerBg+`;
  588.             color: white;
  589.             text-align: center;
  590.             width: 92%;
  591.             border: none;
  592.             transition: 1s;
  593.         }
  594.         .inputRangeContainer input[type="number"]::-webkit-inner-spin-button{
  595.             cursor: pointer;
  596.             display: none;
  597.         }
  598.         .inputRangeContainer input[type="number"]:hover::-webkit-inner-spin-button{
  599.             display: inline;
  600.         }
  601.  
  602.         .oringinController{
  603.             margin-left: 3px;
  604.             margin-bottom: 5px;
  605.             height: fit-content;
  606.             width: fit-content;
  607.             background-color: `+PJSMP_mp__colors.darkerBg+`;
  608.             border: `+PJSMP_mp__colors.darkerBg+` solid;
  609.             border-radius: 10px;
  610.         }
  611.         .oringinController button{
  612.             position: relative;
  613.             top: -6px;
  614.         }
  615.         .oringinController input[type=number]{
  616.             position: relative;
  617.             top: -6px;
  618.             margin-left: 5px;
  619.             margin-top: 5px;
  620.             background: `+PJSMP_mp__colors.darkerBg+`;
  621.             width: 50px;
  622.             color: white;
  623.             text-align: center;
  624.             border: 1px solid `+PJSMP_mp__colors.secondBg+`;
  625.             border-radius: 5px;
  626.             transition: 1s;
  627.             outline: none;
  628.         }
  629.  
  630.         #PJSMP_mp__infoContainer{
  631.             margin-left: 5px;
  632.             width: fit-content;
  633.             display: grid;
  634.             grid-template-columns: auto auto auto auto;
  635.         }
  636.         #PJSMP_mp__infoContainer span, #PJSMP_mp__NPSContainer_text{
  637.             font-size: 10px;
  638.             text-align: center;
  639.             padding: 0px 2px 0px 2px;
  640.             margin-bottom: 5px;
  641.             background: `+PJSMP_mp__colors.darkerBg+`;
  642.             border: solid `+PJSMP_mp__colors.darkerBg+`;
  643.             border-radius: 25px;
  644.         }
  645.         #PJSMP_mp__NPSContainer {
  646.             position: absolute;
  647.             bottom: 0px;
  648.             right: 0px;
  649.             margin: 5px 5px 0px 5px;
  650.         }
  651.         #PJSMP_mp__NPSContainer span{
  652.             display: inline-block;
  653.             width: 35px;
  654.         }
  655.  
  656.         #PJSMP_mp__bottomName{
  657.             position: absolute;
  658.             bottom: -22px;
  659.             left: 0px;
  660.             height: 20px;
  661.             background: `+PJSMP_mp__colors.bgColor2+`;
  662.             border: solid `+PJSMP_mp__colors.darkerBg+`;
  663.             border-radius: 0px 0px 10px 10px;
  664.         }
  665.         #PJSMP_mp__bottomName span, #PJSMP_mp__dragAndDrop span{
  666.             font-size: 10px;
  667.             text-align: center;
  668.             padding: 0px 2px 0px 2px;
  669.             position: relative;
  670.             bottom: 65%;
  671.             transform: translateY(50%);
  672.             text-shadow: 0px 0px 2px white;
  673.             transition: 1s;
  674.         }
  675.         #PJSMP_mp__bottomName span:hover, #PJSMP_mp__dragAndDrop span:hover{
  676.             text-shadow: 0px 0px 4px white, 0px 0px 4px white;
  677.         }
  678.  
  679.         #PJSMP_mp__dragAndDrop{
  680.             position: absolute;
  681.             top: -22px;
  682.             right: 0px;
  683.             height: 20px;
  684.             width: max-content;
  685.             background: `+PJSMP_mp__colors.bgColor2+`;
  686.             border: solid `+PJSMP_mp__colors.darkerBg+`;
  687.             border-radius: 10px 10px 0px 0px;
  688.             cursor: move;
  689.             overflow: hidden;
  690.         }
  691.         #PJSMP_mp__dragAndDrop button{
  692.             float: right;
  693.             width: 0px;
  694.             height: 100%;
  695.             border-radius: 0px;
  696.             padding: 0px;
  697.             margin: 0px;
  698.             opacity: 0;
  699.             border: none;
  700.             transition: width 1.5s, margin 1.5s, opacity 1.5s, background .5s;
  701.         }
  702.         #PJSMP_mp__dragAndDrop:hover #PJSMP_mp__dragAndDrop_ocBtn{
  703.             margin: 0px 0px 0px 5px;
  704.             width: 17px;
  705.             opacity: 1;
  706.             transition: width .5s, margin .5s, opacity .5s, background .5s;
  707.         }
  708.     `;
  709.  
  710.     PJSMP_mp__mainContainer.appendChild(PJSMP_mp__CSS);
  711.  
  712.     //PROGRAM WINDOW
  713.     var PJSMP_mp__window = document.createElement("div");
  714.     PJSMP_mp__window.id = "PJSMP_mp__window";
  715.     PJSMP_mp__window.className = "PJSMP_mp__window";
  716.     PJSMP_mp__window.style.background = PJSMP_mp__colors.bgColor;
  717.  
  718.  
  719.     //FILEDROP SECTION START
  720.         var PJSMP_mp__fileDropContainer = document.createElement("div");
  721.         PJSMP_mp__fileDropContainer.id = "PJSMP_mp__fileDropContainer";
  722.  
  723.         var PJSMP_mp__fileDropContainer_textContainer = document.createElement("div");
  724.         PJSMP_mp__fileDropContainer_textContainer.id = "PJSMP_mp__fileDropContainer_textContainer";
  725.    
  726.         var PJSMP_mp__fileDropContainer_textContainer_text = document.createElement("p");
  727.         PJSMP_mp__fileDropContainer_textContainer_text.id = "PJSMP_mp__fileDropContainer_textContainer_text";
  728.         PJSMP_mp__fileDropContainer_textContainer_text.innerHTML = PJSMP_mp__translate("text.noMidiLoad");
  729.  
  730.         //input file
  731.         var PJSMP_mp__inputFile = document.createElement("input");
  732.         PJSMP_mp__inputFile.id = "PJSMP_mp__inputFile";
  733.         PJSMP_mp__inputFile.type = "file";
  734.         PJSMP_mp__inputFile.accept = "audio/midi";
  735.  
  736.         //choose midi button
  737.         var PJSMP_mp__fileDropBtn = document.createElement("button");
  738.         PJSMP_mp__fileDropBtn.id = "PJSMP_mp__fileDropBtn";
  739.         PJSMP_mp__fileDropBtn.className = "PJSMP_mp__buttonClass";
  740.         PJSMP_mp__fileDropBtn.innerHTML = PJSMP_mp__translate("text.chooseMidi");
  741.         PJSMP_mp__fileDropBtn.setAttribute("onclick", 'document.querySelector("#PJSMP_mp__inputFile").click()');
  742.  
  743.        
  744.         PJSMP_mp__fileDropContainer_textContainer.appendChild(PJSMP_mp__fileDropContainer_textContainer_text);
  745.         PJSMP_mp__fileDropContainer.appendChild(PJSMP_mp__fileDropContainer_textContainer)
  746.  
  747.         PJSMP_mp__fileDropContainer.appendChild(PJSMP_mp__inputFile);
  748.  
  749.         PJSMP_mp__window.appendChild(PJSMP_mp__fileDropContainer);
  750.         PJSMP_mp__window.appendChild(PJSMP_mp__fileDropBtn);
  751.         PJSMP_mp__window.appendChild(document.createElement("br"));
  752.     //FILEDROP SECTION END
  753.  
  754.  
  755.     //PLAY/PAUSE BUTTON
  756.     var PJSMP_mp__playBtn = document.createElement("button");
  757.     PJSMP_mp__playBtn.id = "PJSMP_mp__playBtn";
  758.     PJSMP_mp__playBtn.className = "PJSMP_mp__buttonClass";
  759.     PJSMP_mp__playBtn.innerHTML = PJSMP_mp__translate("play");
  760.     PJSMP_mp__playBtn.setAttribute("onclick", 'PJSMP_mp__playPauseButtonClick(this)');
  761.  
  762.     PJSMP_mp__window.appendChild(PJSMP_mp__playBtn)
  763.  
  764.     //STOP BUTTON
  765.     var PJSMP_mp__stopBtn = document.createElement("button");
  766.     PJSMP_mp__stopBtn.id = "PJSMP_mp__stopBtn";
  767.     PJSMP_mp__stopBtn.className = "PJSMP_mp__buttonClass";
  768.     PJSMP_mp__stopBtn.innerHTML = PJSMP_mp__translate("stop");
  769.     PJSMP_mp__stopBtn.setAttribute("onclick", 'PJSMP_mp__stopButtonClick()');
  770.  
  771.     PJSMP_mp__window.appendChild(PJSMP_mp__stopBtn);
  772.  
  773.  
  774.     //BASIC CONTROLLERS SECTION START
  775.         var PJSMP_mp__basicControllersContainer = document.createElement("div");
  776.         PJSMP_mp__basicControllersContainer.id = "PJSMP_mp__basicControllersContainer";
  777.         PJSMP_mp__basicControllersContainer.style.float = "right";
  778.  
  779.  
  780.         var PJSMP_mp__basicControllersContainer_options = document.createElement("div");
  781.         PJSMP_mp__basicControllersContainer_options.id = "PJSMP_mp__basicControllersContainer_options";
  782.         PJSMP_mp__basicControllersContainer_options.style.float = "right";
  783.         PJSMP_mp__basicControllersContainer_options.style.marginRight = "5px";
  784.  
  785.         var PJSMP_mp__basicControllersContainer_sustainBtn = document.createElement("button");
  786.         PJSMP_mp__basicControllersContainer_sustainBtn.id = "PJSMP_mp__basicControllersContainer_sustainBtn";
  787.         PJSMP_mp__basicControllersContainer_sustainBtn.className = "PJSMP_mp__buttonClass";
  788.         PJSMP_mp__basicControllersContainer_sustainBtn.innerHTML = PJSMP_mp__translate("options.sustain");
  789.         PJSMP_mp__basicControllersContainer_sustainBtn.title = PJSMP_mp__translate("options.sustainTitle");
  790.         PJSMP_mp__setBtnTextColor(PJSMP_mp__basicControllersContainer_sustainBtn, PJSMP_mp__controllers.sustain.state? PJSMP_mp__colors.on: PJSMP_mp__colors.off);
  791.         PJSMP_mp__basicControllersContainer_sustainBtn.setAttribute("onclick", 'PJSMP_mp__optionsBtnHandler(this, PJSMP_mp__controllers.sustain)');
  792.  
  793.         PJSMP_mp__basicControllersContainer_options.appendChild(PJSMP_mp__basicControllersContainer_sustainBtn);
  794.  
  795.  
  796.         var PJSMP_mp__basicControllersContainer_loopBtn = document.createElement("button");
  797.         PJSMP_mp__basicControllersContainer_loopBtn.className = "PJSMP_mp__buttonClass";
  798.         PJSMP_mp__basicControllersContainer_loopBtn.innerHTML = PJSMP_mp__translate("options.loop");
  799.         PJSMP_mp__basicControllersContainer_loopBtn.title = PJSMP_mp__translate("options.loopTitle");
  800.         PJSMP_mp__setBtnTextColor(PJSMP_mp__basicControllersContainer_loopBtn, PJSMP_mp__controllers.loop.state? PJSMP_mp__colors.on: PJSMP_mp__colors.off);
  801.         PJSMP_mp__basicControllersContainer_loopBtn.setAttribute("onclick", 'PJSMP_mp__optionsBtnHandler(this, PJSMP_mp__controllers.loop)');
  802.  
  803.         PJSMP_mp__basicControllersContainer_options.appendChild(PJSMP_mp__basicControllersContainer_loopBtn);
  804.  
  805.  
  806.         var PJSMP_mp__basicControllersContainer_asynchronyBtn = document.createElement("button");
  807.         PJSMP_mp__basicControllersContainer_asynchronyBtn.className = "PJSMP_mp__buttonClass";
  808.         PJSMP_mp__basicControllersContainer_asynchronyBtn.innerHTML = PJSMP_mp__translate("options.asynchrony");
  809.         PJSMP_mp__basicControllersContainer_asynchronyBtn.title = PJSMP_mp__translate("options.asynchronyTitle");
  810.         PJSMP_mp__setBtnTextColor(PJSMP_mp__basicControllersContainer_asynchronyBtn, PJSMP_mp__controllers.loop.state? PJSMP_mp__colors.on: PJSMP_mp__colors.off);
  811.         PJSMP_mp__basicControllersContainer_asynchronyBtn.setAttribute("onclick", 'PJSMP_mp__optionsBtnHandler(this, PJSMP_mp__controllers.asynchrony)');
  812.  
  813.         PJSMP_mp__basicControllersContainer_options.appendChild(PJSMP_mp__basicControllersContainer_asynchronyBtn);
  814.  
  815.  
  816.         var PJSMP_mp__basicControllersContainer_notequotaBtn = document.createElement("button");
  817.         PJSMP_mp__basicControllersContainer_notequotaBtn.className = "PJSMP_mp__buttonClass";
  818.         PJSMP_mp__basicControllersContainer_notequotaBtn.innerHTML = PJSMP_mp__translate("options.notequota");
  819.         PJSMP_mp__basicControllersContainer_notequotaBtn.title = PJSMP_mp__translate("options.notequotaTitle");
  820.         PJSMP_mp__setBtnTextColor(PJSMP_mp__basicControllersContainer_notequotaBtn, PJSMP_mp__controllers.loop.state? PJSMP_mp__colors.on: PJSMP_mp__colors.off);
  821.         PJSMP_mp__basicControllersContainer_notequotaBtn.setAttribute("onclick", 'PJSMP_mp__optionsBtnHandler(this, PJSMP_mp__controllers.notequota)');
  822.  
  823.         PJSMP_mp__basicControllersContainer_options.appendChild(PJSMP_mp__basicControllersContainer_notequotaBtn);
  824.  
  825.         PJSMP_mp__basicControllersContainer.appendChild(PJSMP_mp__basicControllersContainer_options);
  826.  
  827.  
  828.         //sliders and inputs
  829.             var PJSMP_mp__basicControllersContainer_inputRangeContainer = document.createElement("div");
  830.             PJSMP_mp__basicControllersContainer_inputRangeContainer.className = "inputRangeContainer";
  831.  
  832.             //velocity increment
  833.             var PJSMP_mp__basicControllersSubContainer_volumeEncrementContainer = document.createElement("div");
  834.             PJSMP_mp__basicControllersSubContainer_volumeEncrementContainer.className = "inputRangeSubContainer";
  835.             PJSMP_mp__basicControllersSubContainer_volumeEncrementContainer.title = PJSMP_mp__translate("sliders.velocityIncrement");
  836.  
  837.  
  838.             var PJSMP_mp__basicControllersContainer_volumeEncrementInput = document.createElement("input");
  839.             PJSMP_mp__basicControllersContainer_volumeEncrementInput.type = "range";
  840.             PJSMP_mp__basicControllersContainer_volumeEncrementInput.value = PJSMP_mp__controllers.velocityIncrement.default;
  841.             PJSMP_mp__basicControllersContainer_volumeEncrementInput.min = "-1";
  842.             PJSMP_mp__basicControllersContainer_volumeEncrementInput.max = "3";
  843.             PJSMP_mp__basicControllersContainer_volumeEncrementInput.step = ".01";
  844.             PJSMP_mp__basicControllersContainer_volumeEncrementInput.setAttribute("oninput", 'PJSMP_mp__sliderHandler(this, PJSMP_mp__controllers.velocityIncrement)');
  845.             PJSMP_mp__basicControllersContainer_volumeEncrementInput.setAttribute("orient", 'vertical');
  846.  
  847.             PJSMP_mp__basicControllersSubContainer_volumeEncrementContainer.appendChild(PJSMP_mp__basicControllersContainer_volumeEncrementInput);
  848.            
  849.  
  850.             var PJSMP_mp__basicControllersContainer_volumeEncrementInputNumber = document.createElement("input");
  851.             PJSMP_mp__basicControllersContainer_volumeEncrementInputNumber.type = "number";
  852.             PJSMP_mp__basicControllersContainer_volumeEncrementInputNumber.value = PJSMP_mp__controllers.velocityIncrement.default;
  853.             PJSMP_mp__basicControllersContainer_volumeEncrementInputNumber.step = ".1";
  854.             PJSMP_mp__basicControllersContainer_volumeEncrementInputNumber.setAttribute("oninput", 'PJSMP_mp__sliderHandler(this, PJSMP_mp__controllers.velocityIncrement)');
  855.  
  856.             PJSMP_mp__basicControllersSubContainer_volumeEncrementContainer.appendChild(PJSMP_mp__basicControllersContainer_volumeEncrementInputNumber);
  857.  
  858.  
  859.             var PJSMP_mp__basicControllersContainer_volumeEncrementFixBtn = document.createElement("button");
  860.             PJSMP_mp__basicControllersContainer_volumeEncrementFixBtn.className = "PJSMP_mp__buttonClass";
  861.             PJSMP_mp__basicControllersContainer_volumeEncrementFixBtn.innerHTML = PJSMP_mp__translate("fix");
  862.             PJSMP_mp__basicControllersContainer_volumeEncrementFixBtn.style.height = "20px";
  863.             PJSMP_mp__basicControllersContainer_volumeEncrementFixBtn.style.width = "100%";
  864.             PJSMP_mp__basicControllersContainer_volumeEncrementFixBtn.style.padding = "0px";
  865.             PJSMP_mp__basicControllersContainer_volumeEncrementFixBtn.style.margin = "0px";
  866.             PJSMP_mp__basicControllersContainer_volumeEncrementFixBtn.setAttribute("onclick", 'PJSMP_mp__sliderHandler(this, PJSMP_mp__controllers.velocityIncrement)');
  867.            
  868.             PJSMP_mp__basicControllersSubContainer_volumeEncrementContainer.appendChild(PJSMP_mp__basicControllersContainer_volumeEncrementFixBtn);
  869.  
  870.  
  871.             var PJSMP_mp__basicControllersContainer_volumeEncrementSwitchBtn = document.createElement("button");
  872.             PJSMP_mp__basicControllersContainer_volumeEncrementSwitchBtn.className = "PJSMP_mp__buttonClass";
  873.             PJSMP_mp__basicControllersContainer_volumeEncrementSwitchBtn.innerHTML = "V";
  874.             PJSMP_mp__setBtnTextColor(PJSMP_mp__basicControllersContainer_volumeEncrementSwitchBtn, PJSMP_mp__controllers.velocityIncrement.state? PJSMP_mp__colors.on: PJSMP_mp__colors.off);
  875.             PJSMP_mp__basicControllersContainer_volumeEncrementSwitchBtn.style.height = "20px";
  876.             PJSMP_mp__basicControllersContainer_volumeEncrementSwitchBtn.style.width = "100%";
  877.             PJSMP_mp__basicControllersContainer_volumeEncrementSwitchBtn.style.padding = "0px";
  878.             PJSMP_mp__basicControllersContainer_volumeEncrementSwitchBtn.style.margin = "0px";
  879.             PJSMP_mp__basicControllersContainer_volumeEncrementSwitchBtn.setAttribute("onclick", 'PJSMP_mp__sliderHandler(this, PJSMP_mp__controllers.velocityIncrement)');
  880.  
  881.             PJSMP_mp__basicControllersSubContainer_volumeEncrementContainer.appendChild(PJSMP_mp__basicControllersContainer_volumeEncrementSwitchBtn);
  882.  
  883.             PJSMP_mp__basicControllersContainer_inputRangeContainer.appendChild(PJSMP_mp__basicControllersSubContainer_volumeEncrementContainer);
  884.  
  885.  
  886.  
  887.             //speed
  888.             var PJSMP_mp__basicControllersSubContainer_speedContainer = document.createElement("div");
  889.             PJSMP_mp__basicControllersSubContainer_speedContainer.className = "inputRangeSubContainer";
  890.             PJSMP_mp__basicControllersSubContainer_speedContainer.title = PJSMP_mp__translate("sliders.speed");
  891.  
  892.  
  893.             var PJSMP_mp__basicControllersContainer_speedInput = document.createElement("input");
  894.             PJSMP_mp__basicControllersContainer_speedInput.type = "range";
  895.             PJSMP_mp__basicControllersContainer_speedInput.value = PJSMP_mp__controllers.speed.default;
  896.             PJSMP_mp__basicControllersContainer_speedInput.min = "0";
  897.             PJSMP_mp__basicControllersContainer_speedInput.max = "4";
  898.             PJSMP_mp__basicControllersContainer_speedInput.step = ".01";
  899.             PJSMP_mp__basicControllersContainer_speedInput.setAttribute("oninput", 'PJSMP_mp__sliderHandler(this, PJSMP_mp__controllers.speed)');
  900.             PJSMP_mp__basicControllersContainer_speedInput.setAttribute("orient", 'vertical');
  901.  
  902.             PJSMP_mp__basicControllersSubContainer_speedContainer.appendChild(PJSMP_mp__basicControllersContainer_speedInput);
  903.  
  904.  
  905.             var PJSMP_mp__basicControllersContainer_speedInputNumber = document.createElement("input");
  906.             PJSMP_mp__basicControllersContainer_speedInputNumber.type = "number";
  907.             PJSMP_mp__basicControllersContainer_speedInputNumber.value = PJSMP_mp__controllers.speed.default;
  908.             PJSMP_mp__basicControllersContainer_speedInputNumber.min = "0";
  909.             PJSMP_mp__basicControllersContainer_speedInputNumber.step = ".1";
  910.             PJSMP_mp__basicControllersContainer_speedInputNumber.setAttribute("oninput", 'PJSMP_mp__sliderHandler(this, PJSMP_mp__controllers.speed)');
  911.  
  912.             PJSMP_mp__basicControllersSubContainer_speedContainer.appendChild(PJSMP_mp__basicControllersContainer_speedInputNumber);
  913.  
  914.  
  915.             var PJSMP_mp__basicControllersContainer_speedFixBtn = document.createElement("button");
  916.             PJSMP_mp__basicControllersContainer_speedFixBtn.className = "PJSMP_mp__buttonClass";
  917.             PJSMP_mp__basicControllersContainer_speedFixBtn.innerHTML = PJSMP_mp__translate("fix");
  918.             PJSMP_mp__basicControllersContainer_speedFixBtn.style.height = "20px";
  919.             PJSMP_mp__basicControllersContainer_speedFixBtn.style.width = "100%";
  920.             PJSMP_mp__basicControllersContainer_speedFixBtn.style.padding = "0px";
  921.             PJSMP_mp__basicControllersContainer_speedFixBtn.style.margin = "0px";
  922.             PJSMP_mp__basicControllersContainer_speedFixBtn.setAttribute("onclick", 'PJSMP_mp__sliderHandler(this, PJSMP_mp__controllers.speed)');
  923.            
  924.             PJSMP_mp__basicControllersSubContainer_speedContainer.appendChild(PJSMP_mp__basicControllersContainer_speedFixBtn);
  925.  
  926.  
  927.             var PJSMP_mp__basicControllersContainer_speedSwitchBtn = document.createElement("button");
  928.             PJSMP_mp__basicControllersContainer_speedSwitchBtn.className = "PJSMP_mp__buttonClass";
  929.             PJSMP_mp__basicControllersContainer_speedSwitchBtn.innerHTML = "S";
  930.             PJSMP_mp__setBtnTextColor(PJSMP_mp__basicControllersContainer_speedSwitchBtn, "white");
  931.             PJSMP_mp__basicControllersContainer_speedSwitchBtn.style.height = "20px";
  932.             PJSMP_mp__basicControllersContainer_speedSwitchBtn.style.width = "100%";
  933.             PJSMP_mp__basicControllersContainer_speedSwitchBtn.style.padding = "0px";
  934.             PJSMP_mp__basicControllersContainer_speedSwitchBtn.style.margin = "0px";
  935.  
  936.             PJSMP_mp__basicControllersSubContainer_speedContainer.appendChild(PJSMP_mp__basicControllersContainer_speedSwitchBtn);
  937.  
  938.  
  939.             PJSMP_mp__basicControllersContainer_inputRangeContainer.appendChild(PJSMP_mp__basicControllersSubContainer_speedContainer);
  940.            
  941.  
  942.             PJSMP_mp__basicControllersContainer.appendChild(PJSMP_mp__basicControllersContainer_inputRangeContainer);
  943.  
  944.         PJSMP_mp__window.appendChild(PJSMP_mp__basicControllersContainer);
  945.     //BASIC CONTROLLERS SECTION END
  946.  
  947.     //FILE INFORMATION
  948.     var PJSMP_mp__infoContainer = document.createElement("div");
  949.     PJSMP_mp__infoContainer.id = "PJSMP_mp__infoContainer";
  950.     PJSMP_mp__infoContainer.style.opacity = "0";
  951.     PJSMP_mp__infoContainer.style.transition = "2s";
  952.  
  953.     var PJSMP_mp__infoContainer_duration = document.createElement("span");
  954.     PJSMP_mp__infoContainer_duration.id = "PJSMP_mp__infoContainer_duration";
  955.     PJSMP_mp__infoContainer_duration.innerHTML = "defalt value";
  956.  
  957.     PJSMP_mp__infoContainer.appendChild(PJSMP_mp__infoContainer_duration);
  958.  
  959.     PJSMP_mp__window.appendChild(PJSMP_mp__infoContainer);
  960.  
  961.     //ORIGIN CONTROLLERS
  962.     var PJSMP_mp__originContainer = document.createElement("div");
  963.     PJSMP_mp__originContainer.id = "PJSMP_mp__originContainer";
  964.  
  965.         //OCTAVE
  966.         var PJSMP_mp__originContainer_controllerOctave = document.createElement("div");
  967.         PJSMP_mp__originContainer_controllerOctave.className = "oringinController";
  968.         PJSMP_mp__originContainer_controllerOctave.title = PJSMP_mp__translate("origin.octave");
  969.        
  970.         var PJSMP_mp__originContainer_octaveSwitcher = document.createElement("button");
  971.         PJSMP_mp__originContainer_octaveSwitcher.innerHTML = "O";
  972.         PJSMP_mp__setBtnTextColor(PJSMP_mp__originContainer_octaveSwitcher, PJSMP_mp__controllers.originOctave.state? PJSMP_mp__colors.on: PJSMP_mp__colors.off);
  973.         PJSMP_mp__originContainer_octaveSwitcher.style.padding = "1px";
  974.         PJSMP_mp__originContainer_octaveSwitcher.style.marginRight = "2px";
  975.         PJSMP_mp__originContainer_octaveSwitcher.setAttribute("onclick", 'PJSMP_mp__originControllersHandler(this, PJSMP_mp__controllers.originOctave)');
  976.  
  977.         PJSMP_mp__originContainer_controllerOctave.appendChild(PJSMP_mp__originContainer_octaveSwitcher);
  978.  
  979.        
  980.         var PJSMP_mp__originContainer_octaveFix = document.createElement("button");
  981.         PJSMP_mp__originContainer_octaveFix.innerHTML = PJSMP_mp__translate("fix");
  982.         PJSMP_mp__originContainer_octaveFix.style.paddingLeft = "0px";
  983.         PJSMP_mp__originContainer_octaveFix.style.paddingRight = "0px";
  984.         PJSMP_mp__originContainer_octaveFix.setAttribute("onclick", 'PJSMP_mp__originControllersHandler(this, PJSMP_mp__controllers.originOctave)');
  985.  
  986.         PJSMP_mp__originContainer_controllerOctave.appendChild(PJSMP_mp__originContainer_octaveFix);
  987.  
  988.         var PJSMP_mp__originContainer_octaveInput = document.createElement("input");
  989.         PJSMP_mp__originContainer_octaveInput.type = "number";
  990.         PJSMP_mp__originContainer_octaveInput.value = PJSMP_mp__controllers.originOctave.value;
  991.         PJSMP_mp__originContainer_octaveInput.step = 1;
  992.         PJSMP_mp__originContainer_octaveInput.setAttribute("oninput", 'PJSMP_mp__originControllersHandler(this, PJSMP_mp__controllers.originOctave)');
  993.  
  994.         PJSMP_mp__originContainer_controllerOctave.appendChild(PJSMP_mp__originContainer_octaveInput);
  995.  
  996.         PJSMP_mp__originContainer.appendChild(PJSMP_mp__originContainer_controllerOctave);
  997.  
  998.         PJSMP_mp__window.appendChild(PJSMP_mp__originContainer);
  999.  
  1000.         //TRANSPOSE
  1001.         var PJSMP_mp__originContainer_controllerTranspose = document.createElement("div");
  1002.         PJSMP_mp__originContainer_controllerTranspose.className = "oringinController";
  1003.         PJSMP_mp__originContainer_controllerTranspose.title = PJSMP_mp__translate("origin.transpose");
  1004.        
  1005.         var PJSMP_mp__originContainer_transposeSwitcher = document.createElement("button");
  1006.         PJSMP_mp__originContainer_transposeSwitcher.innerHTML = "T";
  1007.         PJSMP_mp__setBtnTextColor(PJSMP_mp__originContainer_transposeSwitcher, PJSMP_mp__controllers.originTranspose.state? PJSMP_mp__colors.on: PJSMP_mp__colors.off);
  1008.         PJSMP_mp__originContainer_transposeSwitcher.style.padding = "1px";
  1009.         PJSMP_mp__originContainer_transposeSwitcher.style.marginRight = "2px";
  1010.         PJSMP_mp__originContainer_transposeSwitcher.setAttribute("onclick", 'PJSMP_mp__originControllersHandler(this, PJSMP_mp__controllers.originTranspose)');
  1011.  
  1012.         PJSMP_mp__originContainer_controllerTranspose.appendChild(PJSMP_mp__originContainer_transposeSwitcher);
  1013.  
  1014.        
  1015.         var PJSMP_mp__originContainer_transposeFix = document.createElement("button");
  1016.         PJSMP_mp__originContainer_transposeFix.innerHTML = PJSMP_mp__translate("fix");
  1017.         PJSMP_mp__originContainer_transposeFix.style.paddingLeft = "0px";
  1018.         PJSMP_mp__originContainer_transposeFix.style.paddingRight = "0px";
  1019.         PJSMP_mp__originContainer_transposeFix.setAttribute("onclick", 'PJSMP_mp__originControllersHandler(this, PJSMP_mp__controllers.originTranspose)');
  1020.  
  1021.         PJSMP_mp__originContainer_controllerTranspose.appendChild(PJSMP_mp__originContainer_transposeFix);
  1022.  
  1023.         var PJSMP_mp__originContainer_transposeInput = document.createElement("input");
  1024.         PJSMP_mp__originContainer_transposeInput.type = "number";
  1025.         PJSMP_mp__originContainer_transposeInput.value = PJSMP_mp__controllers.originTranspose.value;
  1026.         PJSMP_mp__originContainer_transposeInput.step = 1;
  1027.         PJSMP_mp__originContainer_transposeInput.setAttribute("oninput", 'PJSMP_mp__originControllersHandler(this, PJSMP_mp__controllers.originTranspose)');
  1028.  
  1029.         PJSMP_mp__originContainer_controllerTranspose.appendChild(PJSMP_mp__originContainer_transposeInput);
  1030.  
  1031.  
  1032.         PJSMP_mp__originContainer.appendChild(PJSMP_mp__originContainer_controllerTranspose);
  1033.  
  1034.         PJSMP_mp__window.appendChild(PJSMP_mp__originContainer);  
  1035.  
  1036.    
  1037.     //NOTES PER SECOND
  1038.     var PJSMP_mp__NPSContainer = document.createElement("div");
  1039.     PJSMP_mp__NPSContainer.id = "PJSMP_mp__NPSContainer";
  1040.  
  1041.     var PJSMP_mp__NPSContainer_text = document.createElement("span");
  1042.     PJSMP_mp__NPSContainer_text.id = "PJSMP_mp__NPSContainer_text";
  1043.     PJSMP_mp__NPSContainer_text.innerHTML = PJSMP_mp__NPS;
  1044.     PJSMP_mp__NPSContainer_text.title = PJSMP_mp__translate("text.notePerSecond");
  1045.  
  1046.     PJSMP_mp__NPSContainer.appendChild(PJSMP_mp__NPSContainer_text);
  1047.  
  1048.     PJSMP_mp__window.appendChild(PJSMP_mp__NPSContainer);
  1049.  
  1050.     //BOTTOM NAME
  1051.     var PJSMP_mp__bottomName = document.createElement("div");
  1052.     PJSMP_mp__bottomName.id = "PJSMP_mp__bottomName";
  1053.     PJSMP_mp__bottomName.title = PJSMP_mp__moduleName+" - v"+PJSMP_mp__version;
  1054.     PJSMP_mp__bottomName.setAttribute("onclick", "PJSMP_mp__openChangelog()");
  1055.  
  1056.     var PJSMP_mp__bottomName_text = document.createElement("span");
  1057.     PJSMP_mp__bottomName_text.id = "PJSMP_mp__bottomName_text";
  1058.     PJSMP_mp__bottomName_text.innerHTML = "MADE BY: NaN-NaN-senpai(BR)";
  1059.  
  1060.     PJSMP_mp__bottomName.appendChild(PJSMP_mp__bottomName_text);
  1061.  
  1062.     PJSMP_mp__window.appendChild(PJSMP_mp__bottomName);
  1063.  
  1064.     //DRAG AND DROP
  1065.     var PJSMP_mp__dragAndDrop = document.createElement("div");
  1066.     PJSMP_mp__dragAndDrop.id = "PJSMP_mp__dragAndDrop";
  1067.     PJSMP_mp__dragAndDrop.title = PJSMP_mp__moduleFullName;
  1068.  
  1069.     var PJSMP_mp__dragAndDrop_text = document.createElement("span");
  1070.     PJSMP_mp__dragAndDrop_text.id = "PJSMP_mp__dragAndDrop_text";
  1071.     PJSMP_mp__dragAndDrop_text.innerHTML = PJSMP_mp__moduleName;
  1072.  
  1073.     var PJSMP_mp__dragAndDrop_ocBtn = document.createElement("button");
  1074.     PJSMP_mp__dragAndDrop_ocBtn.id = "PJSMP_mp__dragAndDrop_ocBtn";
  1075.     PJSMP_mp__dragAndDrop_ocBtn.innerHTML = PJSMP_mp__windowMinimized? "O": "X";
  1076.     PJSMP_mp__dragAndDrop_ocBtn.title = PJSMP_mp__windowMinimized? PJSMP_mp__translate("text.openWindow"): PJSMP_mp__translate("text.closeWindow");
  1077.     PJSMP_mp__setBtnTextColor(PJSMP_mp__dragAndDrop_ocBtn, PJSMP_mp__windowMinimized? PJSMP_mp__colors.on: PJSMP_mp__colors.off);
  1078.     PJSMP_mp__dragAndDrop_ocBtn.style.background = "linear-gradient(to right, transparent 5%, "+(PJSMP_mp__windowMinimized? PJSMP_mp__colors.darkerOn: PJSMP_mp__colors.darkerOff)+")";
  1079.     PJSMP_mp__dragAndDrop_ocBtn.setAttribute("onclick", "PJSMP_mp__minimizeWindow(this)");
  1080.  
  1081.     PJSMP_mp__dragAndDrop.appendChild(PJSMP_mp__dragAndDrop_text);
  1082.  
  1083.     PJSMP_mp__dragAndDrop.appendChild(PJSMP_mp__dragAndDrop_ocBtn);
  1084.  
  1085.  
  1086.     //APPENDING PROGRAM
  1087.     PJSMP_mp__mainContainer.appendChild(PJSMP_mp__dragAndDrop);
  1088.     PJSMP_mp__mainContainer.appendChild(PJSMP_mp__window);
  1089.     document.querySelector("#bottom").appendChild(PJSMP_mp__mainContainer);
  1090. }
  1091.  
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120. //HTML ELEMENTS FUNCTIONS
  1121. window.PJSMP_mp__dragElement = (elmnt) => { //DRAG AND DROP PROGRAM WINDOW
  1122.   var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
  1123.  
  1124.   document.getElementById("PJSMP_mp__dragAndDrop").onmousedown = PJSMP_mp__dragMouseDown;
  1125.  
  1126.   function PJSMP_mp__dragMouseDown(e) {
  1127.     e = e || window.event;
  1128.     e.preventDefault();
  1129.     pos3 = e.clientX;
  1130.     pos4 = e.clientY;
  1131.     document.onmouseup = PJSMP_mp__closeDragElement;
  1132.     document.onmousemove = PJSMP_mp__elementDrag;
  1133.   }
  1134.  
  1135.   function PJSMP_mp__elementDrag(e) {
  1136.     e = e || window.event;
  1137.     e.preventDefault();
  1138.     pos1 = pos3 - e.clientX;
  1139.     pos2 = pos4 - e.clientY;
  1140.     pos3 = e.clientX;
  1141.     pos4 = e.clientY;
  1142.     elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
  1143.     elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
  1144.   }
  1145.  
  1146.   function PJSMP_mp__closeDragElement() {
  1147.     document.onmouseup = null;
  1148.     document.onmousemove = null;
  1149.   }
  1150. }
  1151. PJSMP_mp__dragElement(document.querySelector("#PJSMP_mp__mainContainer"));
  1152.  
  1153. window.PJSMP_mp__minimizeWindow = (e) => { //MINIMIZE WINDOW
  1154.     PJSMP_mp__windowMinimized = !PJSMP_mp__windowMinimized;
  1155.     e.innerHTML = PJSMP_mp__windowMinimized? "O": "X";
  1156.     e.title = PJSMP_mp__windowMinimized? PJSMP_mp__translate("text.openWindow"): PJSMP_mp__translate("text.closeWindow");
  1157.     PJSMP_mp__setBtnTextColor(e, PJSMP_mp__windowMinimized? PJSMP_mp__colors.on: PJSMP_mp__colors.off);
  1158.  
  1159.     e.style.background = "linear-gradient(to right, transparent 5%, "+(PJSMP_mp__windowMinimized? PJSMP_mp__colors.darkerOn: PJSMP_mp__colors.darkerOff)+")";
  1160.    
  1161.     var pWindow = document.querySelector("#PJSMP_mp__window").style;
  1162.     document.querySelector("#PJSMP_mp__dragAndDrop").style.transition = ".5s";
  1163.     var pContainer = document.querySelector("#PJSMP_mp__mainContainer").style;
  1164.     if(PJSMP_mp__windowMinimized){
  1165.         pWindow.pointerEvents = "none";
  1166.         pWindow.overflow = "hidden";
  1167.         pWindow.height = "0px";
  1168.         pWindow.opacity = "0";
  1169.         pContainer.backdropFilter = "";
  1170.  
  1171.         document.querySelector("#PJSMP_mp__dragAndDrop").style.borderRadius = "10px 10px 10px 10px";
  1172.     } else {
  1173.         pWindow.pointerEvents = "auto";
  1174.         pWindow.overflow = "";
  1175.         pWindow.height = "";
  1176.         pWindow.opacity = "1";
  1177.         pContainer.backdropFilter = "blur(1.5px)";
  1178.        
  1179.         document.querySelector("#PJSMP_mp__dragAndDrop").style.borderRadius = "10px 10px 0px 0px";
  1180.     }
  1181. }
  1182.  
  1183. window.PJSMP_mp__openChangelog = () => { //OPEN CHANGELOG
  1184.     window.open("").document.write("<html><head><title>"+PJSMP_mp__moduleName+" - v"+PJSMP_mp__version+" ChangeLog</title></head><body><h1 align='center'>"+PJSMP_mp__moduleName+" - v"+PJSMP_mp__version+"</h1><textarea readonly style='font-size: 20px;height: 100%; width: 100%;' rows='4' cols='50'>"+PJSMP_mp__changeLog+"</textarea></body></html>");
  1185. }
  1186.  
  1187. window.PJSMP_mp__optionsBtnHandler = (e, control) => { //OPTION CONTROLLERS HANDLER
  1188.     control.state = !control.state;
  1189.  
  1190.     PJSMP_mp__setBtnTextColor(e, control.state? PJSMP_mp__colors.on: PJSMP_mp__colors.off);
  1191. }
  1192.  
  1193. window.PJSMP_mp__originControllersHandler = (e, control) => { //ORIGIN CONTROLLERS HANDLER
  1194.     if(e.tagName == "BUTTON"){
  1195.         if(e.innerHTML == PJSMP_mp__translate("fix")){
  1196.             e.parentElement.children[2].value = control.value = control.default;
  1197.         } else {
  1198.             control.state = !control.state;
  1199.  
  1200.             PJSMP_mp__setBtnTextColor(e, control.state? PJSMP_mp__colors.on: PJSMP_mp__colors.off);
  1201.         }
  1202.     } else {
  1203.         control.value = parseFloat(e.value);
  1204.     }
  1205. }
  1206.  
  1207. window.PJSMP_mp__sliderHandler = (e, control) => { //SLIDERS HANDLER
  1208.     if(e.tagName == "BUTTON"){
  1209.         if(e.innerHTML == PJSMP_mp__translate("fix")){
  1210.             e.parentElement.children[0].value = e.parentElement.children[1].value = control.value = control.default;
  1211.         } else {
  1212.             control.state = !control.state;
  1213.  
  1214.             PJSMP_mp__setBtnTextColor(e, control.state? PJSMP_mp__colors.on: PJSMP_mp__colors.off);
  1215.         }
  1216.     } else {
  1217.         if(e.type == "range"){
  1218.             control.value = parseFloat(e.value);
  1219.             e.parentElement.children[1].value = e.value;
  1220.  
  1221.         } else if(e.type == "number"){
  1222.             control.value = parseFloat(e.value);
  1223.  
  1224.             var range = e.parentElement.children[0];
  1225.             range.value = e.value < range.min? range.min:
  1226.                         e.value > range.max? range.max:
  1227.                         e.value;
  1228.  
  1229.         }
  1230.     }
  1231.  
  1232.     if(control == PJSMP_mp__controllers.speed){
  1233.         if(document.querySelector("#PJSMP_mp__playBtn").innerHTML == PJSMP_mp__translate("pause")){
  1234.             PJSMP_mp__playPauseFunction("pause", "play");
  1235.             PJSMP_mp__playPauseFunction("play", "play");
  1236.         }
  1237.         PJSMP_mp__setDurationInfo();
  1238.     }
  1239. }
  1240.  
  1241. window.PJSMP_mp__playPauseButtonClick = (e) => { //PLAY/PAUSE
  1242.     if(PJSMP_mp__fileName !== "none"){
  1243.         if(e.innerHTML == PJSMP_mp__translate("play")){
  1244.             PJSMP_mp__playPauseFunction("play", "play");
  1245.             e.innerHTML = PJSMP_mp__translate("pause");
  1246.         } else {
  1247.             PJSMP_mp__playPauseFunction("pause", "play");
  1248.             e.innerHTML = PJSMP_mp__translate("play");
  1249.         }
  1250.     }
  1251. }
  1252.  
  1253. window.PJSMP_mp__stopButtonClick = () => { //STOP  
  1254.     PJSMP_mp__stopFunction();
  1255.     if(document.querySelector("#PJSMP_mp__playBtn").innerHTML == PJSMP_mp__translate("pause")){
  1256.         document.querySelector("#PJSMP_mp__playBtn").innerHTML = PJSMP_mp__translate("play");
  1257.     }
  1258. }
  1259.  
  1260.  
  1261.  
  1262.  
  1263.  
  1264.  
  1265.  
  1266.  
  1267.  
  1268.  
  1269.  
  1270.  
  1271.  
  1272. //MIDI READERS AND PLAYERS
  1273. window.PJSMP_mp__notesArr = [];
  1274. window.PJSMP_mp__actualNote = 0;
  1275. window.PJSMP_mp__pauseActualNote = 0;
  1276. window.PJSMP_mp__endTime = 0;
  1277.  
  1278. window.PJSMP_mp__stopInterval = undefined;
  1279.  
  1280. window.PJSMP_mp__fileNameRaw = "none";
  1281. window.PJSMP_mp__fileName = "none";
  1282.  
  1283. window.PJSMP_mp__trackAmount = 0;
  1284. window.PJSMP_mp__noteAmount = 0;
  1285.  
  1286.  
  1287. window.PJSMP_mp__renderMidi = (file, qType) => { //RENDER MIDI
  1288.     file.tracks.forEach(track => {
  1289.         if(typeof PJSMP_mtc__renderTrack == "undefined"){
  1290.             PJSMP_mp__renderTrack(track, qType); //RENDER TRACK IN MODULE PLAYER
  1291.         } else {
  1292.             PJSMP_mtc__renderTrack(track, qType); //RENDE TRACK IN MODULE TRACK CONTROLLER
  1293.         }
  1294.     });
  1295.     PJSMP_mp__trackAmount = file.tracks.length;
  1296.     document.querySelector("#PJSMP_mp__fileDropContainer_textContainer_text").title = PJSMP_mp__translate("text.tracks")+": "+PJSMP_mp__trackAmount+"\n"+PJSMP_mp__translate("text.notes")+": "+PJSMP_mp__noteAmount;
  1297. }
  1298.  
  1299. window.PJSMP_mp__playPauseFunction = (action, qType) => { //PLAY/PAUSE
  1300.     if(typeof PJSMP_mp__midiJSONobject != "undefined"){
  1301.         if(action == "play"){
  1302.             PJSMP_mp__renderMidi(PJSMP_mp__midiJSONobject, qType);
  1303.            
  1304.             PJSMP_mp__stopInterval = setTimeout(()=>{
  1305.                 PJSMP_mp__stopButtonClick();
  1306.  
  1307.                 if(PJSMP_mp__controllers.loop.state){
  1308.                     PJSMP_mp__playPauseButtonClick(document.querySelector("#PJSMP_mp__playBtn"));
  1309.                 }
  1310.             }, PJSMP_mp__calcSpeed(PJSMP_mp__endTime - PJSMP_mp__pauseActualNote));
  1311.  
  1312.         } else if(action == "pause"){
  1313.             PJSMP_mp__pauseActualNote = PJSMP_mp__actualNote;
  1314.            
  1315.             PJSMP_mp__notesArr.forEach(e => {
  1316.                 clearInterval(e);
  1317.             });
  1318.             PJSMP_mp__notesArr = [];
  1319.             clearInterval(PJSMP_mp__stopInterval);
  1320.         }
  1321.     }
  1322. }
  1323.  
  1324. window.PJSMP_mp__stopFunction = (action, qType) => { //STOP
  1325.     PJSMP_mp__notesArr.forEach(e => {
  1326.         clearInterval(e);
  1327.     });
  1328.     PJSMP_mp__resetVars();
  1329.     PJSMP_mp__setDurationInfo();
  1330. }
  1331.  
  1332. window.PJSMP_mp__keyNames = ["a-1", "as-1", "b-1", "c0", "cs0", "d0", "ds0", "e0", "f0", "fs0", "g0", "gs0", "a0", "as0", "b0", "c1", "cs1", "d1", "ds1", "e1", "f1", "fs1", "g1", "gs1", "a1", "as1", "b1", "c2", "cs2", "d2", "ds2", "e2", "f2", "fs2", "g2", "gs2", "a2", "as2", "b2", "c3", "cs3", "d3", "ds3", "e3", "f3", "fs3", "g3", "gs3", "a3", "as3", "b3", "c4", "cs4", "d4", "ds4", "e4", "f4", "fs4", "g4", "gs4", "a4", "as4", "b4", "c5", "cs5", "d5", "ds5", "e5", "f5", "fs5", "g5", "gs5", "a5", "as5", "b5", "c6", "cs6", "d6", "ds6", "e6", "f6", "fs6", "g6", "gs6", "a6", "as6", "b6", "c7"]
  1333. window.PJSMP_mp__noNoteQuotaObj = {doOnce: true};
  1334. window.PJSMP_mp__renderTrack = (track, qType) => { //RENDER TRACKS
  1335.     try {
  1336.         var endTrack = track.notes.filter(e => e.time >= PJSMP_mp__pauseActualNote / 1000);
  1337.         endTrack.forEach(note => {
  1338.             var key = note.name.replace("#", "s").toLowerCase().slice(0, note.name.replace("#", "s").toLowerCase().length-1);
  1339.             var octave = parseFloat(note.name.replace("#", "s").toLowerCase().slice(note.name.replace("#", "s").toLowerCase().length-1)) - 1;
  1340.  
  1341.             var time = note.time * 1000;
  1342.             var velocity = note.velocity;
  1343.             var duration = note.duration * 1000;
  1344.  
  1345.             if(qType == "load"){
  1346.                 if(PJSMP_mp__endTime <= time){
  1347.                     PJSMP_mp__endTime = time + duration;
  1348.                 }
  1349.                 PJSMP_mp__noteAmount++;
  1350.                 PJSMP_mp__setDurationInfo();
  1351.  
  1352.             } else if(qType == "play"){
  1353.                 PJSMP_mp__notesArr.push(setTimeout(()=>{
  1354.                     var canSustain = (!PJSMP_mp__controllers.sustain.state? undefined: PJSMP_mp__calcSpeed(duration));
  1355.  
  1356.                     var sendNote = PJSMP_mp__keyNames[PJSMP_mp__keyNames.indexOf(key+octave) +
  1357.                                                      (PJSMP_mp__controllers.originOctave.state? PJSMP_mp__controllers.originOctave.value * 12: 0) +
  1358.                                                      (PJSMP_mp__controllers.originTranspose.state? PJSMP_mp__controllers.originTranspose.value: 0)];
  1359.  
  1360.                     PJSMP_mp__keyPress({
  1361.                             key: sendNote,
  1362.                             velocity: velocity + (PJSMP_mp__controllers.velocityIncrement.state? PJSMP_mp__controllers.velocityIncrement.value: 0)
  1363.                         }, canSustain);
  1364.  
  1365.                     if(PJSMP_mp__controllers.notequota.state){
  1366.                         PJSMP_mp__noNoteQuotaObj.doOnce = true;
  1367.                        
  1368.                         MPP.noteQuota.points = 1000000000;
  1369.                     } else if(PJSMP_mp__noNoteQuotaObj.doOnce){
  1370.                         PJSMP_mp__noNoteQuotaObj.doOnce = !PJSMP_mp__noNoteQuotaObj.doOnce;
  1371.  
  1372.                         MPP.noteQuota.points = 450;
  1373.                     }
  1374.  
  1375.                     PJSMP_mp__actualNote = time;
  1376.  
  1377.                     PJSMP_mp__setDurationInfo();
  1378.                     PJSMP_mp__NPS++;
  1379.                 }, PJSMP_mp__calcSpeed(time - PJSMP_mp__pauseActualNote)));
  1380.             }
  1381.         });
  1382.     } catch(e){
  1383.         PJSMP_mp__setFileName(PJSMP_mp__translate("text.error.midiPlayError")+": "+PJSMP_mp__fileNameRaw);
  1384.         throw e;
  1385.     }
  1386.  
  1387.     if(qType == "load"){
  1388.         PJSMP_mp__setFileName(PJSMP_mp__fileName);
  1389.     }
  1390. }
  1391.  
  1392. window.PJSMP_mp__calcSpeed = (time) => { //CALCULATE SPEED
  1393.     return (time + (PJSMP_mp__controllers.asynchrony.state? Math.random() * 175: 0)) / (PJSMP_mp__controllers.speed.value==0? 0.01: PJSMP_mp__controllers.speed.value);
  1394. }
  1395.  
  1396. window.PJSMP_mp__resetVars = () => { //RESET VARIABLES
  1397.     PJSMP_mp__notesArr = [];
  1398.     PJSMP_mp__actualNote = PJSMP_mp__pauseActualNote = 0;
  1399.     clearInterval(PJSMP_mp__stopInterval);
  1400. }
  1401.  
  1402. window.PJSMP_mp__setFileName = (name) => { //SET FILE NAME
  1403.     document.querySelector("#PJSMP_mp__fileDropContainer #PJSMP_mp__fileDropContainer_textContainer_text").textContent = name;
  1404. }
  1405.  
  1406. window.PJSMP_mp__keyPress = (note, release) => { //MPP.PRESS FUNCTION OVERIDE
  1407.     if(typeof PJSMP_mmc__keyPress != "function"){
  1408.         MPP.press(note.key, note.velocity);
  1409.  
  1410.         if(typeof release == "number"){
  1411.             setTimeout(()=>{
  1412.                 MPP.release(note.key);
  1413.             }, release);
  1414.         }
  1415.     } else {
  1416.         PJSMP_mmc__keyPress(note, release);
  1417.     }
  1418. }
  1419.  
  1420. window.PJSMP_mp__calcDuration = () => { //CALCULATE DURATION
  1421.     var pNote = new Date(PJSMP_mp__calcSpeed(PJSMP_mp__actualNote)).toISOString();
  1422.     var endNote = new Date(PJSMP_mp__calcSpeed(PJSMP_mp__endTime)).toISOString();
  1423.     return (pNote.substr(11, 3) == "00:"?pNote.substr(14, 5):pNote.substr(11, 8))+" | "+(endNote.substr(11, 3) == "00:"?endNote.substr(14, 5):endNote.substr(11, 8));
  1424. }
  1425. window.PJSMP_mp__setDurationInfo = () => { //DISPLAY DURATION
  1426.     if(PJSMP_mp__fileName !== "none"){
  1427.         document.querySelector("#PJSMP_mp__infoContainer").style.opacity = "1";
  1428.     }
  1429.     document.querySelector("#PJSMP_mp__infoContainer_duration").innerHTML = PJSMP_mp__calcDuration();
  1430.     document.querySelector("#PJSMP_mp__dragAndDrop").title = PJSMP_mp__translate("text.playing") + ": "+PJSMP_mp__fileName+"\n"+PJSMP_mp__calcDuration();
  1431. }
  1432.  
  1433.  
  1434.  
  1435. //MIDI TO JSON AND FILE READING
  1436. if (!(window.File && window.FileReader && window.FileList && window.Blob)) {
  1437.     PJSMP_mp__setFileName("Sorry, this browser doesnt support PJSMP (RE)");
  1438. } else {
  1439.     document.querySelector("#PJSMP_mp__fileDropContainer input").addEventListener("change", e => {
  1440.         const files = e.target.files;
  1441.         if (files.length > 0){
  1442.             const file = files[0];
  1443.             PJSMP_mp__parseMidi(file);
  1444.             PJSMP_mp__fileNameRaw = file.name;
  1445.             PJSMP_mp__fileName = file.name.replace(/.midi/g, "").replace(/.mid/g, "");
  1446.         }
  1447.     })
  1448. }
  1449. window.PJSMP_mp__parseMidi = (file) => {
  1450.     const reader = new FileReader()
  1451.     reader.onload = function(e){
  1452.         try {
  1453.             PJSMP_mp__stopButtonClick();
  1454.             window.PJSMP_mp__midiJSONobject = new Midi(e.target.result);
  1455.             PJSMP_mp__noteAmount = 0;
  1456.             PJSMP_mp__endTime = 0;
  1457.             PJSMP_mp__renderMidi(PJSMP_mp__midiJSONobject, "load");
  1458.         } catch(e){
  1459.             PJSMP_mp__setFileName(PJSMP_mp__translate("text.error.midiLoadError")+": "+PJSMP_mp__fileNameRaw);
  1460.             throw e;
  1461.         }
  1462.        
  1463.     }
  1464.     reader.readAsArrayBuffer(file);
  1465. }
  1466.  
  1467. //MIDI TO JSON
  1468. !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r=e();for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}("undefined"!=typeof self?self:this,function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=4)}([function(t,e,r){e.parseMidi=r(5),e.writeMidi=r(6)},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(2),i=new WeakMap;e.keySignatureKeys=["Cb","Gb","Db","Ab","Eb","Bb","F","C","G","D","A","E","B","F#","C#"];var a=function(){function t(t){var r=this;this.tempos=[],this.timeSignatures=[],this.keySignatures=[],this.meta=[],this.name="",i.set(this,480),t&&(i.set(this,t.header.ticksPerBeat),t.tracks[0].forEach(function(t){t.meta&&("timeSignature"===t.type?r.timeSignatures.push({ticks:t.absoluteTime,timeSignature:[t.numerator,t.denominator]}):"setTempo"===t.type?r.tempos.push({bpm:6e7/t.microsecondsPerBeat,ticks:t.absoluteTime}):"keySignature"===t.type?r.keySignatures.push({key:e.keySignatureKeys[t.key+7],scale:0===t.scale?"major":"minor",ticks:t.absoluteTime}):"trackName"===t.type?r.name=t.text:"endOfTrack"!==t.type&&r.meta.push({text:t.text,ticks:t.absoluteTime,type:t.type}))}),this.update())}return t.prototype.update=function(){var t=this,e=0,r=0;this.tempos.sort(function(t,e){return t.ticks-e.ticks}),this.tempos.forEach(function(n,i){var a=i>0?t.tempos[i-1].bpm:t.tempos[0].bpm,o=n.ticks/t.ppq-r,s=60/a*o;n.time=s+e,e=n.time,r+=o}),this.timeSignatures.sort(function(t,e){return t.ticks-e.ticks}),this.timeSignatures.forEach(function(e,r){var n=r>0?t.timeSignatures[r-1]:t.timeSignatures[0],i=(e.ticks-n.ticks)/t.ppq/n.timeSignature[0]/(n.timeSignature[1]/4);n.measures=n.measures||0,e.measures=i+n.measures})},t.prototype.ticksToSeconds=function(t){var e=n.search(this.tempos,t);if(-1!==e){var r=this.tempos[e],i=r.time,a=(t-r.ticks)/this.ppq;return i+60/r.bpm*a}return.5*(t/this.ppq)},t.prototype.ticksToMeasures=function(t){var e=n.search(this.timeSignatures,t);if(-1!==e){var r=this.timeSignatures[e],i=(t-r.ticks)/this.ppq;return r.measures+i/(r.timeSignature[0]/r.timeSignature[1])/4}return t/this.ppq/4},Object.defineProperty(t.prototype,"ppq",{get:function(){return i.get(this)},enumerable:!0,configurable:!0}),t.prototype.secondsToTicks=function(t){var e=n.search(this.tempos,t,"time");if(-1!==e){var r=this.tempos[e],i=(t-r.time)/(60/r.bpm);return Math.round(r.ticks+i*this.ppq)}var a=t/.5;return Math.round(a*this.ppq)},t.prototype.toJSON=function(){return{keySignatures:this.keySignatures,meta:this.meta,name:this.name,ppq:this.ppq,tempos:this.tempos.map(function(t){return{bpm:t.bpm,ticks:t.ticks}}),timeSignatures:this.timeSignatures}},t.prototype.fromJSON=function(t){this.name=t.name,this.tempos=t.tempos.map(function(t){return Object.assign({},t)}),this.timeSignatures=t.timeSignatures.map(function(t){return Object.assign({},t)}),this.keySignatures=t.keySignatures.map(function(t){return Object.assign({},t)}),this.meta=t.meta.map(function(t){return Object.assign({},t)}),i.set(this,t.ppq),this.update()},t.prototype.setTempo=function(t){this.tempos=[{bpm:t,ticks:0}],this.update()},t}();e.Header=a},function(t,e,r){"use strict";function n(t,e,r){void 0===r&&(r="ticks");var n=0,i=t.length,a=i;if(i>0&&t[i-1][r]<=e)return i-1;for(;n<a;){var o=Math.floor(n+(a-n)/2),s=t[o],u=t[o+1];if(s[r]===e){for(var c=o;c<t.length;c++){t[c][r]===e&&(o=c)}return o}if(s[r]<e&&u[r]>e)return o;s[r]>e?a=o:s[r]<e&&(n=o+1)}return-1}Object.defineProperty(e,"__esModule",{value:!0}),e.search=n,e.insert=function(t,e,r){if(void 0===r&&(r="ticks"),t.length){var i=n(t,e[r],r);t.splice(i+1,0,e)}else t.push(e)}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.controlChangeNames={1:"modulationWheel",2:"breath",4:"footController",5:"portamentoTime",7:"volume",8:"balance",10:"pan",64:"sustain",65:"portamentoTime",66:"sostenuto",67:"softPedal",68:"legatoFootswitch",84:"portamentoControl"},e.controlChangeIds=Object.keys(e.controlChangeNames).reduce(function(t,r){return t[e.controlChangeNames[r]]=r,t},{});var n=new WeakMap,i=new WeakMap,a=function(){function t(t,e){n.set(this,e),i.set(this,t.controllerType),this.ticks=t.absoluteTime,this.value=t.value}return Object.defineProperty(t.prototype,"number",{get:function(){return i.get(this)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return e.controlChangeNames[this.number]?e.controlChangeNames[this.number]:null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"time",{get:function(){return n.get(this).ticksToSeconds(this.ticks)},set:function(t){var e=n.get(this);this.ticks=e.secondsToTicks(t)},enumerable:!0,configurable:!0}),t.prototype.toJSON=function(){return{number:this.number,ticks:this.ticks,time:this.time,value:this.value}},t}();e.ControlChange=a},function(t,e,r){"use strict";var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))(function(i,a){function o(t){try{u(n.next(t))}catch(t){a(t)}}function s(t){try{u(n.throw(t))}catch(t){a(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(o,s)}u((n=n.apply(t,e||[])).next())})},i=this&&this.__generator||function(t,e){var r,n,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=(i=o.trys).length>0&&i[i.length-1])&&(6===a[0]||2===a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(t,o)}catch(t){a=[6,t],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}};Object.defineProperty(e,"__esModule",{value:!0});var a=r(0),o=r(7),s=r(1),u=r(9),c=function(){function t(t){var e=this,r=null;t&&(t instanceof ArrayBuffer&&(t=new Uint8Array(t)),(r=a.parseMidi(t)).tracks.forEach(function(t){var e=0;t.forEach(function(t){e+=t.deltaTime,t.absoluteTime=e})})),this.header=new s.Header(r),this.tracks=[],t&&(this.tracks=r.tracks.map(function(t){return new u.Track(t,e.header)}),1===r.header.format&&0===this.tracks[0].duration&&this.tracks.shift())}return t.fromUrl=function(e){return n(this,void 0,void 0,function(){var r;return i(this,function(n){switch(n.label){case 0:return[4,fetch(e)];case 1:return(r=n.sent()).ok?[4,r.arrayBuffer()]:[3,3];case 2:return[2,new t(n.sent())];case 3:throw new Error("could not load "+e)}})})},Object.defineProperty(t.prototype,"name",{get:function(){return this.header.name},set:function(t){this.header.name=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"duration",{get:function(){var t=this.tracks.map(function(t){return t.duration});return Math.max.apply(Math,t)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"durationTicks",{get:function(){var t=this.tracks.map(function(t){return t.durationTicks});return Math.max.apply(Math,t)},enumerable:!0,configurable:!0}),t.prototype.addTrack=function(){var t=new u.Track(void 0,this.header);return this.tracks.push(t),t},t.prototype.toArray=function(){return o.encode(this)},t.prototype.toJSON=function(){return{header:this.header.toJSON(),tracks:this.tracks.map(function(t){return t.toJSON()})}},t.prototype.fromJSON=function(t){var e=this;this.header=new s.Header,this.header.fromJSON(t.header),this.tracks=t.tracks.map(function(t){var r=new u.Track(void 0,e.header);return r.fromJSON(t),r})},t.prototype.clone=function(){var e=new t;return e.fromJSON(this.toJSON()),e},t}();e.Midi=c},function(t,e){function r(t){for(var e,r=new n(t),i=[];!r.eof();){var a=o();i.push(a)}return i;function o(){var t={};t.deltaTime=r.readVarInt();var n=r.readUInt8();if(240==(240&n)){if(255!==n){if(240==n){t.type="sysEx";a=r.readVarInt();return t.data=r.readBytes(a),t}if(247==n){t.type="endSysEx";a=r.readVarInt();return t.data=r.readBytes(a),t}throw"Unrecognised MIDI event type byte: "+n}t.meta=!0;var i=r.readUInt8(),a=r.readVarInt();switch(i){case 0:if(t.type="sequenceNumber",2!==a)throw"Expected length for sequenceNumber event is 2, got "+a;return t.number=stream.readUInt16(),t;case 1:return t.type="text",t.text=r.readString(a),t;case 2:return t.type="copyrightNotice",t.text=r.readString(a),t;case 3:return t.type="trackName",t.text=r.readString(a),t;case 4:return t.type="instrumentName",t.text=r.readString(a),t;case 5:return t.type="lyrics",t.text=r.readString(a),t;case 6:return t.type="marker",t.text=r.readString(a),t;case 7:return t.type="cuePoint",t.text=r.readString(a),t;case 32:if(t.type="channelPrefix",1!=a)throw"Expected length for channelPrefix event is 1, got "+a;return t.channel=r.readUInt8(),t;case 33:if(t.type="portPrefix",1!=a)throw"Expected length for portPrefix event is 1, got "+a;return t.port=r.readUInt8(),t;case 47:if(t.type="endOfTrack",0!=a)throw"Expected length for endOfTrack event is 0, got "+a;return t;case 81:if(t.type="setTempo",3!=a)throw"Expected length for setTempo event is 3, got "+a;return t.microsecondsPerBeat=r.readUInt24(),t;case 84:if(t.type="smpteOffset",5!=a)throw"Expected length for smpteOffset event is 5, got "+a;var o=r.readUInt8();return t.frameRate={0:24,32:25,64:29,96:30}[96&o],t.hour=31&o,t.min=r.readUInt8(),t.sec=r.readUInt8(),t.frame=r.readUInt8(),t.subFrame=r.readUInt8(),t;case 88:if(t.type="timeSignature",4!=a)throw"Expected length for timeSignature event is 4, got "+a;return t.numerator=r.readUInt8(),t.denominator=1<<r.readUInt8(),t.metronome=r.readUInt8(),t.thirtyseconds=r.readUInt8(),t;case 89:if(t.type="keySignature",2!=a)throw"Expected length for keySignature event is 2, got "+a;return t.key=r.readInt8(),t.scale=r.readUInt8(),t;case 127:return t.type="sequencerSpecific",t.data=r.readBytes(a),t;default:return t.type="unknownMeta",t.data=r.readBytes(a),t.metatypeByte=i,t}}else{var s;if(0==(128&n)){if(null===e)throw"Running status byte encountered before status byte";s=n,n=e,t.running=!0}else s=r.readUInt8(),e=n;var u=n>>4;switch(t.channel=15&n,u){case 8:return t.type="noteOff",t.noteNumber=s,t.velocity=r.readUInt8(),t;case 9:var c=r.readUInt8();return t.type=0===c?"noteOff":"noteOn",t.noteNumber=s,t.velocity=c,0===c&&(t.byte9=!0),t;case 10:return t.type="noteAftertouch",t.noteNumber=s,t.amount=r.readUInt8(),t;case 11:return t.type="controller",t.controllerType=s,t.value=r.readUInt8(),t;case 12:return t.type="programChange",t.programNumber=s,t;case 13:return t.type="channelAftertouch",t.amount=s,t;case 14:return t.type="pitchBend",t.value=s+(r.readUInt8()<<7)-8192,t;default:throw"Unrecognised MIDI event type: "+u}}}}function n(t){this.buffer=t,this.bufferLen=this.buffer.length,this.pos=0}n.prototype.eof=function(){return this.pos>=this.bufferLen},n.prototype.readUInt8=function(){var t=this.buffer[this.pos];return this.pos+=1,t},n.prototype.readInt8=function(){var t=this.readUInt8();return 128&t?t-256:t},n.prototype.readUInt16=function(){return(this.readUInt8()<<8)+this.readUInt8()},n.prototype.readInt16=function(){var t=this.readUInt16();return 32768&t?t-65536:t},n.prototype.readUInt24=function(){return(this.readUInt8()<<16)+(this.readUInt8()<<8)+this.readUInt8()},n.prototype.readInt24=function(){var t=this.readUInt24();return 8388608&t?t-16777216:t},n.prototype.readUInt32=function(){return(this.readUInt8()<<24)+(this.readUInt8()<<16)+(this.readUInt8()<<8)+this.readUInt8()},n.prototype.readBytes=function(t){var e=this.buffer.slice(this.pos,this.pos+t);return this.pos+=t,e},n.prototype.readString=function(t){var e=this.readBytes(t);return String.fromCharCode.apply(null,e)},n.prototype.readVarInt=function(){for(var t=0;!this.eof();){var e=this.readUInt8();if(!(128&e))return t+e;t+=127&e,t<<=7}return t},n.prototype.readChunk=function(){var t=this.readString(4),e=this.readUInt32();return{id:t,length:e,data:this.readBytes(e)}},t.exports=function(t){var e=new n(t),i=e.readChunk();if("MThd"!=i.id)throw"Bad MIDI file.  Expected 'MHdr', got: '"+i.id+"'";for(var a=function(t){var e=new n(t),r=e.readUInt16(),i=e.readUInt16(),a={format:r,numTracks:i},o=e.readUInt16();return 32768&o?(a.framesPerSecond=256-(o>>8),a.ticksPerFrame=255&o):a.ticksPerBeat=o,a}(i.data),o=[],s=0;!e.eof()&&s<a.numTracks;s++){var u=e.readChunk();if("MTrk"!=u.id)throw"Bad MIDI file.  Expected 'MTrk', got: '"+u.id+"'";var c=r(u.data);o.push(c)}return{header:a,tracks:o}}},function(t,e){function r(t,e,r){var a,o=new i,s=e.length,u=null;for(a=0;a<s;a++)!1!==r.running&&(r.running||e[a].running)||(u=null),u=n(o,e[a],u,r.useByte9ForNoteOff);t.writeChunk("MTrk",o.buffer)}function n(t,e,r,n){var i=e.type,a=e.deltaTime,o=e.text||"",s=e.data||[],u=null;switch(t.writeVarInt(a),i){case"sequenceNumber":t.writeUInt8(255),t.writeUInt8(0),t.writeVarInt(2),t.writeUInt16(e.number);break;case"text":t.writeUInt8(255),t.writeUInt8(1),t.writeVarInt(o.length),t.writeString(o);break;case"copyrightNotice":t.writeUInt8(255),t.writeUInt8(2),t.writeVarInt(o.length),t.writeString(o);break;case"trackName":t.writeUInt8(255),t.writeUInt8(3),t.writeVarInt(o.length),t.writeString(o);break;case"instrumentName":t.writeUInt8(255),t.writeUInt8(4),t.writeVarInt(o.length),t.writeString(o);break;case"lyrics":t.writeUInt8(255),t.writeUInt8(5),t.writeVarInt(o.length),t.writeString(o);break;case"marker":t.writeUInt8(255),t.writeUInt8(6),t.writeVarInt(o.length),t.writeString(o);break;case"cuePoint":t.writeUInt8(255),t.writeUInt8(7),t.writeVarInt(o.length),t.writeString(o);break;case"channelPrefix":t.writeUInt8(255),t.writeUInt8(32),t.writeVarInt(1),t.writeUInt8(e.channel);break;case"portPrefix":t.writeUInt8(255),t.writeUInt8(33),t.writeVarInt(1),t.writeUInt8(e.port);break;case"endOfTrack":t.writeUInt8(255),t.writeUInt8(47),t.writeVarInt(0);break;case"setTempo":t.writeUInt8(255),t.writeUInt8(81),t.writeVarInt(3),t.writeUInt24(e.microsecondsPerBeat);break;case"smpteOffset":t.writeUInt8(255),t.writeUInt8(84),t.writeVarInt(5);var c=31&e.hour|{24:0,25:32,29:64,30:96}[e.frameRate];t.writeUInt8(c),t.writeUInt8(e.min),t.writeUInt8(e.sec),t.writeUInt8(e.frame),t.writeUInt8(e.subFrame);break;case"timeSignature":t.writeUInt8(255),t.writeUInt8(88),t.writeVarInt(4),t.writeUInt8(e.numerator);var h=255&Math.floor(Math.log(e.denominator)/Math.LN2);t.writeUInt8(h),t.writeUInt8(e.metronome),t.writeUInt8(e.thirtyseconds||8);break;case"keySignature":t.writeUInt8(255),t.writeUInt8(89),t.writeVarInt(2),t.writeInt8(e.key),t.writeUInt8(e.scale);break;case"sequencerSpecific":t.writeUInt8(255),t.writeUInt8(127),t.writeVarInt(s.length),t.writeBytes(s);break;case"unknownMeta":null!=e.metatypeByte&&(t.writeUInt8(255),t.writeUInt8(e.metatypeByte),t.writeVarInt(s.length),t.writeBytes(s));break;case"sysEx":t.writeUInt8(240),t.writeVarInt(s.length),t.writeBytes(s);break;case"endSysEx":t.writeUInt8(247),t.writeVarInt(s.length),t.writeBytes(s);break;case"noteOff":(u=(!1!==n&&e.byte9||n&&0==e.velocity?144:128)|e.channel)!==r&&t.writeUInt8(u),t.writeUInt8(e.noteNumber),t.writeUInt8(e.velocity);break;case"noteOn":(u=144|e.channel)!==r&&t.writeUInt8(u),t.writeUInt8(e.noteNumber),t.writeUInt8(e.velocity);break;case"noteAftertouch":(u=160|e.channel)!==r&&t.writeUInt8(u),t.writeUInt8(e.noteNumber),t.writeUInt8(e.amount);break;case"controller":(u=176|e.channel)!==r&&t.writeUInt8(u),t.writeUInt8(e.controllerType),t.writeUInt8(e.value);break;case"programChange":(u=192|e.channel)!==r&&t.writeUInt8(u),t.writeUInt8(e.programNumber);break;case"channelAftertouch":(u=208|e.channel)!==r&&t.writeUInt8(u),t.writeUInt8(e.amount);break;case"pitchBend":(u=224|e.channel)!==r&&t.writeUInt8(u);var f=8192+e.value,p=127&f,l=f>>7&127;t.writeUInt8(p),t.writeUInt8(l);break;default:throw"Unrecognized event type: "+i}return u}function i(){this.buffer=[]}i.prototype.writeUInt8=function(t){this.buffer.push(255&t)},i.prototype.writeInt8=i.prototype.writeUInt8,i.prototype.writeUInt16=function(t){var e=t>>8&255,r=255&t;this.writeUInt8(e),this.writeUInt8(r)},i.prototype.writeInt16=i.prototype.writeUInt16,i.prototype.writeUInt24=function(t){var e=t>>16&255,r=t>>8&255,n=255&t;this.writeUInt8(e),this.writeUInt8(r),this.writeUInt8(n)},i.prototype.writeInt24=i.prototype.writeUInt24,i.prototype.writeUInt32=function(t){var e=t>>24&255,r=t>>16&255,n=t>>8&255,i=255&t;this.writeUInt8(e),this.writeUInt8(r),this.writeUInt8(n),this.writeUInt8(i)},i.prototype.writeInt32=i.prototype.writeUInt32,i.prototype.writeBytes=function(t){this.buffer=this.buffer.concat(Array.prototype.slice.call(t,0))},i.prototype.writeString=function(t){var e,r=t.length,n=[];for(e=0;e<r;e++)n.push(t.codePointAt(e));this.writeBytes(n)},i.prototype.writeVarInt=function(t){if(t<0)throw"Cannot write negative variable-length integer";if(t<=127)this.writeUInt8(t);else{var e=t,r=[];for(r.push(127&e),e>>=7;e;){var n=127&e|128;r.push(n),e>>=7}this.writeBytes(r.reverse())}},i.prototype.writeChunk=function(t,e){this.writeString(t),this.writeUInt32(e.length),this.writeBytes(e)},t.exports=function(t,e){if("object"!=typeof t)throw"Invalid MIDI data";e=e||{};var n,a=t.header||{},o=t.tracks||[],s=o.length,u=new i;for(function(t,e,r){var n=null==e.format?1:e.format,a=128;e.timeDivision?a=e.timeDivision:e.ticksPerFrame&&e.framesPerSecond?a=-(255&e.framesPerSecond)<<8|255&ticksPerFrame:e.ticksPerBeat&&(a=32767&e.ticksPerBeat);var o=new i;o.writeUInt16(n),o.writeUInt16(r),o.writeUInt16(a),t.writeChunk("MThd",o.buffer)}(u,a,s),n=0;n<s;n++)r(u,o[n],e);return u.buffer}},function(t,e,r){"use strict";var n=this&&this.__spreadArrays||function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;var n=Array(t),i=0;for(e=0;e<r;e++)for(var a=arguments[e],o=0,s=a.length;o<s;o++,i++)n[i]=a[o];return n},i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var a=r(0),o=r(1),s=i(r(8));function u(t){return s.default(t.notes.map(function(e){return function(t,e){return[{absoluteTime:t.ticks,channel:e,deltaTime:0,noteNumber:t.midi,type:"noteOn",velocity:Math.floor(127*t.velocity)},{absoluteTime:t.ticks+t.durationTicks,channel:e,deltaTime:0,noteNumber:t.midi,type:"noteOff",velocity:Math.floor(127*t.noteOffVelocity)}]}(e,t.channel)}))}function c(t,e){return{absoluteTime:t.ticks,channel:e,controllerType:t.number,deltaTime:0,type:"controller",value:t.value}}function h(t){return{absoluteTime:0,channel:t.channel,deltaTime:0,programNumber:t.instrument.number,type:"programChange"}}e.encode=function(t){var e={header:{format:1,numTracks:t.tracks.length+1,ticksPerBeat:t.header.ppq},tracks:n([n([{absoluteTime:0,deltaTime:0,meta:!0,text:t.header.name,type:"trackName"}],t.header.keySignatures.map(function(t){return function(t){var e=o.keySignatureKeys.indexOf(t.key);return{absoluteTime:t.ticks,deltaTime:0,key:e+7,meta:!0,scale:"major"===t.scale?0:1,type:"keySignature"}}(t)}),t.header.meta.map(function(t){return{absoluteTime:(e=t).ticks,deltaTime:0,meta:!0,text:e.text,type:e.type};var e}),t.header.tempos.map(function(t){return function(t){return{absoluteTime:t.ticks,deltaTime:0,meta:!0,microsecondsPerBeat:Math.floor(6e7/t.bpm),type:"setTempo"}}(t)}),t.header.timeSignatures.map(function(t){return function(t){return{absoluteTime:t.ticks,deltaTime:0,denominator:t.timeSignature[1],meta:!0,metronome:24,numerator:t.timeSignature[0],thirtyseconds:8,type:"timeSignature"}}(t)}))],t.tracks.map(function(t){return n([(e=t.name,{absoluteTime:0,deltaTime:0,meta:!0,text:e,type:"trackName"}),h(t)],u(t),function(t){for(var e=[],r=0;r<127;r++)t.controlChanges.hasOwnProperty(r)&&t.controlChanges[r].forEach(function(r){e.push(c(r,t.channel))});return e}(t),function(t){var e=[];return t.pitchBends.forEach(function(r){e.push(function(t,e){return{absoluteTime:t.ticks,channel:e,deltaTime:0,type:"pitchBend",value:t.value}}(r,t.channel))}),e}(t));var e}))};return e.tracks=e.tracks.map(function(t){t=t.sort(function(t,e){return t.absoluteTime-e.absoluteTime});var e=0;return t.forEach(function(t){t.deltaTime=t.absoluteTime-e,e=t.absoluteTime,delete t.absoluteTime}),t.push({deltaTime:0,meta:!0,type:"endOfTrack"}),t}),new Uint8Array(a.writeMidi(e))}},function(t,e,r){"use strict";function n(t){return function t(e,r){for(var n=0;n<e.length;n++){var i=e[n];Array.isArray(i)?t(i,r):r.push(i)}return r}(t,[])}function i(t,e){if("number"!=typeof e)throw new TypeError("Expected the depth to be a number");return function t(e,r,n){n--;for(var i=0;i<e.length;i++){var a=e[i];n>-1&&Array.isArray(a)?t(a,r,n):r.push(a)}return r}(t,[],e)}t.exports=function(t){if(!Array.isArray(t))throw new TypeError("Expected value to be an array");return n(t)},t.exports.from=n,t.exports.depth=function(t,e){if(!Array.isArray(t))throw new TypeError("Expected value to be an array");return i(t,e)},t.exports.fromDepth=i},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(2),i=r(3),a=r(10),o=r(11),s=r(12),u=r(14),c=new WeakMap,h=function(){function t(t,e){var r=this;if(this.name="",this.notes=[],this.controlChanges=a.createControlChanges(),this.pitchBends=[],c.set(this,e),t){var n=t.find(function(t){return"trackName"===t.type});this.name=n?n.text:""}if(this.instrument=new s.Instrument(t,this),this.channel=0,t){for(var i=t.filter(function(t){return"noteOn"===t.type}),o=t.filter(function(t){return"noteOff"===t.type}),u=function(){var t=i.shift();h.channel=t.channel;var e=o.findIndex(function(e){return e.noteNumber===t.noteNumber&&e.absoluteTime>=t.absoluteTime});if(-1!==e){var r=o.splice(e,1)[0];h.addNote({durationTicks:r.absoluteTime-t.absoluteTime,midi:t.noteNumber,noteOffVelocity:r.velocity/127,ticks:t.absoluteTime,velocity:t.velocity/127})}},h=this;i.length;)u();t.filter(function(t){return"controller"===t.type}).forEach(function(t){r.addCC({number:t.controllerType,ticks:t.absoluteTime,value:t.value/127})}),t.filter(function(t){return"pitchBend"===t.type}).forEach(function(t){r.addPitchBend({ticks:t.absoluteTime,value:t.value/Math.pow(2,13)})})}}return t.prototype.addNote=function(t){var e=c.get(this),r=new u.Note({midi:0,ticks:0,velocity:1},{ticks:0,velocity:0},e);return Object.assign(r,t),n.insert(this.notes,r,"ticks"),this},t.prototype.addCC=function(t){var e=c.get(this),r=new i.ControlChange({controllerType:t.number},e);return delete t.number,Object.assign(r,t),Array.isArray(this.controlChanges[r.number])||(this.controlChanges[r.number]=[]),n.insert(this.controlChanges[r.number],r,"ticks"),this},t.prototype.addPitchBend=function(t){var e=c.get(this),r=new o.PitchBend({},e);return Object.assign(r,t),n.insert(this.pitchBends,r,"ticks"),this},Object.defineProperty(t.prototype,"duration",{get:function(){var t=this.notes[this.notes.length-1];return t?t.time+t.duration:0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"durationTicks",{get:function(){var t=this.notes[this.notes.length-1];return t?t.ticks+t.durationTicks:0},enumerable:!0,configurable:!0}),t.prototype.fromJSON=function(t){var e=this;for(var r in this.name=t.name,this.channel=t.channel,this.instrument=new s.Instrument(void 0,this),this.instrument.fromJSON(t.instrument),t.controlChanges)t.controlChanges[r]&&t.controlChanges[r].forEach(function(t){e.addCC({number:t.number,ticks:t.ticks,value:t.value})});t.notes.forEach(function(t){e.addNote({durationTicks:t.durationTicks,midi:t.midi,ticks:t.ticks,velocity:t.velocity})})},t.prototype.toJSON=function(){for(var t={},e=0;e<127;e++)this.controlChanges.hasOwnProperty(e)&&(t[e]=this.controlChanges[e].map(function(t){return t.toJSON()}));return{channel:this.channel,controlChanges:t,pitchBends:this.pitchBends.map(function(t){return t.toJSON()}),instrument:this.instrument.toJSON(),name:this.name,notes:this.notes.map(function(t){return t.toJSON()})}},t}();e.Track=h},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(3);e.createControlChanges=function(){return new Proxy({},{get:function(t,e){return t[e]?t[e]:n.controlChangeIds.hasOwnProperty(e)?t[n.controlChangeIds[e]]:void 0},set:function(t,e,r){return n.controlChangeIds.hasOwnProperty(e)?t[n.controlChangeIds[e]]=r:t[e]=r,!0}})}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=new WeakMap,i=function(){function t(t,e){n.set(this,e),this.ticks=t.absoluteTime,this.value=t.value}return Object.defineProperty(t.prototype,"time",{get:function(){return n.get(this).ticksToSeconds(this.ticks)},set:function(t){var e=n.get(this);this.ticks=e.secondsToTicks(t)},enumerable:!0,configurable:!0}),t.prototype.toJSON=function(){return{ticks:this.ticks,time:this.time,value:this.value}},t}();e.PitchBend=i},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(13),i=new WeakMap,a=function(){function t(t,e){if(this.number=0,i.set(this,e),this.number=0,t){var r=t.find(function(t){return"programChange"===t.type});r&&(this.number=r.programNumber)}}return Object.defineProperty(t.prototype,"name",{get:function(){return this.percussion?n.DrumKitByPatchID[this.number]:n.instrumentByPatchID[this.number]},set:function(t){var e=n.instrumentByPatchID.indexOf(t);-1!==e&&(this.number=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"family",{get:function(){return this.percussion?"drums":n.InstrumentFamilyByID[Math.floor(this.number/8)]},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"percussion",{get:function(){return 9===i.get(this).channel},enumerable:!0,configurable:!0}),t.prototype.toJSON=function(){return{family:this.family,name:this.name,number:this.number}},t.prototype.fromJSON=function(t){this.number=t.number},t}();e.Instrument=a},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.instrumentByPatchID=["acoustic grand piano","bright acoustic piano","electric grand piano","honky-tonk piano","electric piano 1","electric piano 2","harpsichord","clavi","celesta","glockenspiel","music box","vibraphone","marimba","xylophone","tubular bells","dulcimer","drawbar organ","percussive organ","rock organ","church organ","reed organ","accordion","harmonica","tango accordion","acoustic guitar (nylon)","acoustic guitar (steel)","electric guitar (jazz)","electric guitar (clean)","electric guitar (muted)","overdriven guitar","distortion guitar","guitar harmonics","acoustic bass","electric bass (finger)","electric bass (pick)","fretless bass","slap bass 1","slap bass 2","synth bass 1","synth bass 2","violin","viola","cello","contrabass","tremolo strings","pizzicato strings","orchestral harp","timpani","string ensemble 1","string ensemble 2","synthstrings 1","synthstrings 2","choir aahs","voice oohs","synth voice","orchestra hit","trumpet","trombone","tuba","muted trumpet","french horn","brass section","synthbrass 1","synthbrass 2","soprano sax","alto sax","tenor sax","baritone sax","oboe","english horn","bassoon","clarinet","piccolo","flute","recorder","pan flute","blown bottle","shakuhachi","whistle","ocarina","lead 1 (square)","lead 2 (sawtooth)","lead 3 (calliope)","lead 4 (chiff)","lead 5 (charang)","lead 6 (voice)","lead 7 (fifths)","lead 8 (bass + lead)","pad 1 (new age)","pad 2 (warm)","pad 3 (polysynth)","pad 4 (choir)","pad 5 (bowed)","pad 6 (metallic)","pad 7 (halo)","pad 8 (sweep)","fx 1 (rain)","fx 2 (soundtrack)","fx 3 (crystal)","fx 4 (atmosphere)","fx 5 (brightness)","fx 6 (goblins)","fx 7 (echoes)","fx 8 (sci-fi)","sitar","banjo","shamisen","koto","kalimba","bag pipe","fiddle","shanai","tinkle bell","agogo","steel drums","woodblock","taiko drum","melodic tom","synth drum","reverse cymbal","guitar fret noise","breath noise","seashore","bird tweet","telephone ring","helicopter","applause","gunshot"],e.InstrumentFamilyByID=["piano","chromatic percussion","organ","guitar","bass","strings","ensemble","brass","reed","pipe","synth lead","synth pad","synth effects","world","percussive","sound effects"],e.DrumKitByPatchID={0:"standard kit",8:"room kit",16:"power kit",24:"electronic kit",25:"tr-808 kit",32:"jazz kit",40:"brush kit",48:"orchestra kit",56:"sound fx kit"}},function(t,e,r){"use strict";function n(t){return["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"][t%12]}Object.defineProperty(e,"__esModule",{value:!0});var i,a,o=(i=/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i,a={cbb:-2,cb:-1,c:0,"c#":1,cx:2,dbb:0,db:1,d:2,"d#":3,dx:4,ebb:2,eb:3,e:4,"e#":5,ex:6,fbb:3,fb:4,f:5,"f#":6,fx:7,gbb:5,gb:6,g:7,"g#":8,gx:9,abb:7,ab:8,a:9,"a#":10,ax:11,bbb:9,bb:10,b:11,"b#":12,bx:13},function(t){var e=i.exec(t),r=e[1],n=e[2];return a[r.toLowerCase()]+12*(parseInt(n,10)+1)}),s=new WeakMap,u=function(){function t(t,e,r){s.set(this,r),this.midi=t.midi,this.velocity=t.velocity,this.noteOffVelocity=e.velocity,this.ticks=t.ticks,this.durationTicks=e.ticks-t.ticks}return Object.defineProperty(t.prototype,"name",{get:function(){return t=this.midi,e=Math.floor(t/12)-1,n(t)+e.toString();var t,e},set:function(t){this.midi=o(t)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"octave",{get:function(){return Math.floor(this.midi/12)-1},set:function(t){var e=t-this.octave;this.midi+=12*e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pitch",{get:function(){return n(this.midi)},set:function(t){this.midi=12*(this.octave+1)+["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"].indexOf(t)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"duration",{get:function(){var t=s.get(this);return t.ticksToSeconds(this.ticks+this.durationTicks)-t.ticksToSeconds(this.ticks)},set:function(t){var e=s.get(this).secondsToTicks(this.time+t);this.durationTicks=e-this.ticks},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"time",{get:function(){return s.get(this).ticksToSeconds(this.ticks)},set:function(t){var e=s.get(this);this.ticks=e.secondsToTicks(t)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bars",{get:function(){return s.get(this).ticksToMeasures(this.ticks)},enumerable:!0,configurable:!0}),t.prototype.toJSON=function(){return{duration:this.duration,durationTicks:this.durationTicks,midi:this.midi,name:this.name,ticks:this.ticks,time:this.time,velocity:this.velocity}},t}();e.Note=u}])});
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement