generativefm / generative.fm

A platform for playing generative music in the browser.
https://generative.fm
MIT License
1.59k stars 86 forks source link

Audio generation on the server side #34

Closed unixfox closed 5 years ago

unixfox commented 5 years ago

I would love to see the generation of the audio on the server side so that it would be possible to play some infinite ambient music on some low powerful hardware like it's already possible to listen to a web radio using a URL on any device that is Wi-Fi compatible. The generated audio would be streamable trough a web server for example.

Mindavi commented 5 years ago

Looking at this project this seems not in the philosophy of this project. The author should chime in but generating it server side vs client side gives very different requirements from the back end.

If this (generating music on the backend) is desired it seems more logical to do this in a seperate project and maybe put the music generating code in a seperate (common) repository. It would make sense to generate one stream of music for multiple listening clients (like a radio station) if one were to implement something like this. Keep in mind that hosting such a server might generate a lot of traffic as streaming music needs a lot of bandwidth.

loksonarius commented 5 years ago

Mmmmm.... now what'd be interesting is taking this code to make a web streaming/video streaming server that infinitely generates this kind of content. 🤔

Now I got an idea for a new project 😄 if this doesn't pan out.

alexbainter commented 5 years ago

Generating the music server side is actually pretty easy but I don't want to host the streams or pay for machine hours to generate them. The site was designed to be cheap to host (it's just a static site served out of an S3 bucket) and generating music server side and distributing it would get expensive. I have been playing around with a YouTube live stream that includes visuals, which is much cheaper since I can run it on a personal machine and just upload it to YouTube, which takes care of distribution. It's almost ready to go, just been focusing more on the site recently.

loksonarius commented 5 years ago

Ooooo.... please link when done 🙏

unixfox commented 5 years ago

@metalex9 I didn't mean to force you to host the website. What I suggested is a self hosted program that anyone could host.

alexbainter commented 5 years ago

@unixfox Ahh I gotcha, sorry for misunderstanding. I have some related work for this but it's nowhere near ready for use by others yet. In case you want to experiment yourself, what I've been doing is loading one of the pieces in a separate project and passing in a MediaStreamAudioDestinationNode as the piece's destination. MediaStreamAudioDestinationNodes have a stream property which is a MediaStream and can be passed to MediaRecorder for recording purposes. This basically turns the audio into some supported audio format like webm or ogg which you can then stream or save as a file.

alexbainter commented 5 years ago

I'm going to leave this closed as I consider it outside the scope of this particular repository but I may someday have another repository for streaming the pieces yourself.