jmickle66666666/wad-js

http:// URL is preventing scripts from loading

Opened this issue · 10 comments

Simply change http:// to https:// or use protocol-less URLs (depending on your opinion on which is better.)

<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.min.js"></script> 
<script type='text/javascript' src='https://www.midijs.net/lib/midi.js'></script>

midijs.net doesn't have HTTPS actually, so you're probably better putting it in the project and loading it locally.

Thanks for the report! I looked into hosting the library in the project but there doesn't seem to be an easy way to move it over, so I'll have to replace the library entirely with something else.

There is no good fix for HTTPS because it's the onus on the web master. Anyways, I did some reverse engineering and these are the files that you need to also download (assume www.midijs.net/lib/ as a prefix):

  • libtimidity.js
  • pat/arachno-109.pat
  • pat/arachno-98.pat
  • pat/arachno-93.pat
  • pat/arachno-90.pat
  • pat/arachno-9.pat
  • pat/MT32Drums/mt32drum-0.pat
  • pat/MT32Drums/mt32drum-1.pat
  • pat/MT32Drums/mt32drum-5.pat
  • pat/MT32Drums/mt32drum-6.pat
  • pat/MT32Drums/mt32drum-7.pat
  • pat/MT32Drums/mt32drum-8.pat
  • pat/MT32Drums/mt32drum-9.pat
  • pat/MT32Drums/mt32drum-10.pat
  • pat/MT32Drums/mt32drum-11.pat
  • pat/MT32Drums/mt32drum-12.pat
  • pat/MT32Drums/mt32drum-13.pat
  • pat/MT32Drums/mt32drum-14.pat
  • pat/MT32Drums/mt32drum-15.pat
  • pat/MT32Drums/mt32drum-16.pat
  • pat/MT32Drums/mt32drum-18.pat
  • pat/MT32Drums/mt32drum-22.pat
  • pat/MT32Drums/mt32drum-24.pat

Of course you run into potential legal issues with distributing files that aren't yours (and don't have an explicit LICENSE). So I wouldn't blame you for wanting to switch to a different library.

Ref commits: 3b8a9bc, 79831a3

Ah thank you for this! I assumed it was many more files. I will get this put on my repo and try it out.

Looking at it I think those aren't the only files. I'm now batch downloading all the # files to expected limits. Let's see how that goes

You might actually be correct. I used a python script to get the string from the char code list:

''.join(chr(i) for i in L)
'dir ./pat\n\ndrumset 0\n\n 35\t MT32Drums/mt32drum-0.pat\n 36\t MT32Drums/mt32drum-1.pat\n 37\t MT32Drums/mt32drum-2.pat\n 38\t MT32Drums/mt32drum-3.pat\n 39\t MT32Drums/mt32drum-4.pat\n 40\t MT32Drums/mt32drum-5.pat\n 41\t MT32Drums/mt32drum-6.pat\n 42\t MT32Drums/mt32drum-7.pat\n 43\t MT32Drums/mt32drum-8.pat\n 44\t MT32Drums/mt32drum-9.pat\n 45\t MT32Drums/mt32drum-10.pat\n 46\t MT32Drums/mt32drum-11.pat\n 47\t MT32Drums/mt32drum-12.pat\n 48\t MT32Drums/mt32drum-13.pat\n 49\t MT32Drums/mt32drum-14.pat\n 50\t MT32Drums/mt32drum-15.pat\n 51\t MT32Drums/mt32drum-16.pat\n 52\t MT32Drums/mt32drum-17.pat\n 53\t MT32Drums/mt32drum-18.pat\n 54\t MT32Drums/mt32drum-19.pat\n 55\t MT32Drums/mt32drum-20.pat\n 56\t MT32Drums/mt32drum-21.pat\n 57\t MT32Drums/mt32drum-22.pat\n 58\t MT32Drums/mt32drum-23.pat\n 59\t MT32Drums/mt32drum-24.pat\n 60\t MT32Drums/mt32drum-25.pat\n 61\t MT32Drums/mt32drum-26.pat\n 62\t MT32Drums/mt32drum-27.pat\n 63\t MT32Drums/mt32drum-28.pat\n 64\t MT32Drums/mt32drum-29.pat\n 65\t MT32Drums/mt32drum-30.pat\n 66\t MT32Drums/mt32drum-31.pat\n 67\t MT32Drums/mt32drum-32.pat\n 68\t MT32Drums/mt32drum-33.pat\n 69\t MT32Drums/mt32drum-34.pat\n 70\t MT32Drums/mt32drum-35.pat\n 71\t MT32Drums/mt32drum-36.pat\n 72\t MT32Drums/mt32drum-37.pat\n 73\t MT32Drums/mt32drum-38.pat\n 74\t MT32Drums/mt32drum-39.pat\n 75\t MT32Drums/mt32drum-40.pat\n 76\t MT32Drums/mt32drum-41.pat\n 77\t MT32Drums/mt32drum-42.pat\n 78\t MT32Drums/mt32drum-43.pat\n 79\t MT32Drums/mt32drum-44.pat\n 80\t MT32Drums/mt32drum-45.pat\n 81\t MT32Drums/mt32drum-46.pat\n\nbank 0\n\n 0\t arachno-127.pat\n 1\t arachno-126.pat\n 2\t arachno-125.pat\n 3\t arachno-124.pat\n 4\t arachno-123.pat\n 5\t arachno-122.pat\n 6\t arachno-121.pat\n 7\t arachno-120.pat\n 8\t arachno-119.pat\n 9\t arachno-118.pat\n 10\t arachno-117.pat\n 11\t arachno-116.pat\n 12\t arachno-115.pat\n 13\t arachno-114.pat\n 14\t arachno-113.pat\n 15\t arachno-112.pat\n 16\t arachno-111.pat\n 17\t arachno-110.pat\n 18\t arachno-109.pat\n 19\t arachno-108.pat\n 20\t arachno-107.pat\n 21\t arachno-106.pat\n 22\t arachno-105.pat\n 23\t arachno-104.pat\n 24\t arachno-103.pat\n 25\t arachno-102.pat\n 26\t arachno-101.pat\n 27\t arachno-100.pat\n 28\t arachno-99.pat\n 29\t arachno-98.pat\n 30\t arachno-97.pat\n 31\t arachno-96.pat\n 32\t arachno-95.pat\n 33\t arachno-94.pat\n 34\t arachno-93.pat\n 35\t arachno-92.pat\n 36\t arachno-91.pat\n 37\t arachno-90.pat\n 38\t arachno-89.pat\n 39\t arachno-88.pat\n 40\t arachno-87.pat\n 41\t arachno-86.pat\n 42\t arachno-85.pat\n 43\t arachno-84.pat\n 44\t arachno-83.pat\n 45\t arachno-82.pat\n 46\t arachno-81.pat\n 47\t arachno-80.pat\n 48\t arachno-79.pat\n 49\t arachno-78.pat\n 50\t arachno-77.pat\n 51\t arachno-76.pat\n 52\t arachno-75.pat\n 53\t arachno-74.pat\n 54\t arachno-73.pat\n 55\t arachno-72.pat\n 56\t arachno-71.pat\n 57\t arachno-70.pat\n 58\t arachno-69.pat\n 59\t arachno-68.pat\n 60\t arachno-67.pat\n 61\t arachno-66.pat\n 62\t arachno-65.pat\n 63\t arachno-64.pat\n 64\t arachno-63.pat\n 65\t arachno-62.pat\n 66\t arachno-61.pat\n 67\t arachno-60.pat\n 68\t arachno-59.pat\n 69\t arachno-58.pat\n 70\t arachno-57.pat\n 71\t arachno-56.pat\n 72\t arachno-55.pat\n 73\t arachno-54.pat\n 74\t arachno-53.pat\n 75\t arachno-52.pat\n 76\t arachno-51.pat\n 77\t arachno-50.pat\n 78\t arachno-49.pat\n 79\t arachno-48.pat\n 80\t arachno-47.pat\n 81\t arachno-46.pat\n 82\t arachno-45.pat\n 83\t arachno-44.pat\n 84\t arachno-43.pat\n 85\t arachno-42.pat\n 86\t arachno-41.pat\n 87\t arachno-40.pat\n 88\t arachno-39.pat\n 89\t arachno-38.pat\n 90\t arachno-37.pat\n 91\t arachno-36.pat\n 92\t arachno-35.pat\n 93\t arachno-34.pat\n 94\t arachno-33.pat\n 95\t arachno-32.pat\n 96\t arachno-31.pat\n 97\t arachno-30.pat\n 98\t arachno-29.pat\n 99\t arachno-28.pat\n 100\t arachno-27.pat\n 101\t arachno-26.pat\n 102\t arachno-25.pat\n 103\t arachno-24.pat\n 104\t arachno-23.pat\n 105\t arachno-22.pat\n 106\t arachno-21.pat\n 107\t arachno-20.pat\n 108\t arachno-19.pat\n 109\t arachno-18.pat\n 110\t arachno-17.pat\n 111\t arachno-16.pat\n 112\t arachno-15.pat\n 113\t arachno-14.pat\n 114\t arachno-13.pat\n 115\t arachno-12.pat\n 116\t arachno-11.pat\n 117\t arachno-10.pat\n 118\t arachno-9.pat\n 119\t arachno-8.pat\n 120\t arachno-7.pat\n 121\t arachno-6.pat\n 122\t arachno-5.pat\n 123\t arachno-4.pat\n 124\t arachno-3.pat\n 125\t arachno-2.pat\n 126\t arachno-1.pat\n 127\t arachno-0.pat\n'

Anyways, batch downloading is borderline abuse. You can just download the pat files from https://github.com/babelsberg/babelsberg-js/tree/master/midijs/pat. But download only the pat files because it seems they modified their copy of midi.js to work for their project only.

Ah great find there, thanks for that. This should work great.

I managed to get FreePats working instead of the patches that come with midi.js. It doesn't sound as good but it's a proof of concept.

  1. Download Freepats
  2. Extract it to a directory named pat (that is, the root directory is called pat, not freepats)
  3. Copy/paste crude.fg into freepats.cfg, then use this tool to get it into a char code list
  4. Open up libtimidity.js. Find the Module['FS_createPath'] lines.
  5. Replace:
Module['FS_createPath']('/pat', 'MT32Drums', true, true)

with:

Module['FS_createPath']('/pat', 'Drum_000', true, true);
Module['FS_createPath']('/pat', 'Tone_000', true, true);
  1. On the next line where it says timidity.cfg, replace the list of numbers with the converted freepats.cfg
  2. Delete the lines after where it mentions dummy.txt (probably not necessary)
  3. Create this file and test it out:
<!DOCTYPE html>
<head>
        <meta charset="utf-8">
</head>
<body>
<script src="midi.js" type="text/javascript"></script>
<script type="text/javascript">
MIDIjs.play("d_runnin.mid");
</script>
</body>
</html>

Now we just have to find a way to make it work with soundfonts or find a set of patches that actually sound good. Personally I like Scc1t2 (Roland) the best, but it's a sf2 format.

While this is working locally, midi playback is failing on https://jmickle66666666.github.io/wad-js/. The console says MIDI.js:10 GET https://jmickle66666666.github.io/wad-js/nulllibtimidity.js

I remember when looking at MIDI.js before, it uses some weird way of getting URLs, I think this is what it creating this malformed URL.

Filename issues. git didn't seem to want to commit filename changes when its MIDI.js -> midi.js and vice versa. Fixed.