在javascript中生成MIDI [英] generating MIDI in javascript

查看:237
本文介绍了在javascript中生成MIDI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在javascript中生成一系列MIDI音符,然后播放它。许多插件支持MIDI,但我不知道任何支持data:URL。生成MIDI内容并不是什么大问题 - 但是将这些内容提供给播放器就是。任何人都知道如何做到这一点 - 如果不是一般,那么至少对于像QuickTime这样的特定插件?

I'd like to generate a sequence of MIDI notes in javascript and then play it. Many plugins support MIDI, but I'm not aware of any supporting "data:" URL. Generating MIDI content is not a big deal - but feeding this content into player is. Anyone knows how this can be done - if not in general, then at least for specific plugin like QuickTime?

推荐答案

非常整洁的问题。我最近一直在使用base64编码的图像,并经常使用 http:// www.greywyvern.com/code/php/binary2base64 用于图像编码。我只是尝试转换MIDI文件并将base64文本流放入HTML中,它在Firefox中播放得很好(这令我很惊讶)。这是代码(为简洁起见删除了Base64流):

Very neat problem. I've been working a lot lately with base64-encoded images and have regularly been using http://www.greywyvern.com/code/php/binary2base64 for image encoding. I just tried converting a MIDI file and putting the base64 text stream into an HTML and it played just fine in Firefox (which astonished me). Here's the code (with the Base64 stream removed for brevity):

<embed 
    autostart="true" 
    loop="false" 
    volume="100" 
    hidden="false" 
    src="data:audio/x-midi;base64,abc...."
></embed>

我不确定在JS中可以从二进制映像转到base64,但我怀疑从MIDI发出的可能是。这是一个开始。

I'm not sure it's possible to go from a binary image to base64 in JS, but I suspect that going from MIDI might be. It's a start.

这篇关于在javascript中生成MIDI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆