Topic: Javascript chould dynamicly generate MIDI (Quicktime needed, not for IE again) Pages that link to <a href="https://ozoneasylum.com/backlink?for=30609" title="Pages that link to Topic: Javascript chould dynamicly generate MIDI (Quicktime needed, not for IE again)" rel="nofollow" >Topic: Javascript chould dynamicly generate MIDI (Quicktime needed, not for IE again)\

 
Author Thread
electronixtar
Obsessive-Compulsive (I) Inmate

From:
Insane since: Mar 2008

IP logged posted posted 10-22-2008 20:46 Edit Quote
code:
<html>
<head>
<title>MIDI from Javascript using QuickTime</title>
<!-- http://d.hatena.ne.jp/brazil/20071003/1191381382 -->
</head>
<body>

<script type="text/javascript">

var MIDI_DATA = 'data:audio/midi,' + 
  'MThd%00%00%00%06%00%01%00%01%00%C0' + // &#12501;&#12449;&#12452;&#12523;&#12504;&#12483;&#12480;
  'MTrk%00%00%00%0E' + // data length
    '%00%C0%05' +
    '%00%90%30%64' +
    '%70%30%00' + 
  '%00%FF%2F%00'; 

var midi = document.body.appendChild(setAttributes(document.createElement('embed'), {
  src : MIDI_DATA,
  type : 'video/quicktime',
  controller : 'false',
  autoplay : 'true', 
  loop : 'false',
  width : '1px',
  height : '1px'
}));

function setAttributes(elm, attrs){
  for(var attr in attrs)
    elm.setAttribute(attr, attrs[attr]);
  return elm;
}

</script>
</body></html>



Credits: http://d.hatena.ne.jp/brazil/20071003/1191381382

video demo: http://vimeo.com/886342

Now we can chrunch midi using javascript, and playback using Quicktime. Great!

I think this works on browsers both in Win/Linux/Mac, but again sadly IE does not support data: protocol.

Tip: If you are using Quicktime Alternative, be sure to tick "Install plugin for Firefox/Mozilla/Netscape/Opera/Chrome" option when install QTAlt.

(Edited by electronixtar on 10-22-2008 20:48)

poi
Paranoid (IV) Inmate

From: Norway
Insane since: Jun 2002

IP logged posted posted 10-22-2008 21:01 Edit Quote

Javascript can generate absolutely ANYTHING.

I started to do a Soft Synth in summer 2006, went as far as having sounds made of various generators ( saw tooth, square, noise ) with different tuning, with an ADSR enveloppe, and did some delay ( aka echo ), and simple LFO effects. It worked well but I never got the guts to make a proper editor.

When Jacob Sedeilin did his Super Mario in 14Kb, in April this year I think, I looked at Midi and got something to decode and encode MIDI tunes. IIRC, once compressed, the 1"24 and >10Kb Super Mario Bros. theme song took around 2Kb to generate and play.

I should really get my hands dirty and make a music editor.

Scott
Paranoid (IV) Inmate

From: schillmania.com
Insane since: Jul 2002

IP logged posted posted 10-23-2008 00:48 Edit Quote

^ Yes, you should!

lucy1988
Nervous Wreck (II) Inmate

From:
Insane since: Sep 2008

IP logged posted posted 10-23-2008 10:17 Edit Quote

Spammer. Please cease existing.

(Edited by Tyberius Prime on 10-23-2008 10:27)

Scott
Paranoid (IV) Inmate

From: schillmania.com
Insane since: Jul 2002

IP logged posted posted 11-16-2008 18:35 Edit Quote

"The man in blue" has a nifty JS+QuickTime drum machine, JS-909 demo based on feeding data: URIs to QT - it actually seems to work pretty well.

coach
Nervous Wreck (II) Inmate

From:
Insane since: May 2011

IP logged posted posted 05-31-2011 11:10 Edit Quote
Edit TP: spam removed


Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu