我需要将声音输入发送到服务器。我可以将其作为变量发送吗?我应该在函数start_microphone()
中做什么,以及我应该使用AudioContext()
的哪些方法?
var input = null;
var webaudio_tooling_obj = function() {
var audioContext = new AudioContext();
console.log("audio is starting up ...");
var BUFF_SIZE = 16384;
var audioInput = null,
if (!navigator.getUserMedia)
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia || navigator.msGetUserMedia;
if (navigator.getUserMedia) {
navigator.getUserMedia({
audio: true
}, function(stream) {
start_microphone(stream);
}, function(e) {
alert('Error capturing audio.');
});
} else {
alert('getUserMedia not supported in this browser.');
}
function start_microphone(stream) {
///////////////////
}
}();
function sendInput() {
$(document).ready(function() {
$("button").click(function() {
$.post("/tuner/getfreq/", {
"sound": input
}, function(data, status) {
document.getElementById("post").innerHTML = data;
});
});
});
}