我正试图从我的麦克风中获取数据流(例如音量,音高).现在我一直在使用getUserMedia来访问我的麦克风音频.但我找不到从中提取数据的方法.
我的代码:
$(function () {
var audioContext = new AudioContext();
var audioInput = null,
realAudioInput = null,
inputPoint = null,
analyserNode = null;
if (!navigator.getUserMedia)
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia || navigator.msGetUserMedia;
if (navigator.getUserMedia){
navigator.getUserMedia({audio:true}, success, function(e) {
alert('Error capturing audio.');
});
} else alert('getUserMedia not supported in this browser.');
function success(stream){
inputPoint = audioContext.createGain();
realAudioInput = audioContext.createMediaStreamSource(stream);
audioInput = realAudioInput;
audioInput.connect(inputPoint);
analyserNode = audioContext.createAnalyser();
analyserNode.fftSize = 2048;
inputPoint.connect( analyserNode );
}
function live(){
requestAnimationFrame(live);
var freqByteData = …Run Code Online (Sandbox Code Playgroud) 目前,我正在开发一个需要我连接到外部 API 以获取 JSON 文件的 Web 应用程序。
我正在使用需要 Oauth1.0a 身份验证的名词项目的相关 API 。现在这个项目需要我使用 Angular.JS 来处理 JSON 数据。
但在我可以使用 JSON 之前,我需要获取它,这就是事情分崩离析的地方。当我尝试使用以下代码连接时,我的http://localhost:8080/上不断出现以下错误。
错误 :
> XMLHttpRequest cannot load
> http://api.thenounproject.com/icons/fish&callback=?&oauth_consumer_key=9c70…891xxxx&oauth_version=1.0&oauth_signature=xxxxx6oeQI0p5U%2Br0xxxxxxx%3D.
> No 'Access-Control-Allow-Origin' header is present on the requested
> resource. Origin 'http://localhost:8080' is therefore not allowed
> access. The response had HTTP status code 403.
> Blockquote
Run Code Online (Sandbox Code Playgroud)
编码 :
var oAuth = OAuth({
consumer: {
public: '9c704cb01xxxxxxxxx',
secret: '45b7a8d86xxxxxxxxx'
},
signature_method: 'HMAC-SHA1'
});
var app = angular.module('nounProject', []); …Run Code Online (Sandbox Code Playgroud) angularjs ×1
api ×1
audio ×1
audiocontext ×1
getusermedia ×1
html5 ×1
javascript ×1
json ×1
oauth ×1