Is there a way to feed multiple audio interfaces with Web Audio? - javascript

I am currently thinking about how to realise an app that feeds multiple audio interfaces with different sounds. For example if I have a second sound card at disposal.
As far as I researched the AudioContext of Web Audio only feeds a single destination. I haven't seen a way to select the actual destination hardware.
Can anyone think of a way to work around this?

Nope. It'll use whatever your system default is.

You can output audio from an audio/video element to a specified output device using setSinkid()
videoElement.setSinkId(deviceID).then().catch()

Related

Audio stream modulation in a browser

I am trying to create a calling app that uses WebRTC and a feature I want to add is audio obfuscation.
I want the ability to change the audio pitch that I am sending either at the source audio or even at the receiving end.
I have tried various famous libraries like P5.js but still was unable to get the result.
Need some suggestions/sample code in which I can modulate real time audio or even simulate the feeling that I am modulating the real time pitch of the audio.
I would prefer javascript as it will be rendered on the client but I am even open to using some alternative like WebAssembly if that will help me do the job.
Thanks in advance!

Position dependent audio playback for multiple audio files

I've been designing an html/js based media player whose goal is to give the user some simple playback and region movement functionality found in common DAW's. My ui is comprised of 5 individual tracks and playback controls. By using wavesurfer.js I've been able to successfully create any number of wavesurfer instances/regions inside these tracks, drag and position them anywhere I'd like, and play selected audio files.
In my experimentation with wavesurfer.js, I've found that each instance has its own playhead which indicates the current playback position of the selected audio file and allows the user to navigate playback within that instance.
My issue is that I would also like to have a single "master" playhead which is not contained within any particular instance and am unsure how to approach this.
While there are complex web DAW's out there, I haven't found a source that really helps me understand how to handle audio playback in the way I need..but I know it's been done before. I've read through the webaudio API and wavesurfer.js documentation and unless there's something I'm missing within wavesurfer's capabilities, I'm assuming I need to work with webaudio API to achieve this result - would I start by defining a new AudioContext object comprised of all of the present audio files as AudioNodes?
With multiple audio files/wavesurfer instances whose playback must be dependent on their user-determined positions within the context of the whole track workspace, how would I approach handling audio playback?
Thanks for any insight, I appreciate it.
If you work with for example 5 trackouts, you need to be aware that if you load them into audiobuffers (or audionodes like you call em) they will actually become pretty big concerning the RAM amount if they are longer. So perhaps you can reach your goal if you use five audio elements and set their state and position, though these audio elements can not that easily be accessed by filters and effects and such (Convolver etc.). It really depends on your setup and a prototype shouldn't be too hard to program, so if you are really passionate about it you can make both.
At my website 1ln.de you can load mp3 files (different) in the audio positions and RAM gets up to 30 % of 8 GB if you load 5 mp3 in memory. But RAM is much faster then streaming audio. Because the audio elements need to buffer their contents first and you can't handle and manipulate them as easy as audio buffers.
It really depends on the comlexity of your tool and what you want to achieve.
For professional usage and fast playback i would recommend you playing with audio buffers. It will take some time to decode the audio files first though. But you can handle when buffering is finished.
Hopefully I got your question right.
If you want to program a DAW feel free to say hi for some help.

Possible to process all sounds from webpage with javascript simultaneously?

I've played around with the web audio api before, but it's a very specific and unambiguous that it wants to connect all the sources together to the destination for it to work. However it seems given how iframes and other ways sound can be introduced there'd need to be an extremely elaborate script to tie in new sources to an analyzer node headed to the output.
Note I'm not talking about routing a stream from a microphone like here, there shouldn't be any permission required. Also I'm not talking about audio sources already hooked into the web audio api, there are a ton of examples about processing audio from inside the web audio api. I'm curious if there's a generic way to process audio on a page before (or after) it hits the speakers.
Essentially I was curious if anyone has seen or built an application that's reactive to audio in html and or has thoughts on putting something like this together.
The solution I have in mind would be a script which triggers when media is played and attaches the media source to the web audio api > an analyzer node > destination. I haven't found any javascript event that appears to work in this way.

How do I compress multiple Web Audio sources/tracks into one?

We are making an web based music editor and mixer based on the Web Audio api. Users can mix together multiple tracks, crop tracks, etc. The actual mixing together of the tracks just involves playing back all the sources at once.
We want to be able to add the option to save the mix and make it available for download to a user's computer. Is there some way to do this on the front end (like connecting all the sources to one destination/export node), or even the backend (we are using RoR)?
RecorderJS does exactly what you need, and it could not possibly be easier to use. Really, really great library.
https://github.com/mattdiamond/Recorderjs
P.S. Look into OfflineAudioContext and my answer to this question (Web audio API: scheduling sounds and exporting the mix) for info on doing a faster-than-realtime mixdown of your audio.
Users data looks to be on client side?
Basically when converting data with base64 into dataURI, datas are diplayed inline so they can be add 1 by 1 togheter into one single blob object, and be downloaded.
But this method is only good for smalls files, causing crash and freezing with most browser, this is only good for blob size less than 10mb after some personnal tests, this will be better soon for sure.
<audio controls><source src="data:audio/ogg;base64,BASE64.......BASE564......BASE64............."></audio>
or
<a href="data:audio/ogg;base64,BASE64...BASE64..BASE64....>Download</a>
Probably not your way, just an idea but your project is interesting ;)

Get Relative Loudness of Song, Javascript

I'm trying to build an mp3 player for my site using JavaScript (and any plugins/frameworks(jQuery)/libraries that are relevant) & html5. So I built the player (more accurately, I implemented jPlayer), and now I want to make a visualizer.
Ok maybe it's not a visualizer (all the names for ways to visualize sound always confused me), I guess what I want is something like this:
(source: anthonymattox.com)
Or just something that graphs the amplitude (loudness) of an MP3.
So to start, does anyone know an API that can do this?
If you don't that's ok; I guess I'll build my own. For which I need to know:
Does anybody know a way to get the amplitude/loudness of an mp3 at any given point using JavaScript?
EDIT
Changed to a question about php: Visualization of MP3 - PHP
You would need to be able to decode the MP3 yourself. The html5 audio element, and the browsers's implementations of it, don't expose this sort of data. For example, look at Firefox's exposed methods for JavaScript. The closest thing to what you want is the "volumechange" event. But that is in reference to the volume mixer on the browser's rendered control (i.e. output volume). It has nothing to do with the actual dB of the audio source.
I imagine that the only feasible way to do this is to render your waveform to a graphic ahead of time, and then "reveal" it as the song plays (e.g. with the "timeupdate" event).

Categories

Resources