audiocontext

How to release memory using Web Audio API?

泄露秘密 提交于 2019-12-05 13:09:57
var context = new window.AudioContext() var request = cc.loader.getXMLHttpRequest(); request.open("GET", 'res/raw-assets/resources/audio/bgm.mp3', true); request.responseType = "arraybuffer"; request.onload = function () { context["decodeAudioData"](request.response, function(buffer){ //success cc.log('success') window.buffer = buffer playBgm() }, function(){ //error }); }; request.onerror = function(){ //error }; request.send(); function playBgm(){ var audio = context["createBufferSource"](); audio.buffer = buffer; var _volume = context['createGain'](); _volume['gain'].value = 1; _volume[

Audio plays in Chrome but not Safari

别等时光非礼了梦想. 提交于 2019-12-02 18:08:01
问题 I've got an angular 5 application where I've set the click handler of a button to download an audio file and play it. I'm using this code to do so: onPreviewPressed(media: Media): void { const url = "....."; this.httpClient.get(url, {responseType: 'blob'}).subscribe(x => { const fileReader = new FileReader(); fileReader.onloadend = () => { const context = new ((<any>window).AudioContext || (<any>window).webkitAudioContext)(); const source = context.createBufferSource(); context

javascript readAsArrayBuffer returns empty Array Buffer

回眸只為那壹抹淺笑 提交于 2019-11-30 07:27:17
I am trying to read a local file using the FileReader readAsArrayBuffer property. The read is success and in the "onload" callback, I see the Array Buffer object in reader.result. But the Array Buffer is just empty. The length is set, but not the data. How do I get this data? Here is my code <!DOCTYPE html> <html> <body> <input type="file" id="file" /> </body> <script> function handleFileSelect(evt) { var files = evt.target.files; // FileList object var selFile = files[0]; var reader = new FileReader(); reader.onload = function(e) { console.log(e.target.result); }; reader.onerror = function(e)

javascript readAsArrayBuffer returns empty Array Buffer

戏子无情 提交于 2019-11-29 09:11:55
问题 I am trying to read a local file using the FileReader readAsArrayBuffer property. The read is success and in the "onload" callback, I see the Array Buffer object in reader.result. But the Array Buffer is just empty. The length is set, but not the data. How do I get this data? Here is my code <!DOCTYPE html> <html> <body> <input type="file" id="file" /> </body> <script> function handleFileSelect(evt) { var files = evt.target.files; // FileList object var selFile = files[0]; var reader = new

Using WebAudio API from NodeJs

陌路散爱 提交于 2019-11-29 05:03:58
I want to use WebAudio(AudioContext) in NodeJS. However NodeJS does not support WebAudio. There is an npm for web-audio-api but it is still in alpha stage and is incomplete. So how can I use WebAudio(AudioContext) in NodeJS. Can I instantiate a chrome browser environment from NodeJS and utilize its capabilties. Is this possible? Is there any other way to do it? Please help. You can use node-webkit or app.js to use WebAudio API and talk with it with socket.io. 来源: https://stackoverflow.com/questions/25197708/using-webaudio-api-from-nodejs

Change sample rate of AudioContext (getUserMedia)

痞子三分冷 提交于 2019-11-28 18:45:07
Im trying to record a 48000Hz recording via getUserMedia. But without luck. The returned audio MediaStream returns 44100Hz. How can i set this to 48000Hz? Here are snippets of my code: var startUsermedia = this.startUsermedia; navigator.getUserMedia({ audio: true, //sampleRate: 48000 }, startUsermedia, function (e) { console.log('No live audio input: ' + e); }); The startUsermedia function: startUsermedia: function (stream) { var input = audio_context.createMediaStreamSource(stream); console.log('Media stream created.'); // Uncomment if you want the audio to feedback directly //input.connect

How can I extract the preceding audio (from microphone) as a buffer when silence is detected (JS)?

ぐ巨炮叔叔 提交于 2019-11-28 07:33:14
I'm using the Google Cloud API for Speech-to-text, with a NodeJS back-end. The app needs to be able to listen for voice commands, and transmit them to the back-end as a buffer. For this, I need to send the buffer of the preceding audio when silence is detected. Any help would be appreciated. Including the js code below 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

Using WebAudio API from NodeJs

独自空忆成欢 提交于 2019-11-27 18:52:19
问题 I want to use WebAudio(AudioContext) in NodeJS. However NodeJS does not support WebAudio. There is an npm for web-audio-api but it is still in alpha stage and is incomplete. So how can I use WebAudio(AudioContext) in NodeJS. Can I instantiate a chrome browser environment from NodeJS and utilize its capabilties. Is this possible? Is there any other way to do it? Please help. 回答1: You can use node-webkit or app.js to use WebAudio API and talk with it with socket.io. 来源: https://stackoverflow

How to play wav audio byte array via javascript/html5?

妖精的绣舞 提交于 2019-11-27 08:25:57
I'm using the following method to play a byte array containing wav data. The function is being called from a GWT project. This function plays back sound, but it sounds like some kind of Hellish monster. The sample rate is definitely correct (the sound is being generated by neospeech) and I've tried all kinds of values for numberOfSamples, which just seems to represent how long the audio data is. A value greater than 30000 for numberOfSamples will play the audio file's full length but it is garbled and horrible. So, what am I doing wrong? function playByteArray(byteArray, numberOfSamples) {

How can I extract the preceding audio (from microphone) as a buffer when silence is detected (JS)?

早过忘川 提交于 2019-11-27 01:51:49
问题 I'm using the Google Cloud API for Speech-to-text, with a NodeJS back-end. The app needs to be able to listen for voice commands, and transmit them to the back-end as a buffer. For this, I need to send the buffer of the preceding audio when silence is detected. Any help would be appreciated. Including the js code below if (!navigator.getUserMedia) navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia; if