admin管理员组文章数量:1299986
I can't find anything through net searches, but is there any plans to make an API to generate audio chunks to be played in an HTML5 <audio>
tag?
EDIT: this is the example::
PSEUDOCODE::
var music = new Song([Array of hertz levels or notes]);
var box = document.createElement('audio');
document.body.appendChild(box);
box.src = music.convert();
box.play();
I can't find anything through net searches, but is there any plans to make an API to generate audio chunks to be played in an HTML5 <audio>
tag?
EDIT: this is the example::
PSEUDOCODE::
var music = new Song([Array of hertz levels or notes]);
var box = document.createElement('audio');
document.body.appendChild(box);
box.src = music.convert();
box.play();
Share
Improve this question
edited Aug 13, 2010 at 19:04
Rixius
asked Aug 13, 2010 at 18:42
RixiusRixius
2,3033 gold badges24 silver badges33 bronze badges
2 Answers
Reset to default 6In theory, you can actually do this now -- set the source attribute of an audio element to a data URI which you build on the fly in your JavaScript. I've done this with embed
elements and MIDI files, which works on machines with QuickTime or some other media helper installed.
The catch, of course, is that generating audio data is a bit more putationally intensive and it takes up more space (which might run afoul of the data URL size limit in certain contexts... IE and Mobile Safari e to mind). So you'd be limited to small clips, and you might be limited by start/stop times for the audio
tag.
Mozilla has an audio buffer API they're working on, which could bring true programatically generated audio to the browser. In the meanwhile, though, it's either Data URI hacks, or plugin-type stuff like Flash (which got a programatic Audio Buffer in version 10) or Java.
One more note: I started a JavaScript Audio google group a few months back. There isn't a lot of discussion going on there yet, but I'd love it if enough people who were interested in music/audio/sound in the context of the browser signed up so that we can reach a critical mass and start having actual conversations on topics just like this.
Mozilla have released an audio data API, which works in Firefox 4 betas and Minefield nightlies:
https://wiki.mozilla/Audio_Data_API
http://vocamus/dave/?p=1148
As I understand it, there is also a similar WebKit project.
A W3C Audio Incubator Group has been formed -- their mission is 'to explore the possibility of starting one or more specifications dealing with various aspects of advanced audio functionality, including reading and writing raw audio data, and synthesizing sound or speech'.
http://www.w3/2005/Incubator/audio/
本文标签: htmlCreating Audio using Javascript in ltaudiogtStack Overflow
版权声明:本文标题:html - Creating Audio using Javascript in <audio> - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741639888a2389855.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论