我想实现一个基本的音频播放器来从文件夹加载文件并通过按 ReactJS 中的按钮来播放它。
\n\nimport React, { Component, PropTypes } from \'react\';\nimport ReactDOM from \'react-dom\';\nimport Tone from \'tone\';\nimport MuiThemeProvider from \'material-ui/styles/MuiThemeProvider\';\nimport Slider from \'material-ui/Slider\';\nimport RaisedButton from \'material-ui/RaisedButton\';\n\n\nlet sound = new Tone.Player("kick.wav").toMaster();\nexport default class App extends Component {\n\nrender() {\n\n return(\n <MuiThemeProvider>\n <div>\n <Slider min={0} max={100} step={10} className = "Slider1Test1" style={{height: 400}} axis="y"/>\n <RaisedButton label="A" className = "RaisedB1Test1" style={{width: 10}}/>\n\n <Slider min={0} max={100} step={10} className = "Slider2Test1" style={{height: 400}} axis="y"/>\n <RaisedButton label="B" className = "RaisedB2Test1" style={{width: 10}}/>\n </div>\n </MuiThemeProvider>\n );\n}\n}\nRun Code Online (Sandbox Code Playgroud)\n\n但这给出了一个错误: …
为了不让听众感到窒息,我想播放一个波形,但音量不应该从一开始就以 100% 的比例播放,例如,它应该在 2 秒的持续时间内从 0% 到 100%。
我考虑了 setTimeout 并增加了时间增益,但我不知道是否还有其他更好的方法
var source = aCtx.createBufferSource();
source.buffer = buf;
var gainNode = aCtx.createGain();
gainNode.gain.value = 0
source.connect(gainNode);
gainNode.connect(aCtx.destination);
source.start(0);
setTimeout(function() {
gainNode.gain.value = 0.5
}, 1000)
setTimeout(function() {
gainNode.gain.value = 1
}, 2000)
Run Code Online (Sandbox Code Playgroud) 我MediaStream从 获得包含音频数据WebRTC。我们称这个流为srcStream。
如果我有我的 HTML
<audio id="audio" controls autoplay></audio>
Run Code Online (Sandbox Code Playgroud)
我跑
audioEl = document.querySelector("#audio")
audioEl.srcObject = srcStream
Run Code Online (Sandbox Code Playgroud)
我可以听到音频,并且可以看到音频元素开始计算秒数。
但是,我得到多个音频流,因此我想做一些更通用的操作,并将所有这些流连接到单个流。如果我跑
audioCtx = new AudioContext()
dst = audioCtx.createMediaStreamDestination()
audioEl.srcObject = dst.stream
src = audioCtx.createMediaStreamSource(srcStream);
src.connect(dst)
Run Code Online (Sandbox Code Playgroud)
音频显示正在播放,但我听不到任何音频播放。
我创建目的地的方式有问题吗?
我对网络工作者相对较新(直到现在才需要),我做了很多研究,认为我已经掌握了基础知识......
但 :-)...
我被困住了,希望得到明确的意见。
我正在使用 WebAudioAPI 将音频文件的图形表示形式渲染为 SVG。没有火箭科学,它的效果令我满意。但是,对于较大的音频文件,如果由网络工作人员来完成会很棒,但我遇到的问题是,在网络工作人员内部,我无权访问窗口对象,因此我无法访问我需要的 AudioContext将原始数据解码到 AudioBuffer 中。还有其他方法可以做到这一点或有解决方法吗?
当您创建新设备时,AudioContext它将采样率设置为默认输出设备。这是预期的默认行为。有谁知道是否有什么方法可以在Javascript中获取输入设备的采样率?
我们可以在AudioContext的文档中看到它说的是sampleRate
该值通常在 8,000 Hz 到 96,000 Hz 之间;默认值会根据输出设备而有所不同,但采样率 44,100 Hz 是最常见的。如果选项中未包含sampleRate属性,或者在创建音频上下文时未指定选项,则默认使用新上下文的输出设备的首选采样率。
我如何使用它的示例:
const stream = await navigator.mediaDevices.getUserMedia({audio: true, video: false});
const context = new AudioContext();
context.sampleRate // This is the default output device's sample rate. I need the default input sampleRate
Run Code Online (Sandbox Code Playgroud)
我一直在搜索文档和互联网以寻找实现此目的的方法,但没有找到任何有用的东西。感谢任何帮助。
我正在寻找一种模仿标准DJ混音器的3频段均衡器.
不幸的是我运气不好.我知道它涉及创建BiquadFilter节点并将它们连接到增益节点.不幸的是,我没有达到预期的结果.
我到目前为止唯一的成功只是控制音轨音量的gainNode.
任何帮助将不胜感激.
谢谢,斯坦
我试图通过拼凑示例来在线学习教程.我觉得这应该是播放mp3文件.我正在使用Chrome浏览器,它是最新的.我在控制台上没有任何错误.我不确定我需要更改或添加以使其工作.
<html>
<head>
<script type="text/javascript">
var context;
var sound1Buffer = null;
var url = 'https://dl.dropboxusercontent.com/u/1957768/SrtV2.mp3';
function init(){
try {
window.AudioContext = window.AudioContext || window.webkitAudioContext;
context = new AudioContext();
}
catch(e) {
alert("web Audio api is not supported!");
}
}
window.addEventListener('load', init, false);
function loadDogSound(url){
var request = new XMLHttpRequest();
request.open("GET", url, true);
request.responseType = 'arrayBuffer';
//decode asynchronously
request.onload = function(){
context.decodeAudioData(request.response, function(buffer){
sound1Buffer = buffer;
}, onError);
}
request.send();
}
function playSound(sound1Buffer){
var source = context.createBufferSource();
source.sound1Buffer = sound1Buffer;
source.connect(context.destination); …Run Code Online (Sandbox Code Playgroud) 我想知道我们是否可以在html 5网络音频中将EQ效果应用于音频.我希望使用2种效果EQ男性和EQ女性.我做了一些研究,发现这些只是一些预设的频率.
编辑:
这是我正在寻找的.

我在Chrome for Android上遇到了WebAudio问题.
我在三星Galaxy S3(GT-I9300)上遇到这种情况:
这是我用来尝试隔离问题的代码:
var audioContext;
if(window.AudioContext) {
audioContext = new AudioContext();
}
var startTime = Date.now();
var lastTrigger;
var gain = audioContext.createGain();
gain.gain.value = 1;
gain.connect(audioContext.destination);
var buttonTrigger = document.getElementById('trigger');
buttonTrigger.addEventListener('click', function(event) {
var oscillator = audioContext.createOscillator();
oscillator.type = "square";
oscillator.frequency.value = 100 + (Math.cos(audioContext.currentTime)*100);
oscillator.connect(gain);
oscillator.start(0);
oscillator.stop(audioContext.currentTime+0.1);
lastTrigger = Date.now();
});
var timer = document.getElementById('timer');
setInterval(function() {
if(lastTrigger) { timer.textContent = Date.now() - lastTrigger; }
}, 1000);
Run Code Online (Sandbox Code Playgroud)
在这里它是在jsfiddle
这只是创建一个振荡器节点并在单击按钮时播放.在我的手机上,如果我没有点击按钮大约一分半钟或两分钟,我就不再发出任何声音了.
没有抛出任何错误.
有没有人有这个问题的经验和可能的解决方法?
这个问题最初出现在一个更大的应用程序中,使用Phaser播放来自m4a文件的声音,所以这不仅仅与振荡器有关. …
我有以下非常基本的代码,这是更复杂的问题的一部分。
我的问题是该功能:context.decodeAudioData(arrayBuffer)不能在iPhone(尝试过Safari和Chrome)或Mac(Safari)上运行,但不能在其他地方(Android和Windows 10(所有浏览器)上使用),甚至不能在Mac(Chrome)上运行。
在Mac(Safari)上,出现以下错误:
Unhandled Promise Rejection: TypeError: Not enough arguments
Run Code Online (Sandbox Code Playgroud)
这是代码:
Unhandled Promise Rejection: TypeError: Not enough arguments
Run Code Online (Sandbox Code Playgroud)
window.AudioContext = window.AudioContext || window.webkitAudioContext;
const context = new AudioContext();
window.addEventListener('load', function() {
const button_option_1 = document.querySelector('.button_option_1');
const button_option_1_play = document.querySelector('.button_option_1_play');
button_option_1_play.disabled = true;
button_option_1.addEventListener('click', async function() {
log('', false);
let buffer;
button_option_1_play.disabled = true;
button_option_1_play.onclick = () => playBuffer(buffer);
let time_start = …Run Code Online (Sandbox Code Playgroud)web-audio-api ×10
javascript ×7
html5 ×3
audiocontext ×2
android ×1
audio ×1
html ×1
html5-audio ×1
mediastream ×1
meteor ×1
reactjs ×1
sample-rate ×1
web-worker ×1
webkit ×1
webrtc ×1