Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streaming audio with http api request #77

Open
VictorKolb opened this issue Feb 11, 2020 · 5 comments
Open

Streaming audio with http api request #77

VictorKolb opened this issue Feb 11, 2020 · 5 comments
Labels

Comments

@VictorKolb
Copy link

Hello! Thanks for cool library! I have newbie question:
Is it possible to streaming audio from supercolliderjs with http api request?

If I have simple mp3 file I can do something like this:

app.get("/api/audiofile", (req, res) => {
    const filePath = path.resolve("example/file.mp3");
    const stat = fs.statSync(filePath);

    res.writeHead(200, {
        "Content-Type": "audio/mpeg",
        "Content-Length": stat.size,
    });

    const readStream = fs.createReadStream(filePath);
    readStream.pipe(res);
});

I trying naudiodon, but I guess it not right solution

@crucialfelix
Copy link
Owner

It depends on how you are going to host the project. You can run scsynth in a docker container and stream audio out.

Here is one example: https://github.com/maxhawkins/sc_radio

But I think we need a new up to date one.

If I had the time I would set up a Dockerfile that runs supercollider.js with streaming. That could support many listeners, one stereo broadcast channel.

It may be possible to do it with AWS lambda (15 minutes max execution) in which case each visitor gets their own scsynth. Initially more complicated to solve.

@VictorKolb
Copy link
Author

@crucialfelix amazing! It is what I need. I'll try to figure it out. Thanks!

@VictorKolb
Copy link
Author

@crucialfelix so, apparently Node js can't streaming audio from sound cart to api. Do I understand correctly that I can't without Icecast and Darkice? Let's say I want to stream docker container audio out. Can you point in the direction of for google, please?

@crucialfelix
Copy link
Owner

Node here is starting the scsynth process and sending it osc messages. Those messages are to load sounds, play, modulate, stop, filter, efx, sequencing etc.

The sound engine plays on a device which icecast (and other sound streaming apps) can pipe to an MP3 stream. Clients connect to that over http.

Make sense?

@VictorKolb
Copy link
Author

@crucialfelix hm.I think it's become clearer. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants