UNPKG

scribbletune

Version:

Create music with JavaScript and Node.js!

2 lines 24 kB
(()=>{var e={397:(e,t)=>{(()=>{"use strict";var e={413:e=>{e.exports=JSON.parse('{"5th":"100000010000","M7#5sus4":"100001001001","7#5sus4":"100001001010","sus4":"100001010000","M7sus4":"100001010001","7sus4":"100001010010","7no5":"100010000010","aug":"100010001000","M7b6":"100010001001","maj7#5":"100010001001","7#5":"100010001010","7b13":"100010001010","M":"100010010000","maj7":"100010010001","7th":"100010010010","6th":"100010010100","7add6":"100010010110","7b6":"100010011010","Mb5":"100010100000","M7b5":"100010100001","7b5":"100010100010","maj#4":"100010110001","7#11":"100010110010","M6#11":"100010110100","7#11b13":"100010111010","m#5":"100100001000","mb6M7":"100100001001","m7#5":"100100001010","m":"100100010000","m/ma7":"100100010001","m7":"100100010010","m6":"100100010100","mMaj7b6":"100100011001","dim":"100100100000","oM7":"100100100001","m7b5":"100100100010","dim7":"100100100100","o7M7":"100100100101","4th":"100101000010","madd4":"100101010000","m7add11":"100101010010","+add#9":"100110001000","7#5#9":"100110001010","7#9":"100110010010","13#9":"100110010110","7#9b13":"100110011010","maj7#9#11":"100110110001","7#9#11":"100110110010","13#9#11":"100110110110","7#9#11b13":"100110111010","sus2":"101000010000","M9#5sus4":"101001001001","sus24":"101001010000","M9sus4":"101001010001","11th":"101001010010","9sus4":"101001010010","13sus4":"101001010110","9no5":"101010000010","13no5":"101010000110","M#5add9":"101010001000","maj9#5":"101010001001","9#5":"101010001010","9b13":"101010001010","Madd9":"101010010000","maj9":"101010010001","9th":"101010010010","6/9":"101010010100","maj13":"101010010101","M7add13":"101010010101","13th":"101010010110","M9b5":"101010100001","9b5":"101010100010","13b5":"101010100110","9#5#11":"101010101010","maj9#11":"101010110001","9#11":"101010110010","69#11":"101010110100","M13#11":"101010110101","13#11":"101010110110","9#11b13":"101010111010","m9#5":"101100001010","madd9":"101100010000","mM9":"101100010001","m9":"101100010010","m69":"101100010100","m13":"101100010110","mMaj9b6":"101100011001","m9b5":"101100100010","m11A":"101101001010","m11":"101101010010","b9sus":"110001010010","11b9":"110001010010","7sus4b9b13":"110001011010","alt7":"110010000010","7#5b9":"110010001010","Maddb9":"110010010000","M7b9":"110010010001","7b9":"110010010010","13b9":"110010010110","7b9b13":"110010011010","7#5b9#11":"110010101010","7b9#11":"110010110010","13b9#11":"110010110110","7b9b13#11":"110010111010","mb6b9":"110100001000","7b9#9":"110110010010"}')},722:e=>{e.exports=JSON.parse('{"major pentatonic":"101010010100","ionian pentatonic":"100011010001","mixolydian pentatonic":"100011010010","ritusen":"101001010100","egyptian":"101001010010","neopolitan major pentatonic":"100011100010","vietnamese 1":"100101011000","pelog":"110100011000","kumoijoshi":"110001011000","hirajoshi":"101100011000","iwato":"110001100010","in-sen":"110001010010","lydian pentatonic":"100010110001","malkos raga":"100101001010","locrian pentatonic":"100101100010","minor pentatonic":"100101010010","minor six pentatonic":"100101010100","flat three pentatonic":"101100010100","flat six pentatonic":"101010011000","scriabin":"110010010100","whole tone pentatonic":"100010101010","lydian #5P pentatonic":"100010101001","lydian dominant pentatonic":"100010110010","minor #7M pentatonic":"100101010001","super locrian pentatonic":"100110100010","minor hexatonic":"101101010001","augmented":"100110011001","major blues":"101110010100","piongio":"101001010110","prometheus neopolitan":"110010100110","prometheus":"101010100110","mystery #1":"110010101010","six tone symmetric":"110011001100","whole tone":"101010101010","messiaen\'s mode #5":"110001110001","minor blues":"100101110010","locrian major":"101011101010","double harmonic lydian":"110010111001","harmonic minor":"101101011001","altered":"110110101010","locrian #2":"101101101010","mixolydian b6":"101011011010","lydian dominant":"101010110110","lydian":"101010110101","lydian augmented":"101010101101","dorian b2":"110101010110","melodic minor":"101101010101","locrian":"110101101010","ultralocrian":"110110101100","locrian 6":"110101100110","augmented heptatonic":"100111011001","romanian minor":"101100110110","dorian #4":"101100110110","lydian diminished":"101100110101","phrygian":"110101011010","leading whole tone":"101010101011","lydian minor":"101010111010","phrygian dominant":"110011011010","balinese":"110101011001","neopolitan major":"110101010101","aeolian":"101101011010","harmonic major":"101011011001","double harmonic major":"110011011001","dorian":"101101010110","hungarian minor":"101100111001","hungarian major":"100110110110","oriental":"110011100110","flamenco":"110110110010","todi raga":"110100111001","mixolydian":"101011010110","persian":"110011101001","major":"101011010101","enigmatic":"110010101011","major augmented":"101011001101","lydian #9":"100110110101","messiaen\'s mode #4":"111001111001","purvi raga":"110011111001","spanish heptatonic":"110111011010","bebop":"101011010111","bebop minor":"101111010110","bebop major":"101011011101","bebop locrian":"110101111010","minor bebop":"101101011011","diminished":"101101101101","ichikosucho":"101011110101","minor six diminished":"101101011101","half-whole diminished":"110110110110","kafi raga":"100111010111","messiaen\'s mode #6":"101011101011","composite blues":"101111110110","messiaen\'s mode #3":"101110111011","messiaen\'s mode #7":"111101111101","chromatic":"111111111111","ionian":"101011010101","minor":"101101011010"}')}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return e[t](i,i.exports,n),i.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};(()=>{n.r(o),n.d(o,{chord:()=>c,chords:()=>a,inlineChord:()=>i,scale:()=>u,scales:()=>s});var e=n(722),t=n(413),r=function(r){var n=r.scale,o=r.chord,i=n||o,a=n?"scale":"chord";if("string"!=typeof i)throw new Error("".concat(i," is not a valid input for ").concat(a));var s,c,u=i.indexOf(" ");-1===u?(s=i.slice(1),c=i[0],"b"!==i[1]&&"#"!==i[1]||(s=i.slice(2),c+=i[1])):(s=i.slice(-1===u?1:u+1),c=i.slice(0,u));var p=function(e){return{"C#":"Db","D#":"Eb","F#":"Gb","G#":"Ab","A#":"Bb"}[e.toUpperCase()]||e.charAt(0).toUpperCase()+e.slice(1)}(c.replace(/\d/g,"")),h=""!==c.replace(/\D/g,"")?+c.replace(/\D/g,""):4;if(isNaN(h))throw new Error("".concat(c[0]," does not have a valid octave"));if(!e[s]&&!t[s])throw new Error("".concat(i," is not a valid ").concat(a));for(var d=function(e,t){var r=["C","Db","D","Eb","E","F","Gb","G","Ab","A","Bb","B"],n=r.map((function(e){return e+t})),o=r.map((function(e){return e+(t+1)})),i=n.concat(o);return i.slice(i.indexOf(e+t))}(p,h),l=[],f=0,m=0,v=n?e:t;f<v[s].length;)"1"===v[s][f]&&l.push(d[m]),f++,m++;return l},i=function(e){var t,n,o="b9sus",i=4;return e.includes(o)?(n=o,t=e.slice(0,e.indexOf(o))):(t=e[0],n=e.slice(1),"b"!==e[1]&&"#"!==e[1]||(t+=e[1],n=e.slice(2))),e.includes("_")&&(i=+e.split("_")[1],n=n.slice(0,n.indexOf("_"))),r({chord:t+i+" "+n})},a=function(){return Object.keys(t)},s=function(){return Object.keys(e)},c=function(e){return r({chord:e})},u=function(e){return r({scale:e})}})();var i=t;for(var a in o)i[a]=o[a];o.__esModule&&Object.defineProperty(i,"__esModule",{value:!0})})()},126:function(e,t,r){e=r.nmd(e);var n={};!function(e){var t=e.DEFAULT_VOLUME=90,r=(e.DEFAULT_DURATION=128,e.DEFAULT_CHANNEL=0,{midi_letter_pitches:{a:21,b:23,c:12,d:14,e:16,f:17,g:19},midiPitchFromNote:function(e){var t=/([a-g])(#+|b+)?([0-9]+)$/i.exec(e),n=t[1].toLowerCase(),o=t[2]||"";return 12*parseInt(t[3],10)+r.midi_letter_pitches[n]+("#"==o.substr(0,1)?1:-1)*o.length},ensureMidiPitch:function(e){return"number"!=typeof e&&/[^0-9]/.test(e)?r.midiPitchFromNote(e):parseInt(e,10)},midi_pitches_letter:{12:"c",13:"c#",14:"d",15:"d#",16:"e",17:"f",18:"f#",19:"g",20:"g#",21:"a",22:"a#",23:"b"},midi_flattened_notes:{"a#":"bb","c#":"db","d#":"eb","f#":"gb","g#":"ab"},noteFromMidiPitch:function(e,t){var n,o=0,i=e;return t=t||!1,e>23&&(i=e-12*(o=Math.floor(e/12)-1)),n=r.midi_pitches_letter[i],t&&n.indexOf("#")>0&&(n=r.midi_flattened_notes[n]),n+o},mpqnFromBpm:function(e){var t=Math.floor(6e7/e),r=[];do{r.unshift(255&t),t>>=8}while(t);for(;r.length<3;)r.push(0);return r},bpmFromMpqn:function(e){if(void 0!==e[0])for(var t=0,r=e.length-1;r>=0;++t,--r)e[t];return Math.floor(6e7/e)},codes2Str:function(e){return String.fromCharCode.apply(null,e)},str2Bytes:function(e,t){if(t)for(;e.length/2<t;)e="0"+e;for(var r=[],n=e.length-1;n>=0;n-=2){var o=0===n?e[n]:e[n-1]+e[n];r.unshift(parseInt(o,16))}return r},translateTickTime:function(e){for(var t=127&e;e>>=7;)t<<=8,t|=127&e|128;for(var r=[];r.push(255&t),128&t;)t>>=8;return r}}),n=function(e){if(!this)return new n(e);!e||null===e.type&&void 0===e.type||null===e.channel&&void 0===e.channel||null===e.param1&&void 0===e.param1||(this.setTime(e.time),this.setType(e.type),this.setChannel(e.channel),this.setParam1(e.param1),this.setParam2(e.param2))};n.NOTE_OFF=128,n.NOTE_ON=144,n.AFTER_TOUCH=160,n.CONTROLLER=176,n.PROGRAM_CHANGE=192,n.CHANNEL_AFTERTOUCH=208,n.PITCH_BEND=224,n.prototype.setTime=function(e){this.time=r.translateTickTime(e||0)},n.prototype.setType=function(e){if(e<n.NOTE_OFF||e>n.PITCH_BEND)throw new Error("Trying to set an unknown event: "+e);this.type=e},n.prototype.setChannel=function(e){if(e<0||e>15)throw new Error("Channel is out of bounds.");this.channel=e},n.prototype.setParam1=function(e){this.param1=e},n.prototype.setParam2=function(e){this.param2=e},n.prototype.toBytes=function(){var e=[],t=this.type|15&this.channel;return e.push.apply(e,this.time),e.push(t),e.push(this.param1),void 0!==this.param2&&null!==this.param2&&e.push(this.param2),e};var o=function(e){if(!this)return new o(e);this.setTime(e.time),this.setType(e.type),this.setData(e.data)};o.SEQUENCE=0,o.TEXT=1,o.COPYRIGHT=2,o.TRACK_NAME=3,o.INSTRUMENT=4,o.LYRIC=5,o.MARKER=6,o.CUE_POINT=7,o.CHANNEL_PREFIX=32,o.END_OF_TRACK=47,o.TEMPO=81,o.SMPTE=84,o.TIME_SIG=88,o.KEY_SIG=89,o.SEQ_EVENT=127,o.prototype.setTime=function(e){this.time=r.translateTickTime(e||0)},o.prototype.setType=function(e){this.type=e},o.prototype.setData=function(e){this.data=e},o.prototype.toBytes=function(){if(!this.type)throw new Error("Type for meta-event not specified.");var e=[];if(e.push.apply(e,this.time),e.push(255,this.type),Array.isArray(this.data))e.push(this.data.length),e.push.apply(e,this.data);else if("number"==typeof this.data)e.push(1,this.data);else if(null!==this.data&&void 0!==this.data){e.push(this.data.length);var t=this.data.split("").map((function(e){return e.charCodeAt(0)}));e.push.apply(e,t)}else e.push(0);return e};var i=function(e){if(!this)return new i(e);var t=e||{};this.events=t.events||[]};i.START_BYTES=[77,84,114,107],i.END_BYTES=[0,255,47,0],i.prototype.addEvent=function(e){return this.events.push(e),this},i.prototype.addNoteOn=i.prototype.noteOn=function(e,o,i,a){return this.events.push(new n({type:n.NOTE_ON,channel:e,param1:r.ensureMidiPitch(o),param2:a||t,time:i||0})),this},i.prototype.addNoteOff=i.prototype.noteOff=function(e,o,i,a){return this.events.push(new n({type:n.NOTE_OFF,channel:e,param1:r.ensureMidiPitch(o),param2:a||t,time:i||0})),this},i.prototype.addNote=i.prototype.note=function(e,t,r,n,o){return this.noteOn(e,t,n,o),r&&this.noteOff(e,t,r,o),this},i.prototype.addChord=i.prototype.chord=function(e,t,r,n){if(!Array.isArray(t)&&!t.length)throw new Error("Chord must be an array of pitches");return t.forEach((function(t){this.noteOn(e,t,0,n)}),this),t.forEach((function(t,n){0===n?this.noteOff(e,t,r):this.noteOff(e,t)}),this),this},i.prototype.setInstrument=i.prototype.instrument=function(e,t,r){return this.events.push(new n({type:n.PROGRAM_CHANGE,channel:e,param1:t,time:r||0})),this},i.prototype.setTempo=i.prototype.tempo=function(e,t){return this.events.push(new o({type:o.TEMPO,data:r.mpqnFromBpm(e),time:t||0})),this},i.prototype.toBytes=function(){var e=0,t=[],n=i.START_BYTES,o=i.END_BYTES;this.events.forEach((function(r){var n=r.toBytes();e+=n.length,t.push.apply(t,n)})),e+=o.length;var a=r.str2Bytes(e.toString(16),4);return n.concat(a,t,o)};var a=function(e){if(!this)return new a(e);var t=e||{};if(t.ticks){if("number"!=typeof t.ticks)throw new Error("Ticks per beat must be a number!");if(t.ticks<=0||t.ticks>=32768||t.ticks%1!=0)throw new Error("Ticks per beat must be an integer between 1 and 32767!")}this.ticks=t.ticks||128,this.tracks=t.tracks||[]};a.HDR_CHUNKID="MThd",a.HDR_CHUNK_SIZE="\0\0\0",a.HDR_TYPE0="\0\0",a.HDR_TYPE1="\0",a.prototype.addTrack=function(e){return e?(this.tracks.push(e),this):(e=new i,this.tracks.push(e),e)},a.prototype.toBytes=function(){var e=this.tracks.length.toString(16),t=a.HDR_CHUNKID+a.HDR_CHUNK_SIZE;return parseInt(e,16)>1?t+=a.HDR_TYPE1:t+=a.HDR_TYPE0,t+=r.codes2Str(r.str2Bytes(e,2)),t+=String.fromCharCode(this.ticks/256,this.ticks%256),this.tracks.forEach((function(e){t+=r.codes2Str(e.toBytes())})),t},e.Util=r,e.File=a,e.Track=i,e.Event=n,e.MetaEvent=o}(n),null!==e?e.exports=n:null!==t?t=n:this.Midi=n},148:function(e,t,r){"use strict";var n=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.arp=void 0;var o=r(397),i=r(604),a=function(e,t){var r=function(e){if(!e)throw new Error("Empty element");var t=e.replace(/\d/,""),r=e.replace(/\D/g,"")||4;if(!t)throw new Error("Incorrect note");return t+(+r+1)},o=e.map(r),i=o.map(r);return n(n(n([],e,!0),o,!0),i,!0).slice(0,t)};t.arp=function(e){var t=[],r={count:4,order:"0123",chords:""};if("string"==typeof e)r.chords=e;else{if(e.order&&e.order.match(/\D/g))throw new TypeError("Invalid value for order");if(e.count>8||e.count<2)throw new TypeError("Invalid value for count");e.count&&!e.order&&(r.order=Array.from(Array(e.count).keys()).join("")),Object.assign(r,e)}if("string"==typeof r.chords)r.chords.split(" ").forEach((function(e,i){try{var s=a((0,o.inlineChord)(e),r.count),c=r.order.split("").map((function(e){return s[e]}));t=n(n([],t,!0),c,!0)}catch(t){throw new Error("Cannot decode chord "+(i+1)+' "'+e+'" in given "'+r.chords+'"')}}));else{if(!Array.isArray(r.chords))throw new TypeError("Invalid value for chords");r.chords.forEach((function(e,o){try{var s=a(e,r.count),c=r.order.split("").map((function(e){return s[e]}));t=n(n([],t,!0),c,!0)}catch(t){throw new Error(((0,i.errorHasMessage)(t)?t.message:t)+" in chord "+(o+1)+' "'+e+'"')}}))}return t}},768:function(e,t,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.clip=void 0;var o=r(604),i={"1m":2048,"2m":4096,"3m":6144,"4m":8192,"1n":512,"2n":256,"4n":128,"8n":64,"16n":32};t.clip=function(e){if("string"==typeof(e=n(n({},{notes:["C4"],pattern:"x",shuffle:!1,sizzle:!1,sizzleReps:1,arpegiate:!1,subdiv:"4n",amp:100,accentLow:70,randomNotes:null,offlineRendering:!1}),e||{})).notes&&(e.notes=e.notes.replace(/\s{2,}/g," "),e.notes=e.notes.split(" ")),e.notes=e.notes?e.notes.map(o.convertChordsToNotes):[],/[^x\-_[\]R]/.test(e.pattern))throw new TypeError("pattern can only comprise x - _ [ ] R, found "+e.pattern);e.shuffle&&(e.notes=(0,o.shuffle)(e.notes)),e.randomNotes&&"string"==typeof e.randomNotes&&(e.randomNotes=e.randomNotes.replace(/\s{2,}/g," ").split(/\s/)),e.randomNotes&&(e.randomNotes=e.randomNotes.map(o.convertChordsToNotes));var t=[],r=0,a=function(n,i,s){var c=0;n.forEach((function(u,p){var h;if("string"==typeof u){var d=null;if("-"===u||("R"===u&&(0,o.randomInt)()&&e.randomNotes&&e.randomNotes.length>0?d=e.randomNotes[(0,o.randomInt)(e.randomNotes.length-1)]:e.notes&&(d=e.notes[r])),"x"!==u&&"R"!==u||r++,"x"!==u&&"-"!==u&&"R"!==u||(t.push({note:d,length:i,level:"R"!==u||e.randomNotes?e.amp:e.accentLow}),c+=i),"_"===u&&t.length&&(t[t.length-1].length+=i,c+=i),s&&c!==s&&p===n.length-1){var l=Math.abs(s-c),f=t[t.length-1];f.length>l?f.length=f.length-l:f.length=f.length+l}r===(null===(h=e.notes)||void 0===h?void 0:h.length)&&(r=0)}if(Array.isArray(u)){var m=!1;u.length%2==0&&i%2==0||(m=!0),a(u,Math.round(i/u.length),m&&i),c+=i}}))};if(a((0,o.expandStr)(e.pattern),i[e.subdiv]||i["4n"],!1),e.sizzle){var s=[],c=!0===e.sizzle?"sin":e.sizzle,u=t.length,p=e.amp,h=e.sizzleReps,d=p/(u/h);if("sin"===c||"cos"===c)for(var l=0;l<u;l++){var f=Math[c](l*Math.PI/(u/h))*p;s.push(Math.round(Math.abs(f)))}if("rampUp"===c)for(f=0,l=0;l<u;l++)l%(u/h)==0?f=0:f+=d,s.push(Math.round(Math.abs(f)));if("rampDown"===c)for(f=p,l=0;l<u;l++)l%(u/h)==0?f=p:f-=d,s.push(Math.round(Math.abs(f)));for(l=0;l<s.length;l++)t[l].level=s[l]?s[l]:1}if(e.accent){if(/[^x-]/.test(e.accent))throw new TypeError("Accent can only have x and - characters");for(var m=0,v=0,y=t;v<y.length;v++){var g=y[v];f="x"===e.accent[m]?e.amp:e.accentLow,e.sizzle&&(f=(g.level+f)/2),g.level=Math.round(f),(m+=1)===e.accent.length&&(m=0)}}return t}},890:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.max=t.arp=t.progression=t.getChordsByProgression=t.getChordDegrees=t.clip=t.chords=t.chord=t.modes=t.scales=t.mode=t.scale=void 0;var i=r(397);Object.defineProperty(t,"scales",{enumerable:!0,get:function(){return i.scales}}),Object.defineProperty(t,"modes",{enumerable:!0,get:function(){return i.scales}}),Object.defineProperty(t,"chords",{enumerable:!0,get:function(){return i.chords}}),Object.defineProperty(t,"scale",{enumerable:!0,get:function(){return i.scale}}),Object.defineProperty(t,"mode",{enumerable:!0,get:function(){return i.scale}}),Object.defineProperty(t,"chord",{enumerable:!0,get:function(){return i.chord}});var a=r(768);Object.defineProperty(t,"clip",{enumerable:!0,get:function(){return a.clip}});var s=r(668);Object.defineProperty(t,"getChordDegrees",{enumerable:!0,get:function(){return s.getChordDegrees}}),Object.defineProperty(t,"getChordsByProgression",{enumerable:!0,get:function(){return s.getChordsByProgression}}),Object.defineProperty(t,"progression",{enumerable:!0,get:function(){return s.progression}});var c=r(148);Object.defineProperty(t,"arp",{enumerable:!0,get:function(){return c.arp}});var u=r(528);Object.defineProperty(t,"max",{enumerable:!0,get:function(){return u.max}}),o(r(621),t)},528:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.max=void 0;var n=r(126);t.max=function(e,t){void 0===t&&(t="live_set view highlighted_clip_slot clip");var r=new LiveAPI(t),o=e.reduce((function(e,t){return e+t.length}),0);r.set("loop_end",o/512),r.call("remove_notes",0,1,258,127),r.call("set_notes");var i=e.reduce((function(e,t){return e+(t.note?t.note.length:0)}),0);r.call("notes",i);var a=0;e.forEach((function(e){e.note?(e.note.forEach((function(t){r.call("note",n.Util.midiPitchFromNote(t),a.toFixed(2).toString(),(e.length/512).toFixed(2).toString(),e.level||100,0)})),a+=e.length/512):a+=e.length/512})),r.call("done")}},668:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.progression=t.getChordsByProgression=t.getChordDegrees=void 0;var n=r(397),o=r(604);t.getChordDegrees=function(e){var t={ionian:["I","ii","iii","IV","V","vi","vii°"],dorian:["i","ii","III","IV","v","vi°","VII"],phrygian:["i","II","III","iv","v°","VI","vii"],lydian:["I","II","iii","iv°","V","vi","vii"],mixolydian:["I","ii","iii°","IV","v","vi","VII"],aeolian:["i","ii°","III","iv","v","VI","VII"],locrian:["i°","II","iii","iv","V","VI","vii"],"melodic minor":["i","ii","III+","IV","V","vi°","vii°"],"harmonic minor":["i","ii°","III+","iv","V","VI","vii°"]};return t.major=t.ionian,t.minor=t.aeolian,t[e]||[]};var i={i:0,ii:1,iii:2,iv:3,v:4,vi:5,vii:6};t.getChordsByProgression=function(e,t){var r=e.split(" ");r[0].match(/\d/)||(r[0]+="4",e=r.join(" "));var o=(0,n.scale)(e);return t.replace(/\s*,+\s*/g," ").split(" ").map((function(e){var t=function(e){var t=e.replace(/\W/g,""),r="M";return t.toLowerCase()===t&&(r="m"),e.indexOf("°")>-1?r+"7b5":e.indexOf("+")>-1?r+"#5":e.indexOf("7")>-1?"M"===r?"maj7":"m7":r}(e),r=i[e.replace(/\W|\d/g,"").toLowerCase()],n=o[r],a=n.replace(/\D+/,"");return n.replace(/\d/,"")+t+"_"+a})).toString().replace(/,/g," ")};var a=function(e){var t=e.T,r=e.P,n=e.D;return function(e){void 0===e&&(e=4);var i=[];i.push((0,o.pickOne)(t));var a=1;for(a<e-1&&(i.push((0,o.pickOne)(r)),a++),a<e-1&&(0,o.dice)()&&(i.push((0,o.pickOne)(r)),a++),a<e-1&&(i.push((0,o.pickOne)(n)),a++),a<e-1&&(i.push((0,o.pickOne)(r)),a++),a<e-1&&(i.push((0,o.pickOne)(n)),a++),a<e-1&&(0,o.dice)()&&(i.push((0,o.pickOne)(r)),a++);a<e;)i.push((0,o.pickOne)(n)),a++;return i}},s=a({T:["I","vi"],P:["ii","IV"],D:["V"]}),c=a({T:["i","VI"],P:["ii","iv"],D:["V"]});t.progression=function(e,t){return void 0===t&&(t=4),"major"===e||"M"===e?s(t):"minor"===e||"m"===e?c(t):[]}},621:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},604:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.randomInt=t.convertChordsToNotes=t.convertChordToNotes=t.errorHasMessage=t.flat=t.dice=t.pickOne=t.sizzleMap=t.shuffle=t.expandStr=t.isNote=void 0;var n=r(397);t.isNote=function(e){return/^[a-gA-G](?:#|b)?\d$/.test(e)},t.expandStr=function(e){return e=(e=(e=(e=JSON.stringify(e.split(""))).replace(/,"\[",/g,", [")).replace(/"\[",/g,"[")).replace(/,"\]"/g,"]"),JSON.parse(e)},t.shuffle=function(e,t){void 0===t&&(t=!0);var r=e.length-1;return e.forEach((function(n,o){if(!(o>=r)){var i=t?Math.floor(Math.random()*(r-o))+1+o:Math.floor(Math.random()*(r+1-o))+o;e[o]=e[i],e[i]=n}})),e},t.sizzleMap=function(e){void 0===e&&(e=127);var t=Math.PI,r=[t/6,t/4,t/3,t/2,2*t/3,3*t/4,5*t/6,t],n=[0,t/6,t/4,t/3,t/2,2*t/3,3*t/4,5*t/6];return n.reverse(),r.concat(n).map((function(t){return Math.round(Math.sin(t)*e)}))},t.pickOne=function(e){return e.length>1?e[Math.round(Math.random())]:e[0]},t.dice=function(){return!!Math.round(Math.random())},t.flat=function(e){return e.reduce((function(e,t){return e.concat(t)}),[])},t.errorHasMessage=function(e){return"string"==typeof e.message},t.convertChordToNotes=function(e){var t,r,o,i;try{t=(0,n.inlineChord)(e)}catch(e){o=e}try{r=(0,n.chord)(e.replace(/_/g," "))}catch(e){i=e}if(!o&&!i){if(t.toString()!==r.toString())throw new Error("Chord "+e+" cannot decode, guessing "+t+" or "+r);return t}return o?i?(0,n.chord)(e):r:t},t.convertChordsToNotes=function(e){if("string"==typeof e&&(0,t.isNote)(e))return[e];if(Array.isArray(e))return e.forEach((function(e){if(Array.isArray(e))e.forEach((function(e){if("string"!=typeof e||!(0,t.isNote)(e))throw new TypeError("array of arrays must comprise valid notes")}));else if("string"!=typeof e||!(0,t.isNote)(e))throw new TypeError("array must comprise valid notes")})),e;if(!Array.isArray(e)){var r=(0,t.convertChordToNotes)(e);if(r&&r.length)return r}throw new Error("Chord "+e+" not found")},t.randomInt=function(e){return void 0===e&&(e=1),Math.round(Math.random()*e)}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={id:n,loaded:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.loaded=!0,i.exports}r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var n=r(890),o=exports;for(var i in n)o[i]=n[i];n.__esModule&&Object.defineProperty(o,"__esModule",{value:!0})})(); //# sourceMappingURL=max.js.map