goldfire / howler.js

Javascript audio library for the modern web.
https://howlerjs.com
MIT License
24k stars 2.23k forks source link

Create howl from MediaStream #1314

Open biellls opened 4 years ago

biellls commented 4 years ago

Is there a way to create a howl from a MediaStream? I'm trying with html5: true but getting 404 (File not found).

navigator.mediaDevices.getUserMedia({
  audio: true
}).then(function (stream) {
  sound = new Howl({
    src: stream,
    html5: true,
    volume: 1.0,
  });
  console.log('New howl created')
  sound.play()
})
biellls commented 4 years ago

Any updates on this? If it's not possible I would be interested in starting an issue hunt on this. Not sure how to go about it but I'd be grateful if someone can reply or email me and talk about details.

sorcerykid commented 4 years ago

I was checking out Howl in search of an API for streaming audio in a Web page, but also with the ability to manipulate the sound during playback. Am I to understand that Howl doesn't support continuous audio streams?

gruckionvit commented 4 years ago

I also really want this, I have search the repository for MediaStream and there are no references.

sorcerykid commented 4 years ago

I successfully managed to work around the issue by creating my own AudioContext and applying effects manually, therefore obviating the need for Howler or any third-party JS library completely. The Web Audio API provides this functionality.

Here's some boilerplate code I developed that has been tested with a live SHOUTcast server. It chains several different audio nodes including Convolver, StereoPanner, BiQuadFilter, and Gain, and it provides dry/wet effects loop mixing for the Convolver.

https://gist.github.com/sorcerykid/a6cb75122b9522607821857c65313501

Note that the convolver requires an impulse response waveform which can be readily obtained from various sources online.