lichen-community-systems / Flocking

Flocking - Creative audio synthesis for the Web
GNU General Public License v2.0
699 stars 60 forks source link

How can I get an output stream from Flocking? (using node.js) #132

Closed yura415 closed 9 years ago

yura415 commented 9 years ago

How can I get an output stream?

When using flock.nodejs.outputManager.createOutputStream I get:

20:14:18.520:  FATAL ERROR: Uncaught exception: not implemented
Error: not implemented
    at Readable._read (_stream_readable.js:449:22)
    at Readable.read (_stream_readable.js:328:10)
    at resume_ (_stream_readable.js:708:12)
    at doNTCallback2 (node.js:429:9)
    at process._tickCallback (node.js:343:17)
    at Function.Module.runMain (module.js:477:11)
    at startup (node.js:117:18)
    at node.js:951:3
colinbdclark commented 9 years ago

Hi @yura415,

Assuming you're using Flocking 0.1.5, you can access Flocking's output stream via the outputStream member of the environment's audioStrategy object. Here's an example:

var enviro = flock.init();
var outputStream = enviro.audioStrategy.outputStream;

This API will change in Flocking 0.2.0 (which hasn't yet been released) due to factoring improvements I've been making. The outputStream will be nested within the environment's outputManager object.

var outputSream = enviro.audioStrategy.outputManager.outputStream;

I'm curious, what are you doing with Flocking where you need to access its underlying output stream? I've always considered it an internal implementation detail, but always try to make these sorts of things available in case people do need them. What's your use case?

I'm looking forward to seeing (hearing?) what you do with it!

yura415 commented 9 years ago

Wow, @colinbdclark, awesome support! It works now.

My intentions was to stream output from Flocking over UDP sockets. Kinda got this working for now, but still needs more work on delay compensations.

colinbdclark commented 9 years ago

Sounds awesome! I'd love to see what you're working on once you get it working. I've thought of doing something like this with Flocking for a while, and it's exciting to hear that you're making progress on it.

Since it sounds like this resolved your issue, I'll go ahead and close it here.

markoarnauto commented 7 years ago

This API will change in Flocking 0.2.0 (which hasn't yet been released) due to factoring improvements I've been making. The outputStream will be nested within the environment's outputManager object.

var outputSream = enviro.audioStrategy.outputManager.outputStream;

It not possible to gather outputStream this way. Can you please update this how it actually works in 0.2.0?

colinbdclark commented 7 years ago

Hi @markoarnauto,

Just in case, I should be clear: this is an unsupported API, and Flocking 0.2.0 hasn't yet (still!) been released officially. But if you're using the 0.2.0-dev.20170206T221943Z.fb09a52 dev release or the latest code in master, and want to access the underlying audio output stream being piped to node-speaker, the audioStrategy component has been renamed to audioSystem.

var flock = require("flocking");
var enviro = flock.init();
var outputStream = enviro.audioSystem.outputManager.outputStream;

I hope this helps!