网络音频API:调度的声音和出口结构 [英] Web audio API: scheduling sounds and exporting the mix

查看:275
本文介绍了网络音频API:调度的声音和出口结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经检查网络音频API文档和教程,但没有安静想出如何处理这个问题。

I've been checking Web Audio API documentation and the tutorials but haven't quiet figured out how to approach this problem.

比方说,我通过XMLHtt prequest加载几个wav文件,然后创建buffersources。我知道什么时候开始播放precisely我可以安排。但是,如果我不想玩什么他们,而是要存储在缓冲区调度它们。

Let's say I load few wav files via XMLHttpRequest and then create buffersources. I know I can schedule when the playback starts precisely. But what if I don't want to play them, but instead want to store and schedule them in a buffer.

一个真实的例子:我想创建一个简单的音序器,你安排鼓和高于出口整体搭配,WAV(不使用RecorderJS或东西记录吧)。任何想法,图书馆?

A real example: I want to create a simple sequencer where you schedule drums and than export the whole mix to wav (without recording it using RecorderJS or something). Any ideas, libraries?

推荐答案

只是做了一件有点像这样。

Just did something a bit like this.

从本质上讲,你需要创建一个脱机方面:

Essentially, you'll need to create an offline context:

var offline = new webkitOfflineAudioContext(numChannels, lengthInSamples, sampleRate)

您将不得不重新使用这种新形势下所有的BufferSources:

You'll have to recreate all your BufferSources using this new context:

var newBufferSource = offline.createBufferSource();
newBufferSource.buffer = someAudioBuffer;
newBufferSource.connect(offline.destination);

然后安排您的播放:

Then schedule your playback:

newBufferSource.start(offline.currentTime + 10);

然后绑定到完整事件离线渲染:

offline.onComplete = function( ev ){
  doSomething(ev.renderedBuffer);
}

然后开始'渲染':

Then start 'rendering':

offline.startRendering();

一旦你有了 ev.renderedBuffer ,你可以做任何你想用它。在我的应用程序,我有一个WAV EN codeR,我最后写自己 - 但你可以修改Recorder.js轻松地做同样的事情pretty

Once you have ev.renderedBuffer, you can do whatever you want with it. In my app, I have a WAV encoder that I ended up writing myself - but you could modify Recorder.js to do the same thing pretty easily.

刚刚抬头: webkitOfflineAudioContext 是铬只在瞬间。这里是如果你有兴趣的链接:<一个href=\"https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#OfflineAudioContext-section\"相对=nofollow> OfflineAudioContext

Just a heads-up: webkitOfflineAudioContext is Chrome-only at the moment. Here's a link if you're interested: OfflineAudioContext

这篇关于网络音频API:调度的声音和出口结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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