我正在使用带有网络音频api的麦克风输入,需要获得音量值.
现在我已经让麦克风工作了:http: //updates.html5rocks.com/2012/09/Live-Web-Audio-Input-Enabled
另外,我知道有一种操纵音频文件的方法:http: //www.html5rocks.com/en/tutorials/webaudio/intro/
// Create a gain node.
var gainNode = context.createGain();
// Connect the source to the gain node.
source.connect(gainNode);
// Connect the gain node to the destination.
gainNode.connect(context.destination);
// Reduce the volume.
gainNode.gain.value = 0.5;
Run Code Online (Sandbox Code Playgroud)
但是如何将这两者结合起来并获得输入音量值?我只需要价值,不需要操纵它.
有人知道吗?
我刚问了一个关于音频的问题,人们认为这是一个关于html5-audio而不是网络音频的问题.
所以我想知道有什么区别?
我有下面的代码,在chrome中运行良好.
但是,它不适用于Firefox和IE.什么都没发生.
$("body").animate({scrollTop:$(this).offset().top},800);
Run Code Online (Sandbox Code Playgroud)
所以我可以问我应该为firefox和IE写什么?
谢谢.
有没有人尝试通过browserify使用代码镜像?
我发现没有任何东西是可见的,即使它已经生成了所有的html标签.
代码 :
var CodeMirror = require('codemirror');
require('codemirror/mode/javascript/javascript.js');
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
extraKeys: {
"Ctrl-Space": "autocomplete"
},
mode: {
name: "javascript",
globalVars: true
}
});
Run Code Online (Sandbox Code Playgroud)
我想知道我应该如何要求js模式?
如上所述,processing.js如何响应浏览器的大小?(响应式设计)我尝试过screen.width和screen.height,但效果不佳.它似乎只检测计算机屏幕大小的大小.
更重要的是,我想在拖动时改变窗口的大小,并改变浏览器的大小
我在 Chrome 中的游戏中使用网络音频 API。为了播放声音,我使用网络音频 API。
我从文章中了解到:http://www.html5rocks.com/en/tutorials/webaudio/intro/
window.onload = init;
var context;
var bufferLoader;
function init() {
context = new webkitAudioContext();
bufferLoader = new BufferLoader(
context,
[
'0.mp3',
'2.mp3',
],
finishedLoading
);
bufferLoader.load();
}
function finishedLoading(bufferList) {
var source1 = context.createBufferSource();
var source2 = context.createBufferSource();
source1.buffer = bufferList[0];
source2.buffer = bufferList[1];
source1.connect(context.destination);
source2.connect(context.destination);
source1.noteOn(0);
source2.noteOn(0);
}
Run Code Online (Sandbox Code Playgroud)
但是,声音没有播放。更不用说我想稍后使用noteOff(0)来阻止它们。
然后我发现这篇文章http://updates.html5rocks.com/2012/02/HTML5-audio-and-the-Web-Audio-API-are-BFFs
我将代码更改为:
var context = new webkitAudioContext();
var analyser = context.createAnalyser();
var source;
var audio0 = new Audio();
audio0.src = …
Run Code Online (Sandbox Code Playgroud) 在javascript中,如果我想循环遍历数组中的每个元素,我有几种方法可以做到这一点:
1.
for(var i =0; i<array.length; i++){}
Run Code Online (Sandbox Code Playgroud)
2.
array.forEach(function(item, index){});
Run Code Online (Sandbox Code Playgroud)
3.
for (var index in array){}
Run Code Online (Sandbox Code Playgroud)
第一个是常见的,但如果我感到懒惰,我想使用第二个或第三个.
但我想知道它们之间是否有任何区别,我应该选择哪种情况?
我有一个问题,我想知道是否有人知道原因:
if(n.getInfo() instanceof Token){
//Token abc = n.getInfo();
System.out.print("ouch!");
}
Run Code Online (Sandbox Code Playgroud)
当它运行时,它打印出来ouch!
.
但是,当我取消注释该行时
Token abc = n.getInfo();
Run Code Online (Sandbox Code Playgroud)
它给出了编译错误:
error: incompatible types: Object cannot be converted to Token
Token abc = n.getInfo();
Run Code Online (Sandbox Code Playgroud)
我不明白,因为它是一个实例Token
,所以它怎么不能转换成Token
?
谢谢.
我体内有三个div:
<body>
<div id="wrap">
<div id="a"></div>
<div id="b"></div>
<div id="c"></div>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
我想要意识到的是,"#b"比其他两个滚动得更快.而已.
所以我写代码(然后根据Mark的建议修改它):
<script>
$(document).ready(function(){
$(window).stellar();
});
</script>
<style>
#wrap{overflow:hidden;}
</style>
...
<body>
<div id="wrap">
<div id="a" data-stellar-ratio="1"></div>
<div id="b" data-stellar-ratio="2"></div>
<div id="c" data-stellar-ratio="1"></div>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
但结果很可怕.我永远无法滚动到整个页面的底部.
每次#b到达窗口顶部时,整个页面都会运行到顶部(就像我第一次运行此页面时所看到的那样)
我想我仍然不明白stellar.js网站上的介绍意味着什么.
请帮帮我.
javascript ×5
html5-audio ×3
jquery ×2
scroll ×2
audio ×1
browser ×1
browserify ×1
codemirror ×1
css ×1
firefox ×1
for-loop ×1
html ×1
html5 ×1
instance ×1
iteration ×1
iterator ×1
java ×1
loops ×1
npm ×1
object ×1
object-type ×1
parallax ×1