如何在浏览器中使用Web Audio API和Tone.js保存声音 [英] How to save sound with Web Audio API and Tone.js in a browser

查看:286
本文介绍了如何在浏览器中使用Web Audio API和Tone.js保存声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用上述库 在服务器上保存音乐的最简单方法是什么? 我试图考虑一种在浏览器中记录声音并将其保存到服务器的方法.

Using the above mentioned library whats the easiest way to save tunes on a server ? I trying to think of a way to record the sounds in the browser and be able to save them to the server.

我可以将它们存储在数据库中吗? 最好的方法是什么,有人可以解释一下吗?

And would I be able to store them in a Database ? what is the best way to do so , can anyone explain a bit ?

推荐答案

最简单的方法是使用MediaRecorder API捕获音频图所连接到的MediaStream.这将为您提供记录,通常是在Opus中(除非您需要Vorbis,但我不建议这样做),并且您可以将MediaRecorder中的数据以流的形式发送出去,也可以让它记录整个文件",然后上传.

The easiest method is to use the MediaRecorder API to capture a MediaStream, to which your audio graph is connected to. This will get you a recording, typically in Opus (unless you want Vorbis, but I don't recommend it), and you can either stream the data from the MediaRecorder as its emitted, or let it record a whole "file" which you upload afterwards.

关于存储方式...您可以根据需要存储它.在不知道您的要求的情况下,这确实是一个无法回答的问题.当然,我想您可以将所有二进制数据塞入数据库中,并且在极少数的用例中,这很有用……但是通常您会希望将此blob保留在其他位置,并从数据库中引用它们.

As of how you store it... you can store it however you want. That's really an unanswerable question without knowing what your requirements are. Sure, I suppose you could jam all your binary data in your database, and there are rare use cases where this is useful... but usually you'll want to keep this blobs somewhere else and reference them from your database.

这篇关于如何在浏览器中使用Web Audio API和Tone.js保存声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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