fardog / node-osx-audio

A node.js native library that provides access to Mac OS X Audio I/O as streams.
https://www.npmjs.org/package/osx-audio
MIT License
51 stars 5 forks source link

Port c++ bindings to Nan #7

Closed andresgottlieb closed 8 years ago

andresgottlieb commented 9 years ago

Found out that node-midi did this already (also, check the two following commits [https://github.com/justinlatimer/node-midi/commit/e53396be77e699dc72fa320f6a21ddbb32ac8fbe] and [https://github.com/justinlatimer/node-midi/commit/6048bb747b995161a6f2479d0dff6aba8e2c06c9]) so, since node-osx-audio bindings are based on that project's, it should be somehow straightforward to do this.

The only thing bothering me (for now) is the node::Buffer stuff. It's not based on node-midi, so I have no reference to port it.

@fardog, do you have any ideas/comments to this?

andresgottlieb commented 9 years ago

Been searching and [https://github.com/mdlavin/node-zookeeper/commit/92181f924073a9b8348502ba6448dd3dcb9a67d4](this project) may be useful, since they also had to port usage of node::Buffer to Nan

fardog commented 9 years ago

ah cool, that's great! so when I originally wrote osx-audio, I had planned on basing it on nan for the bindings, however I ran into a few problems; i'm just pulling this from memory as it's been a long while since I looked into it—pardon any inacccuracies.

the issue had to do with not the use of buffers, but the way that nan at the time handled a repeated call to a function; essentially nan assumed that you'd make one call to a function, and get one chunk of data back in a loop, which is not the way that osx-audio needed to work; it repeatedly emits messages in the form of buffers, and nan expected to only perform one allocation; once it received a message it expected to free memory and be done. it looks like a lot of work around that area has been changed though, so it's completely possible this is no longer an issue.

much of what I did came from looking at both what file i/o did in nodejs itself, and the example code that Apple has around audio, and node-midi for the bindings; what node-midi does is really similar to what osx-audio needs to do, so I think that's a great reference to continue looking at! porting this over to nan is absolutely the right move, and it'll make sure that future versions are much easier to release.

but: I don't own any Mac OS X computers any more (the one that I had was from my previous job) so this project is essentially abandonware; i have no way to test any changes, or make any builds myself. if you're able to get somewhere on this, I'd be happy to make you a maintainer on it; I'd love to see this project keep going!

fardog commented 9 years ago

@andresgottlieb I should mention: my c++ is weak at best, so although this is my memory of the issue I ran into, it's totally possible that this was never a limitation of nan, and I just wasn't able to find any example code that led me in the right direction.

andresgottlieb commented 9 years ago

@fardog Thank you for the explanation! My C++ is weaker for sure, but I remember the basics from school. I'll give it a try and let you know if I get somewhere. Thanks again!

andresgottlieb commented 9 years ago

@fardog Hi, I'm just writing to let you know I finally took the shortest path and just included an extra node binary for soundcast to work, so I'm not going to be updating this. Thank you very much for your help!

Someone "e-interviewed" me about soundcast and wrote this tutorial where you're mentioned.

Also, Variety wrote this, and has brought a lot of traffic to the soundcast repo.

Thanks again!

fardog commented 9 years ago

Great work, and thanks for the mention as well! No worries on not getting it updated, and thanks for taking a look; glad you were able to get something worked out with your app!

I'll leave this open and mark as "Help Wanted" just in case anyone stopping by wants to take a look.

danjenkins commented 8 years ago

I might try and tackle this sometime soon - which should enable us to use it with a node version greater than 0.10

fardog commented 8 years ago

@danjenkins that would be incredibly awesome

alexkuz commented 8 years ago

@fardog @andresgottlieb hi everyone, I think I made it :) https://github.com/fardog/node-osx-audio/pull/10

fardog commented 8 years ago

@alexkuz woooaaaaaah! this is the best! I don't have a mac to test it on at the moment, but I'm going to try and get a hold of one briefly, so i can get this tested and merged in the next few days. thanks so much for tackling this!