FAQ Database Discussion Community


Web Audio API for live streaming?

javascript,html5,html5-audio,audio-streaming,web-audio
We need to streaming live audio (from a medical device) to web browsers with no more than 3-5s of end-to-end delay (assume 200mS or less network latency). Today we use a browser plugin (NPAPI) for decoding, filtering (high, low, band), and playback of the audio stream (delivered via Web Sockets)....

Clicking sounds in Stream played with Web Audio Api

javascript,web-audio
I have a strange Problem. I'm using Web Audio to play a stream from the server. I do that the following way: var d2 = new DataView(evt.data); var data = new Float32Array(d2.byteLength / Float32Array.BYTES_PER_ELEMENT); for (var jj = 0; jj < data.length; ++jj) { data[jj] = d2.getFloat32(jj * Float32Array.BYTES_PER_ELEMENT, true);...

Why when adding the audio analyser the sounds stops playing ? Webaudio Api

javascript,web-audio
Im following this tut about using the data of a sound to move stuff. Until now it works correctly, it plays a sound,this is the code: /* Hoist some variables. */ var audio, context = new (window.AudioContext || window.webAudioContext || window.webkitAudioContext)(), /* Create a script processor node with a `bufferSize`...

Playing Soundcloud track with WebAudio

soundcloud,web-audio
I am exploring WebAudio and SoundCloud for a visualization program but can't seem to get past the basic testing stage. Here's the code I used for testing but I can't hear anything. Am I missing something? <script src="http://connect.soundcloud.com/sdk.js"></script> <script> var context = new AudioContext(), audio = new Audio(), source, url...

Get Final Output Frequency of Chained Oscillators

javascript,web-audio
I've set up a web page with a theremin and I'm trying to change the color of a web page element based on the frequency of the note being played. The way I'm generating sound right now looks like this: osc1 = page.audioCX.createOscillator(); pos = getMousePos(page.canvas, ev); osc1.frequency.value = pos.x;...

Firefox Web Audio API on-the-fly update AudioBuffer / AudioBufferSourceNode

javascript,firefox,web-audio
I'm creating a 1s audio snippet by programmatically filling a AudioBuffer. The AudioBufferSourceNode has looping enabled. It plays back just fine in Chrome and Firefox. Now I want to dynamically update the AudioBuffer and have the new audio picked up immediately (or at the next loop). In Chrome this works...

Can I stream microphone audio from client to client using nodejs?

javascript,node.js,socket.io,web-audio,socket.io-1.0
I'm trying to create a realtime voice chat. once a client is holding a button and talks, I want the sound to be sent over the socket to the nodejs backend, then I want to stream this data to another client. here is the sender client code: socket.on('connect', function() {...

How do I implement audio controls on this audio visualizer that uses HTML5 Web Audio API?

javascript,php,html5,audio,web-audio
I know how put audio controls when you're importing the source of the audio like so: <audio src="audio.mp3" id="audio" controls="true"></audio> What's different about the audio visualizer that im trying to fiddle with is that it uses the audio, that the user has to upload (test the demo below). What I...

How to export timbre.js buffer to .wav or any other audio file format?

javascript,web-audio,waveform
So far I figured out how to use T("rec") Recorder. But how to export timbre.js buffer to wav or any other audio file format? var rec = T("rec", {timeout:1000}, t).on("ended", function(buffer) { // export buffer? }); ...

createMediaElementSource plays but getByteFrequencyData returns all 0's

webrtc,web-audio
I am attempting to visualize audio coming out of an element on a webpage. The source for that element is a WebRTC stream connecting to an Asterisk call via sip.js. The audio works as intended. However, when I attempt to get the frequency data using web audio api, it returns...

Should AudioBufferSourceNode.stop() need a 'this' binding?

javascript,web-audio
The following code creates a tone that stops after 500 milliseconds. It's pretty straightforward: // Create audio context and nodes var audioContext = new AudioContext(); var oscillator = audioContext.createOscillator(); oscillator.type = 'sine'; oscillator.frequency.value = 250; // Attach nodes and start tone oscillator.connect(audioContext.destination); oscillator.start(); // Stop the tone after half a...

What's the smallest float allowable for exponentialRampToValueAtTime?

javascript,web-audio
exponentialRampToValueAtTime(value, time) triggers an error if value is 0, which makes sense since log of 0 is undefined, but apparently also triggers an error if value is too close to 0 like 1e-150. What's the smallest number value possible for the value parameter?...

Ring Buffer - Web Audio API

javascript,web,web-audio,getusermedia
I want to make an application that stores (since opened) the last 2 or 3 seconds from the current moment (until is closed). Is it possible with any of this methods? https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createBuffer https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createBufferSource ...

How do I determine which AudioContext constructor to use in Safari?

javascript,safari,web-audio
I'm using the HTML5 web audio API, and I'm trying to dynamically determine which AudioContext constructor to use via var constructor = AudioContext || webkitAudioContext; var context = new constructor(); However, with this code, Safari quips: ReferenceError: Can't find variable: AudioContext For starters, I didn't even know that ReferenceErrors exist...

Web Audio - AudioParam scheduling functions not working

javascript,scheduling,web-audio
I think i am completely missing something. None of the setValueAtTime(), linearRampToValueAtTime(), exponentialRampToValueAtTime(), setTargetAtTime() methods of the AudioParam interface are working for me. The simplest possible example below: var context = new window.AudioContext(); gain = context.createGain(); gain.connect(context.destination); // none of this is working, gain stays at 1 gain.gain.setValueAtTime(0.5, 0); gain.gain.setValueAtTime(0.2,...

SoundCloud Api redirect confusion and Audio Api Streams

javascript,ajax,cors,soundcloud,web-audio
I am attempting to make a request to the SoundCloud API. Then when I get the response I set the stream_url as the source of an < audio > element. This works: http://matthiasdv.org/beta/ But not always... When you search for 'Bonobo' for example, you can play the first few tracks...

How can I use JS WebAudioAPI for beat detection?

javascript,audio,web-audio,beat-detection
I'm interested in using the JavaScript WebAudioAPI to detect song beats, and then render them in a canvas. I can handle the canvas part, but I'm not a big audio guy and really don't understand how to make a beat detector in JavaScript. I've tried following this article but cannot,...

Playing sequence of small sound buffers continuosly with Web Audio Api

web-audio
I like to generate sound from an arbitrary mathematical function f(x). Now I use AudioBufferSource for this, and its onended handler I create and play another source for the next buffer and so on. The problem is the crackles between the buffers. Here is my example code: function init() {...

Is there a simple and direct way of using audio as an output for a program?

c++,html5,audio,web-audio
I want to try some C and C++ programming with audio processing, such as synthesizers, chorus, delay etc, but I only know working with a console as output. I wish to have, instead of a console application, a window that would be capable of sending an audio signal to the...

Web Audio synthesis: how to handle changing the filter cutoff during the attack or release phase?

javascript,audio,web-audio,synthesizer
I'm building an emulation of the Roland Juno-106 synthesizer using WebAudio. The live WIP version is here. I'm hung up on how to deal with updating the filter if the cutoff frequency or envelope modulation amount are changed during the attack or release while the filter is simultaneously being modulated...

What's the harm in having a long maxDelayTime?

javascript,delay,web-audio
I'm building a live-looping application that uses several delay nodes. I initialize the delay nodes by setting the maxDelayTime to be slightly longer than the delayTime, because this seems like the right thing to do. I don't know if it actually makes a difference, but it seems wasteful to set...

How to get right amplitudes (without playing) of the audiotrack samples with web audio api

javascript,audio,web-audio
I did some experiments with the samples volume data, provided to me by web audio api and it appeares that they are different from the data got from other programs like audasity for example. It shows the duration of audio longer at about 40 seconds if we take divide samples...

Web Audio API createMediaElementSource breaks the audio tag

javascript,html5,audio,offline,web-audio
<!DOCTYPE html> <html> <head> <title>createMediaElementSource test</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script> var audioContext, mediaElementSource, analyzer, analyzerBytes; function initAudio(audio) { if (!audioContext) { audioContext = new(window.AudioContext || window.webkitAudioContext)(); analyzer = audioContext.createAnalyser(); analyzer.connect(audioContext.destination); mediaElementSource =...

Math related Javascript for Web Audio API

javascript,web-audio
I am having trouble figuring this math related problem out. I am using the jogDial.js plugin for a project. With it, I'm trying to simulate a volume dial that controls the gainNode of the web audio api. The plugin can return the degree of the dial with this: console.log("event.target.degree: "+event.target.degree);...

Web Audio- streaming file from server to client

javascript,audio,types,web-audio
I'm trying to stream audio from a server containing an audio file to a client using BinaryJS. My code was inspired by the code in this question: Playing PCM stream from Web Audio API on Node.js Here's what my server code looks like: // create a BinaryServer using BinaryJS var...

Web Audio API - Scheduling Issue

javascript,html5,web-audio,synchronous,sequencing
I am trying to build a loop sequencer that utilises the web audio API and many different musical loops of different lengths. The general idea is that the loops are chosen at random (to a degree), then played back in in a specific order for a beginning, middle and end...

What is the range of the values returned by analyser.getByteFrequencyData in the web audio API?

javascript,fft,web-audio
I would like to work with percentages while doing some FFT with the web audio API. To do so I need to know the range of the values the analyser.getByteFrequencyData returns. I can't find anything about that, maybe someone knows? Thanks...

Transfer function of WaveShaperNode

javascript,audio,signal-processing,web-audio,transfer-function
I'm having trouble understanding how the transfer function for a WaveShaperNode in the Web Audio API works. As I understand, a transfer function is a waveshaper which takes in a signal input x and produces a new signal y. So, y = f(x) I understand that if x equals zero,...

Memory leak with web audio api oscillator

javascript,memory-leaks,web-audio
http://codepen.io/superuntitled/pen/EjZOjw/?editors=001 I have a little web instrument (see link above) that has a memory leak, and I am unsure how to plug it. The following function is called when an element is hovered over (there are a couple hundred of these). function tone(id, freq, tonelength) { gainNodes.id = audioCtx.createGain(); osc.id...

How do you change source in a web audio context

html5,api,google-chrome,audio,web-audio
I'm making a game that changes some of it's object depending on what music is playing. After each song has ended I want my audio context to load in a new source and analyze that. However whenever I tried to do that I've gotten the error that an audio object...

Web Audio Api, setting the gain

javascript,web-audio
I have been looking at the Web Audio API and am not able to get the audio gain to work. I have a fiddle set up here, so you can understand the application of the function: http://jsfiddle.net/mnu70gy3/ I am hoping to dynamically create a tone on a click event, but...

Record audio on web, preset: 16000Hz 16bit

javascript,audio,record,web-audio
function floatTo16BitPCM(output, offset, input){ for (var i = 0; i < input.length; i++, offset+=2){ var s = Math.max(-1, Math.min(1, input[i])); output.setInt16(offset, s < 0 ? s * 0x8000 : s * 0x7FFF, true); } } function writeString(view, offset, string){ for (var i = 0; i < string.length; i++){ view.setUint8(offset +...

Issue with HTML5 Audio Frequency Animation?

javascript,html5-audio,web-audio
This is an issue with seemingly just the AnalyserNode in JS (or it's between the keyboard and the chair...). Basically, I have a properly setup audio file (streams under normal circumstances). However, once I try to hook up the analyzer node between it and the destination, everything goes haywire. The...

Cannot analyse Soundcloud's streaming audio because of the lack of CORS policy

visualization,soundcloud,web-audio
I am working on this visualizer http://trif.it that still works well on Chrome Stable (41.x) but stopped working in Chrome Dev, Beta and Canary (42.x onwards) because of a change in how Chrome (and Firefox before that) handles audio sources to be analysed. Here is the code that is problematic....

Web Audio API- onended event scope

javascript,event-handling,web-audio
I'm having a tricky issue with the Web Audio API AudioSourceBufferNode and its onended event. Basically what I'd like to do is have two AudioSourceBufferNodes that are each triggered when the other one finishes and keep playing back-and-forth. I understand that AudioSourceBufferNodes are pretty much done once you call start()...

web audio api plays beep, beep,… beep at different rate

html5-audio,web-audio
I am trying to play "beep" sound at different rate based on some sensor readings inside a browser window. The idea is to "beep, beep, beep, ... beep" faster when the sensor reading is high, and "beep,...beep" slower when the sensor reading is low, all in real-time. The sensor reading...

Access all input channels of an audio interface using the WebAudio API?

javascript,audio,web-audio
I'm trying to access all the audio channels of an attached multi-input audio interface. I understand that the channels should be exposed by the MediaStreamAudioSourceNode node after it has been created with a MediaStream: navigator.getUserMedia({ audio: true }, function(stream) { var input = audio.createMediaStreamSource(stream); console.log(input.channelCount); }); The problem is that...

Implementing a convolution reverb with rapidly updated impulse responses

javascript,signal-processing,web-audio
i'm doing my master thesis on acoustic raytracing, using WebGL as access point to the GPU horsepower and WebAudio to drive the soundcard. Let's assume, the raytracer is implemented such that it delivers an updated impulse response every frame while a graphics rendering engine runs at 30 frames per second....

How can I avoid CORS restriction for web audio api?

javascript,cors,web-audio
I trying to create some visualization for audio-stream. But I run into CORS trouble when I try get access to raw audio data with createMediaElementSource() function. Is there a way to avoid this restriction and get raw audio data from stream on other origins? Perhaps using WebSockets?...

Play a PCM stream sampled at 16 kHz

websocket,web-audio,pcm
I get a input frame stream through a socket, it is a mono 32-bit IEEE floating point PCM stream sampled at 16 kHz. I get this with the following code : audio File sample With Audacity i can visualize this and i see a regular cuts between my audio flux:...

Web audio API equalizer

javascript,filter,web-audio,equalizer
I have been looking around for creating an audio equalizer using the Web audio API: http://webaudio.github.io/web-audio-api/ I found a lot of threads about creating a visualizer, but that is of course not what I want to do. I simply want to be able to alter the sound using frequency sliders....

Recorder.js calculate and offset recording for latency

javascript,audio,web-audio,recorder.js
I'm using Recorder.js to record audio from Google Chrome desktop and mobile browsers. In my specific use case I need to record exactly 3 seconds of audio, starting and ending at a specific time. Now I know that when recording audio, your soundcard cannot work in realtime due to hardware...

How to record audio using getUserMedia and Web Audio API on Chrome for Android?

android,audio,web-audio,getusermedia,chrome-for-android
I am debugging an application which uses FlashWavRecorder or AudioRecorder to record audio, and then playing it back. The problem is that the application works as intended on Desktop Chrome, but does not record or playback (unsure which) on Chrome for Android. Here's the headers for Android: Request Headers URL:blob:http%3A//example.com/8e112ef4-8691-4582-8abb-82da3e312221...

Can I connect an audio node to 2 different nodes?

web-audio
I'm working with the web audio API. Say I have a source buffer node. Is there any way that I could connect it to 2 different delay nodes? Like var sourceNode = context.createBufferSource(); sourceNode.buffer = myBuffer; sourceNode.connect(delayNode1); sourceNode.connect(delayNode2); ? The way I have it here does not work. It only...

Does linearRampToValueAtTime linearly ramp in decibels or literally linearly in sample values?

web-audio
When I call myGainNode.gain.value = 0; myGainNode.gain.linearRampToValueAtTime(1, currTime + 5000); does the gain audioparam literally linearly ramp the gain coefficient from 0 to 1 in 5 seconds? Or does it ramp in terms of decibels and instead ramp from some negligibly small value to 6.02dB (equivalent to doubling the amplitudes...

Record audio, sync to loop, offset latency and export portion

javascript,html5-audio,audio-recording,web-audio,recorder.js
I am building a web app which allows users to listen to a loop of instrumental music and then record vocals on top. This is all working using Recorder.js however there are a few problems: There is latency with recording, so this needs to be set by the user before...

Slice ArrayBuffer with Safari and play it

safari,web-audio,arraybuffer
I need to load a mp3, slice and play it using web audio , on firefox a slice mp3 any where and decode work fine, but on safari an error with null value occurs. Exist a trick or a way do slice the ArrayBuffer on Safari? player.loadMp3 = function(url, callback)...