Node.js Saturday Night Bounty - $100 - Low-Latency Cross-Platform Audio Playback with easy installer

1,074 views
Skip to first unread message

Marak Squires

unread,
May 7, 2011, 11:44:54 PM5/7/11
to nodejs
Hello Internet Friends -

I'm in the middle of doing a music hack event and I'm tired of dealing with https://github.com/tmpvar/node-irrklang for audio playback. It requires 32bit node, is macos only, and irrklang doesn't have a very permissive license. I'm very grateful that tmpvar was able to make node-irrklang for our JSONloops project in such a limited timespace, but it's time to replace it with something else.

I'm paying $100 cash ( from my own pocket ) to the first person who can deliver a cross-platform audio playback for node that can be installed via npm ( without any additional downloads outside of npm install foo ).

It needs to expose an API simply enough that I can use this library to consume it: https://github.com/marak/play.js

It needs to be able to playback wav files of various quality, and maybe even mp3s. 

It needs to work cross-platform ( mac / and linux is good enough for now ).

https://github.com/bmeck/node-sfml looks like a promising start, you might be able to just use this if you are ninja enough to know how to properly bundle everything...

First one to post a working solution wins, working together is encouraged. 

Needs to be MIT license. 

On a closing note, I'm very aware that the amount of money I'm offering is extremely low, but I thought it might be fun to try and motivate someone to release a package that a lot of people might find helpful. 

- Marak

Dav Glass

unread,
May 8, 2011, 1:42:45 AM5/8/11
to nod...@googlegroups.com
Marak --

I've been looking for one too, how about I match your bounty and make
it $200 to make it interesting ;)

--
Dav Glass
davg...@gmail.com
blog.davglass.com


+ Windows: n. - The most successful computer virus, ever. +
+ A computer without a Microsoft operating system is like a dog
    without bricks tied to its head +
+ A Microsoft Certified Systems Engineer is to computing what a
   McDonalds Certified Food Specialist is to fine cuisine  +

> --
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com.
> To unsubscribe from this group, send email to
> nodejs+un...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en.
>

Marak Squires

unread,
May 8, 2011, 1:45:15 AM5/8/11
to nod...@googlegroups.com
Holy moley! The shits getting real! Bounty is up to $200 with a donation from Dav Glass!!!!!

ITS JAVASCRIPT TIME!

chase sechrist

unread,
May 8, 2011, 3:47:21 AM5/8/11
to nodejs
Count me in for +$50 to the pot. I want this.

On May 7, 10:45 pm, Marak Squires <marak.squi...@gmail.com> wrote:
> Holy moley! The shits getting real! Bounty is up to $200 with a donation
> from Dav Glass!!!!!
>
> ITS JAVASCRIPT TIME!
>
>
>
>
>
>
>
> On Sat, May 7, 2011 at 10:42 PM, Dav Glass <davgl...@gmail.com> wrote:
> > Marak --
>
> > I've been looking for one too, how about I match your bounty and make
> > it $200 to make it interesting ;)
>
> > --
> > Dav Glass
> > davgl...@gmail.com
> > blog.davglass.com
>
> > + Windows: n. - The most successful computer virus, ever. +
> > + A computer without a Microsoft operating system is like a dog
> >     without bricks tied to its head +
> > + A Microsoft Certified Systems Engineer is to computing what a
> >    McDonalds Certified Food Specialist is to fine cuisine  +
>
> > On Sat, May 7, 2011 at 10:44 PM, Marak Squires <marak.squi...@gmail.com>
> > wrote:
> > > Hello Internet Friends -
> > > I'm in the middle of doing a music hack event and I'm tired of dealing
> > > withhttps://github.com/tmpvar/node-irrklangfor audio playback. It
> > requires
> > > 32bit node, is macos only, and irrklang doesn't have a very
> > > permissive license. I'm very grateful that tmpvar was able to make
> > > node-irrklang for our JSONloops project in such a limited timespace, but
> > > it's time to replace it with something else.
> > > I'm paying $100 cash ( from my own pocket ) to the first person who can
> > > deliver a cross-platform audio playback for node that can be installed
> > via
> > > npm ( without any additional downloads outside of npm install foo ).
> > > It needs to expose an API simply enough that I can use this library to
> > > consume it:https://github.com/marak/play.js
> > > It needs to be able to playback wav files of various quality, and maybe
> > even
> > > mp3s.
> > > It needs to work cross-platform ( mac / and linux is good enough for now
> > ).
> > >https://github.com/bmeck/node-sfmllooks like a promising start, you
> > might
> > > be able to just use this if you are ninja enough to know how to properly
> > > bundle everything...
> > > First one to post a working solution wins, working together is
> > encouraged.
> > > Needs to be MIT license.
> > > On a closing note, I'm very aware that the amount of money I'm offering
> > is
> > > extremely low, but I thought it might be fun to try and motivate someone
> > to
> > > release a package that a lot of people might find helpful.
> > > - Marak
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "nodejs" group.
> > > To post to this group, send email tono...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > >nodejs+un...@googlegroups.com.
> > > For more options, visit this group at
> > >http://groups.google.com/group/nodejs?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "nodejs" group.
> > To post to this group, send email tono...@googlegroups.com.

Marak Squires

unread,
May 8, 2011, 3:54:03 AM5/8/11
to nod...@googlegroups.com
YES! YES! YES!

Thanks Chase!

I can attest that both Dav and Chase are good for the bounty.

- Marak

To post to this group, send email to nod...@googlegroups.com.

Derek Gathright

unread,
May 8, 2011, 4:00:56 AM5/8/11
to nod...@googlegroups.com
If someone wanted to write a Web Audio library for Node, then it seems like the original request would be a piece of cake.  I'll throw down $100 for whoever gets something working w/ an API similar to Mozilla's Audio Data.

https://chromium.googlecode.com/svn/trunk/samples/audio/specification/specification.html#JavaScriptAudioNode-section
https://wiki.mozilla.org/Audio_Data_API

If I could use beads.js server-side, I'd flip out.  http://beadsjs.chrismorgan.info/

Marak Squires

unread,
May 8, 2011, 4:10:43 AM5/8/11
to nod...@googlegroups.com
Derek -

I love your enthusiasm! I agree with what you are saying, but I think what you are asking is a bit out of scope of what I'm looking for. I also don't think we've had a chance to meet / talk before. 

Unfortunately, because of these reasons I want to make it clear to anyone reading that "my" bounty is still only at $250.

Derek - If you'd be willing to contribute to the original bounty, please feel free to email me and we can sort it out.

- Marak

Marak Squires

unread,
May 8, 2011, 4:11:45 AM5/8/11
to nod...@googlegroups.com
Scratch that, I'm an idiot.

I KNOW YOU DEREK!!! Lol

Please be clear if you want to be down for the OG bounty, without any changes to the specifications.

A million apologies. 

Derek Gathright

unread,
May 8, 2011, 4:47:33 AM5/8/11
to nod...@googlegroups.com
Yeah, I'll chip in.  My pledge...
- $50 for Marak's original request (total bounty at $300)
- $100 for a Web Audio API library (total bounty at $100)

Like I said, if someone does a Web Audio library, then building another layer on top of it to support an API like Marak requested should be easy (in comparison).  Tackle both? $150 from me, $400 total.  Yeah, it's not a ton, but hopefully it's enough to provide some motivation for something that would make Node totally pwn the competition.  For comparison, the method I used to generate audio for a recent hackday event was using Processing (w/ SoundCipher).  That blew.  If I could not just play MP3s, but actually generate audio on the fly, that would be epic.  It's great that there's already a w3c draft for us to work with.

Related, I just came across this module that can generate MP3s.  Can't play them, but it's a start.
https://github.com/fwg/node-radio-stream
 
A million apologies.

Forgiven. :)

Marak Squires

unread,
May 8, 2011, 4:50:26 AM5/8/11
to nod...@googlegroups.com
$300, it's official. I've got word it's about to get bumped to $400. 

Jared Tame

unread,
May 8, 2011, 4:35:22 AM5/8/11
to nodejs
As the author behind Startups Open Sourced, can I add $100 to the
bounty? I can verify my own identity and the web site
(startupsopensourced.com) if needed.

On May 8, 3:11 am, Marak Squires <marak.squi...@gmail.com> wrote:
> Scratch that, I'm an idiot.
>
> I KNOW YOU DEREK!!! Lol
>
> Please be clear if you want to be down for the OG bounty, without any
> changes to the specifications.
>
> A million apologies.
>
> On Sun, May 8, 2011 at 1:10 AM, Marak Squires <marak.squi...@gmail.com>wrote:
>
>
>
>
>
>
>
> > Derek -
>
> > I love your enthusiasm! I agree with what you are saying, but I think what
> > you are asking is a bit out of scope of what I'm looking for. I also don't
> > think we've had a chance to meet / talk before.
>
> > Unfortunately, because of these reasons I want to make it clear to anyone
> > reading that "my" bounty is still only at $250.
>
> > Derek - If you'd be willing to contribute to the original bounty, please
> > feel free to email me and we can sort it out.
>
> > - Marak
>
> > On Sun, May 8, 2011 at 1:00 AM, Derek Gathright <drg...@gmail.com> wrote:
>
> >> If someone wanted to write a Web Audio library for Node, then it seems
> >> like the original request would be a piece of cake.  I'll throw down $100
> >> for whoever gets something working w/ an API similar to Mozilla's Audio
> >> Data.
>
> >>https://chromium.googlecode.com/svn/trunk/samples/audio/specification...
> >>https://wiki.mozilla.org/Audio_Data_API
>
> >> If I could use beads.js server-side, I'd flip out.
> >>http://beadsjs.chrismorgan.info/
>
> >> On Sat, May 7, 2011 at 10:45 PM, Marak Squires <marak.squi...@gmail.com>wrote:
>
> >>> Holy moley! The shits getting real! Bounty is up to $200 with a donation
> >>> from Dav Glass!!!!!
>
> >>> ITS JAVASCRIPT TIME!
>
> >>> On Sat, May 7, 2011 at 10:42 PM, Dav Glass <davgl...@gmail.com> wrote:
>
> >>>> Marak --
>
> >>>> I've been looking for one too, how about I match your bounty and make
> >>>> it $200 to make it interesting ;)
>
> >>>> --
> >>>> Dav Glass
> >>>> davgl...@gmail.com
> >>>> blog.davglass.com
>
> >>>> + Windows: n. - The most successful computer virus, ever. +
> >>>> + A computer without a Microsoft operating system is like a dog
> >>>>     without bricks tied to its head +
> >>>> + A Microsoft Certified Systems Engineer is to computing what a
> >>>>    McDonalds Certified Food Specialist is to fine cuisine  +
>
> >>>> On Sat, May 7, 2011 at 10:44 PM, Marak Squires <marak.squi...@gmail.com>
> >>>> wrote:
> >>>> > Hello Internet Friends -
> >>>> > I'm in the middle of doing a music hack event and I'm tired of dealing
> >>>> > withhttps://github.com/tmpvar/node-irrklangfor audio playback. It
> >>>> requires
> >>>> > 32bit node, is macos only, and irrklang doesn't have a very
> >>>> > permissive license. I'm very grateful that tmpvar was able to make
> >>>> > node-irrklang for our JSONloops project in such a limited timespace,
> >>>> but
> >>>> > it's time to replace it with something else.
> >>>> > I'm paying $100 cash ( from my own pocket ) to the first person who
> >>>> can
> >>>> > deliver a cross-platform audio playback for node that can be installed
> >>>> via
> >>>> > npm ( without any additional downloads outside of npm install foo ).
> >>>> > It needs to expose an API simply enough that I can use this library to
> >>>> > consume it:https://github.com/marak/play.js
> >>>> > It needs to be able to playback wav files of various quality, and
> >>>> maybe even
> >>>> > mp3s.
> >>>> > It needs to work cross-platform ( mac / and linux is good enough for
> >>>> now ).
> >>>> >https://github.com/bmeck/node-sfmllooks like a promising start, you

Marak Squires

unread,
May 8, 2011, 5:50:32 AM5/8/11
to nod...@googlegroups.com
$400, confirmed! 

Floby

unread,
May 8, 2011, 9:01:28 AM5/8/11
to nodejs
I want this too. Unfortunately being a student I don't have much to
put in. However I have enough knowledge in C++/V8 to help working
around bindings to a C library, probably portaudio[1]

[1]http://www.portaudio.com/
> > > >>>> > withhttps://github.com/tmpvar/node-irrklangforaudio playback. It
> > > >>>> requires
> > > >>>> > 32bit node, is macos only, and irrklang doesn't have a very
> > > >>>> > permissive license. I'm very grateful that tmpvar was able to make
> > > >>>> > node-irrklang for our JSONloops project in such a limited
> > timespace,
> > > >>>> but
> > > >>>> > it's time to replace it with something else.
> > > >>>> > I'm paying $100 cash ( from my own pocket ) to the first person
> > who
> > > >>>> can
> > > >>>> > deliver a cross-platform audio playback for node that can be
> > installed
> > > >>>> via
> > > >>>> > npm ( without any additional downloads outside of npm install foo
> > ).
> > > >>>> > It needs to expose an API simply enough that I can use this
> > library to
> > > >>>> > consume it:https://github.com/marak/play.js
> > > >>>> > It needs to be able to playback wav files of various quality, and
> > > >>>> maybe even
> > > >>>> > mp3s.
> > > >>>> > It needs to work cross-platform ( mac / and linux is good enough
> > for
> > > >>>> now ).
> > > >>>> >https://github.com/bmeck/node-sfmllookslike a promising start,

Jacob Chapel

unread,
May 8, 2011, 9:24:27 AM5/8/11
to nod...@googlegroups.com
I have the initial work done with portaudio, I will be getting an initial version meeting these requirements and working towards more library support. Don't be discouraged, if anyone has something already, or wants to jump in on this, go right ahead, this is something that is needed. :)

Dean Landolt

unread,
May 8, 2011, 11:28:50 AM5/8/11
to nod...@googlegroups.com
On Sun, May 8, 2011 at 4:47 AM, Derek Gathright <drg...@gmail.com> wrote:
Yeah, I'll chip in.  My pledge...
- $50 for Marak's original request (total bounty at $300)
- $100 for a Web Audio API library (total bounty at $100)


This is an awesome idea Marak! I have no use for it but I'll sweeten Derek's Web Audio API pot by another $200 for the hell of it. The more webby APIs we can implement the better...

Speaking of -- another $200 to the first person that can deliver a working IndexedDB API with an MIT or BSD license. (If anyone wants in on this please respond in a new thread to avoid further hijacking this one :)

Marak Squires

unread,
May 8, 2011, 1:25:08 PM5/8/11
to nod...@googlegroups.com
I'd recommend going public with the repo, linking your work, and trying to collaborate. :-)

Derek Gathright

unread,
May 8, 2011, 3:35:49 PM5/8/11
to nod...@googlegroups.com
I have the initial work done with portaudio, I will be getting an initial version meeting these requirements and working towards more library support.

Good call. Of all the libraries I found, PortAudio looked like a great candidate for this task.
 
I'll sweeten Derek's Web Audio API pot by another $200 for the hell of it.

Woo! $300 now. :)

Speaking of -- another $200 to the first person that can deliver a working IndexedDB API with an MIT or BSD license.

Whoever wants to tackle this, this could be a good starting point.  https://code.google.com/p/indexeddb/

Derek Gathright

unread,
May 8, 2011, 5:08:15 PM5/8/11
to nod...@googlegroups.com
Question....  In Marak's play.js example code, which looks like

  var play = require('play');

  // play with a callback
  play.sound('./wavs/sfx/intro.wav', function(){

    // these are all "fire and forget", no callback
    play.sound('./wavs/sfx/alarm.wav');
    play.sound('./wavs/sfx/crinkle.wav');
    play.sound('./wavs/sfx/flush.wav');
    play.sound('./wavs/sfx/ding.wav');

  });

Are all 4 of the inner sounds intended to fire at the same time?  Or, one after another.  In other words, is sound() sync or async?  Async, I have a hacky solution in the works.  Sync, I'll need to learn more about how to make a spawned process block until it is finished.

Jacob Chapel

unread,
May 8, 2011, 5:10:21 PM5/8/11
to nod...@googlegroups.com
Well fire and forget, they should all fire at the same time. Though he wanted something native, not just a command line utility binding.

Marak Squires

unread,
May 8, 2011, 5:17:40 PM5/8/11
to nod...@googlegroups.com
You really need to use C bindings, any other approach will introduce > 18 ms latency. 

Those play.sound() files should go out almost at the same time, visualize you had a sequencer playing 16 notes at a time, you dont care when they end, you care when they start.

- Marak

Derek Gathright

unread,
May 8, 2011, 5:21:28 PM5/8/11
to nod...@googlegroups.com
Though he wanted something native, not just a command line utility binding.

Oh I know.  But, he's at a hackday, so figured he might be looking for any working method.  So, here's a solution for OSX.  afplay has been in since Leopard (2007), so should work on any modern Macbook out there.

Took all of 5 minutes to code up.  And no, I don't think this qualifies for the bounty. :)

module.exports.sound = function(path, callback){
    var exec = require('child_process').exec;
    exec('afplay ' + path, function () {
        if (callback) callback();
    });
}

Marak Squires

unread,
May 8, 2011, 5:26:10 PM5/8/11
to nod...@googlegroups.com
*cough* that doesn't work.


The latency is too high, you NEED to use C bindings. I'm not sure how else to say this, I've been trying this for a while. Please prove me wrong.

--

Derek Gathright

unread,
May 8, 2011, 5:33:52 PM5/8/11
to nod...@googlegroups.com
I don't disagree you need C bindings, it's the right way to do it.  Just offering up a temp hack, which it appears you already knew about. :)

On Sun, May 8, 2011 at 2:26 PM, Marak Squires <marak....@gmail.com> wrote:
Audio playback with anything greater then 18ms latency is pretty much unacceptable, even that is high.

Now imagine you are playing 16 tracks at once, still all need to be < 18ms. :-\

Marak Squires

unread,
May 8, 2011, 5:37:22 PM5/8/11
to nod...@googlegroups.com
I've been trying to make this work for over a year, please excuse my sour attitude about high latency audio playback using child processes. 

:-)

Jacob Chapel

unread,
May 8, 2011, 5:41:54 PM5/8/11
to nodejs
I'm working on it, it isn't an easy problem, but hopefully what I make
solves the issue at hand. Wish I had more time today, but I have to
get some sleep since I work nights. I want to get default playback
fire and forget style going, and I will release it.

On May 8, 2:37 pm, Marak Squires <marak.squi...@gmail.com> wrote:
> I've been trying to make this work for over a year, please excuse my sour
> attitude about high latency audio playback using child processes.
>
> :-)
>
>
>
>
>
>
>
> On Sun, May 8, 2011 at 2:33 PM, Derek Gathright <drg...@gmail.com> wrote:
> > I don't disagree you need C bindings, it's the right way to do it.  Just
> > offering up a temp hack, which it appears you already knew about. :)
>
> > On Sun, May 8, 2011 at 2:26 PM, Marak Squires <marak.squi...@gmail.com>wrote:
>
> >> Audio playback with anything greater then 18ms latency is pretty much
> >> unacceptable, even that is high.
>
> >>  Now imagine you are playing 16 tracks at once, still all need to be <
> >> 18ms. :-\
>

Marak Squires

unread,
May 8, 2011, 5:43:43 PM5/8/11
to nod...@googlegroups.com
I think I just wet myself a little.

Marcello Bastéa-Forte

unread,
May 8, 2011, 6:04:01 PM5/8/11
to nod...@googlegroups.com
Semi unrelated: Would be super awesome to integrate something like ChucK into node.js. It's an audio programming language designed for doing realtime audio programming. I wonder how adaptable to node.js's event system it is.

Marcello

Marak Squires

unread,
May 8, 2011, 5:26:55 PM5/8/11
to nod...@googlegroups.com
Audio playback with anything greater then 18ms latency is pretty much unacceptable, even that is high.

Now imagine you are playing 16 tracks at once, still all need to be < 18ms. :-\

George Stagas

unread,
May 8, 2011, 6:49:47 PM5/8/11
to nod...@googlegroups.com
2011/5/9 Marcello Bastéa-Forte <marc...@cellosoft.com>:

> Semi unrelated: Would be super awesome to integrate something like ChucK
> into node.js. It's an audio programming language designed for doing realtime
> audio programming. I wonder how adaptable to node.js's event system it is.
> Marcello

Similar to ChucK is SuperCollider, which also has an OSC interface
that node can communicate with. Did some bindings the other day
https://github.com/stagas/node-supercollider nothing much yet but it's
a start. Right now we have it playing a few notes on a Synthdef but
you still need to load them in SC yourself before using them.

The problem with audio/music programming in JS is the lack of strong
timing. If you miss the beat even by a few ms it would sound
shuffling. Also, even if you get .play() working with very low
latency, playing ie the same sample a lot of times would introduce
unwanted flanger/chorus effects as they will all be executed just a
bit one after another.

The only solution I can think of is having the timer/beats living
outside JS and just use JS to define when and how you want them to
play ie bpm = 127; steps = new StepSequencer(bpm); steps.set([1, 2, 3,
4], 'kick.mp3'); steps.set([2, 4], 'snare.mp3'); steps.run(); // not
exactly but you get the point

-stagas

Marak Squires

unread,
May 8, 2011, 6:53:32 PM5/8/11
to nod...@googlegroups.com
I get acceptable latency with node-irrklang, it's suitable enough for JSONloops playback. I see < 5ms playback times consistently with 8+ tracks.

- Marak

Elijah Insua

unread,
May 8, 2011, 7:05:37 PM5/8/11
to nod...@googlegroups.com

process.nextTick() and Date.now()  should work well as the basis for precise timers

--Elijah

Marak Squires

unread,
May 8, 2011, 7:08:03 PM5/8/11
to nod...@googlegroups.com
Aye, thats how JSONloops work, thanks to Eli's insanely genius code. 

:-)

On Sun, May 8, 2011 at 4:05 PM, Elijah Insua <tmp...@gmail.com> wrote:

process.nextTick() and Date.now()  should work well as the basis for precise timers

--Elijah

--

George Stagas

unread,
May 8, 2011, 7:15:29 PM5/8/11
to nod...@googlegroups.com
2011/5/9 Marak Squires <marak....@gmail.com>:

> Aye, thats how JSONloops work, thanks to Eli's insanely genius code.
> :-)
> On Sun, May 8, 2011 at 4:05 PM, Elijah Insua <tmp...@gmail.com> wrote:
>>
>> process.nextTick() and Date.now()  should work well as the basis for
>> precise timers
>>
>> --Elijah
>>

In music you need a process.stopEverythingElseAndDo() otherwise if
something blocks the event loop nextTick will be seriously off beat. I
mean it's ok to play with and experiment and it would be great to have
a .play() in node, but for any serious music application, you need
_perfect_ accuracy, not a 5ms shuffle. Our ears are extremely
sensitive to timing.

-stagas

Marak Squires

unread,
May 8, 2011, 7:23:30 PM5/8/11
to nod...@googlegroups.com
I don't think the average person can detect audio latency below 10ms. I've been doing digital audio production for about 10 years and have dealt with numerous systems and various levels of measured latency.

I'm not saying its impossible to detect by ear, but it's pretty hard. Also, it should be noted that I've got a working proof of concept with JSONloops that can do a lot of concurrent tracks with pretty much no latency using irrKlang.... The reason I'm asking for this library is really about making the installation process easier for users.

- Marak

George Stagas

unread,
May 8, 2011, 7:49:07 PM5/8/11
to nod...@googlegroups.com
2011/5/9 Marak Squires <marak....@gmail.com>:

> I don't think the average person can detect audio latency below 10ms. I've
> been doing digital audio production for about 10 years and have dealt with
> numerous systems and various levels of measured latency.
> I'm not saying its impossible to detect by ear, but it's pretty hard. Also,
> it should be noted that I've got a working proof of concept with JSONloops
> that can do a lot of concurrent tracks with pretty much no latency using
> irrKlang.... The reason I'm asking for this library is really about making
> the installation process easier for users.
> - Marak
>

No, we can't detect latency <10ms _perceivably_, but there are
psychoacoustic effects that live in that low range of 0-30ms, and we
can certainly detect those. So in reality, we do hear a 5ms latency
shuffle pretty well as the effect flanger. Research comb filter,
flanger and chorus.

Even if you never play the same sample at the same time more than
once, which is something really common in sequencing, when enhancing
envelopes of samples like snares, the effect is still there which
makes it unacceptable for any serious application.

Marak Squires

unread,
May 8, 2011, 7:53:11 PM5/8/11
to nod...@googlegroups.com
Well, irrKlang is currently playing as I type this and it sounds fine. Honestly, I don't see any reason why Node isn't suitable for Audio applications. Until it fails my ears, I'm going to still believe. 

Marcello Bastéa-Forte

unread,
May 8, 2011, 8:01:31 PM5/8/11
to nod...@googlegroups.com
10ms is a good benchmark for synchronizing multiple audio streams. You can easily do up to 100ms if you're synchronizing a mechanical user input (delay between the user pressing the button and action happening).

Here's a nice summary of various articles on the subject: http://forum.ableton.com/viewtopic.php?f=1&t=46567

You can't forget the latency in other parts of your system—so striving for <10ms latency does have some merit.

Marcello

Bradley Meck

unread,
May 8, 2011, 8:35:49 PM5/8/11
to nod...@googlegroups.com
Not necessarily. C bindings can force the queue to be immediate, before the next event queue loop when queueing.

Jeroen Janssen

unread,
May 8, 2011, 6:11:54 AM5/8/11
to nodejs
Hi,

Just two questions to clarify this:

*) this (original bounty) is about playing audio on the server right?
*) if the above is true, then I guess a nodejs SDL_mixer addon (based
on the crossplatform LGPL'ed http://www.libsdl.org/ which seems to
support linux/mac/windows on 32 and 64 bit platforms and can load
various audio formats) could qualify?

(I am completely new to nodejs development, so someone will probably
beat me to it while I figure out how to actually write a nodejs
addon , but I'm willing to give it a shot. I don't have a mac for
testing though)

Best regards,

Jeroen Janssen

On May 8, 5:44 am, Marak Squires <marak.squi...@gmail.com> wrote:
> Hello Internet Friends -
>
> I'm in the middle of doing a music hack event and I'm tired of dealing withhttps://github.com/tmpvar/node-irrklangfor audio playback. It requires
> 32bit node, is macos only, and irrklang doesn't have a very
> permissive license. I'm very grateful that tmpvar was able to make
> node-irrklang for our JSONloops project in such a limited timespace, but
> it's time to replace it with something else.
>
> I'm paying $100 cash ( from my own pocket ) to the first person who can
> deliver a cross-platform audio playback for node that can be installed via
> npm ( without any additional downloads outside of npm install foo ).
>
> It needs to expose an API simply enough that I can use this library to
> consume it:https://github.com/marak/play.js
>
> It needs to be able to playback wav files of various quality, and maybe even
> mp3s.
>
> It needs to work cross-platform ( mac / and linux is good enough for now ).
>
> https://github.com/bmeck/node-sfmllooks like a promising start, you might

Jeroen Janssen

unread,
May 8, 2011, 9:28:02 AM5/8/11
to nodejs
Hi,

Apparently my earlier reply is not showing up on this mailinglist yet,
so here goes another one.

Assuming this is all about getting audio on the server where nodejs is
running, I have started something at https://github.com/japj/node-sdlmixer

It uses SDL_mixer (based on libsdl) to perform cross platform audio
output).
So far I basically have combined the nodejs 'hello world' addon with a
very simple sample from the SDL_mixer code.

Needless to say it is a very very very *very* early stage prototype
and I do not know anything of actually coding an 'async correctly
behaving' nodejs addon. But the test does play an audio file when you
require the code from nodejs (so it is something to start with,
although it blocks until done playing the audio).

Since I do not have a Mac, I can not determine if it will work there,
but I have tried to create a wscript that works for me. If anybody can
see if it also works on a Mac, that would be very much appreciated.

Due to me being unfamiliar with nodejs/v8 addon programming, I am a
bit stuck now. I have made a TODO list of things that I can think of
that need to be done, but I do not know exactly where to start.

Are there any good examples of howto:
*) use an external library that needs synchronous file loading from a
nodejs addon
*) howto use javascript callbacks from a nodejs addon
*) initialize (and 'cleanup') an external library from a nodejs addon

Nico

unread,
May 8, 2011, 2:05:37 PM5/8/11
to nodejs
I'll add $100 for Marak's original request, maybe this will speed
things up a little bit... :D


On May 8, 1:25 pm, Marak Squires <marak.squi...@gmail.com> wrote:
> I'd recommend going public with the repo, linking your work, and trying
> to collaborate. :-)
>
>
>
>
>
>
>
> On Sun, May 8, 2011 at 6:24 AM, Jacob Chapel <jacob.cha...@gmail.com> wrote:
> > I have the initial work done with portaudio, I will be getting an initial
> > version meeting these requirements and working towards more library support.
> > Don't be discouraged, if anyone has something already, or wants to jump in
> > on this, go right ahead, this is something that is needed. :)
>
> >> > > > >>>> > withhttps://github.com/tmpvar/node-irrklangforaudioplayback. It
> >> > > > >>>> >https://github.com/bmeck/node-sfmllookslikea promising

Marak Squires

unread,
May 8, 2011, 9:36:46 PM5/8/11
to nod...@googlegroups.com
This looks promising...if I understand correctly we might have a potential candidate here...

Can you play the audio file from JavaScript or can it only be called in C? To be clear,  I need access to a play() command from JS land.

Marak Squires

unread,
May 8, 2011, 9:40:21 PM5/8/11
to nod...@googlegroups.com
Does that make it $500 now?!?!??! I've got to get some sleep but this is getting hot!!!

Nicholas Campbell

unread,
May 8, 2011, 9:52:06 PM5/8/11
to nod...@googlegroups.com
You can find some examples of async c++ bindings with my bcrypt lib https://github.com/ncb000gt/node.bcrypt.js or with Isaac's nas module (looks to be a reference module) https://github.com/isaacs/node-async-simple/blob/master/nas.cc.

If you look at the bcrypt lib you can take a peek at the tests which show how the async code works from JS land. Good luck. :)

- Nick Campbell

http://digitaltumbleweed.com


Jacob Chapel

unread,
May 9, 2011, 12:33:09 AM5/9/11
to nod...@googlegroups.com

It works in js land like you would expect. My main issue right now is timing, reliability. Audio has to be fast.

Jacob Chapel

unread,
May 9, 2011, 1:05:56 AM5/9/11
to nodejs
Would someone be so kind as to make a test for me that checks latency.
Just a simple test, I can plug in the appropriate code, would be
audio.play('sound.wav'). I can't think of a good way to check that at
the moment.

On May 8, 9:33 pm, Jacob Chapel <jacob.cha...@gmail.com> wrote:
> It works in js land like you would expect. My main issue right now is
> timing, reliability. Audio has to be fast.
> On May 8, 2011 6:36 PM, "Marak Squires" <marak.squi...@gmail.com> wrote:
>
>
>
>
>
>
>
> > This looks promising...if I understand correctly we might have a potential
> > candidate here...
>
> > Can you play the audio file from JavaScript or can it only be called in C?
> > To be clear, I need access to a play() command from JS land.
>
> > On Sun, May 8, 2011 at 6:28 AM, Jeroen Janssen <jeroen.jans...@gmail.com
> >> withhttps://github.com/tmpvar/node-irrklangforaudio playback. It
> requires
> >> > 32bit node, is macos only, and irrklang doesn't have a very
> >> > permissive license. I'm very grateful that tmpvar was able to make
> >> > node-irrklang for our JSONloops project in such a limited timespace,
> but
> >> > it's time to replace it with something else.
>
> >> > I'm paying $100 cash ( from my own pocket ) to the first person who can
> >> > deliver a cross-platform audio playback for node that can be installed
> >> via
> >> > npm ( without any additional downloads outside of npm install foo ).
>
> >> > It needs to expose an API simply enough that I can use this library to
> >> > consume it:https://github.com/marak/play.js
>
> >> > It needs to be able to playback wav files of various quality, and maybe
> >> even
> >> > mp3s.
>
> >> > It needs to work cross-platform ( mac / and linux is good enough for
> now
> >> ).
>
> >> >https://github.com/bmeck/node-sfmllookslike a promising start, you

Marak Squires

unread,
May 9, 2011, 1:11:12 AM5/9/11
to nod...@googlegroups.com
Chapel -

It works in js land like you would expect. My main issue right now is timing, reliability. Audio has to be fast.

Which library are you talking about? You've lost me completely. I was talking to Jeroen Janssen about https://github.com/japj/node-sdlmixer

Have you posted any library yet? 

Jeroen Janssen

unread,
May 9, 2011, 1:37:26 AM5/9/11
to nodejs
Hi,

I have not actually implemented it yet, but it's possible to play
audio from javascript. Basically the SDL_mixer api Mix_LoadWAV expects
a file path to an audio file.

The main problem I have is me being totally unfamiliar with nodejs C/C+
+ addon programming (especially on how to deal with the async stuff).
So I got stuck there (see my TODO list and questions).

But seeing that there are also portaudio projects in progress, I guess
we have multiple available options soon ;)

Best regards,

Jeroen Janssen

On May 9, 3:36 am, Marak Squires <marak.squi...@gmail.com> wrote:
> This looks promising...if I understand correctly we might have a potential
> candidate here...
>
> Can you play the audio file from JavaScript or can it only be called in C?
> To be clear,  I need access to a play() command from JS land.
>
> On Sun, May 8, 2011 at 6:28 AM, Jeroen Janssen <jeroen.jans...@gmail.com>wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > Apparently my earlier reply is not showing up on this mailinglist yet,
> > so here goes another one.
>
> > Assuming this is all about getting audio on the server where nodejs is
> > running, I have started something athttps://github.com/japj/node-sdlmixer
> > withhttps://github.com/tmpvar/node-irrklangforaudio playback. It requires
> > > 32bit node, is macos only, and irrklang doesn't have a very
> > > permissive license. I'm very grateful that tmpvar was able to make
> > > node-irrklang for our JSONloops project in such a limited timespace, but
> > > it's time to replace it with something else.
>
> > > I'm paying $100 cash ( from my own pocket ) to the first person who can
> > > deliver a cross-platform audio playback for node that can be installed
> > via
> > > npm ( without any additional downloads outside of npm install foo ).
>
> > > It needs to expose an API simply enough that I can use this library to
> > > consume it:https://github.com/marak/play.js
>
> > > It needs to be able to playback wav files of various quality, and maybe
> > even
> > > mp3s.
>
> > > It needs to work cross-platform ( mac / and linux is good enough for now
> > ).
>
> > >https://github.com/bmeck/node-sfmllookslike a promising start, you

Marak Squires

unread,
May 9, 2011, 1:52:33 AM5/9/11
to nod...@googlegroups.com
I would suggest people try to collaborate. I think if we all pool our knowledge we can make this happen. If it's a team effort that brings forth a good module, I don't see any harm in sharing the bounty. 

Let's see what happens :-)

Jeroen Janssen

unread,
May 9, 2011, 2:05:11 AM5/9/11
to nodejs
Hi,

I just updated the implementation with a *synchronous* play
implementation. So you'll actually be able to start audio from
javascript now.

For the rest, I'll look at the example links provides and head out to
work now, so more of this later tonight if nobody beats me to it.

Best regards,

Jeroen Janssen

On May 9, 7:52 am, Marak Squires <marak.squi...@gmail.com> wrote:
> I would suggest people try to collaborate. I think if we all pool our
> knowledge we can make this happen. If it's a team effort that brings forth a
> good module, I don't see any harm in sharing the bounty.
>
> Let's see what happens :-)
>
> > > > withhttps://github.com/tmpvar/node-irrklangforaudioplayback. It
> > requires
> > > > > 32bit node, is macos only, and irrklang doesn't have a very
> > > > > permissive license. I'm very grateful that tmpvar was able to make
> > > > > node-irrklang for our JSONloops project in such a limited timespace,
> > but
> > > > > it's time to replace it with something else.
>
> > > > > I'm paying $100 cash ( from my own pocket ) to the first person who
> > can
> > > > > deliver a cross-platform audio playback for node that can be
> > installed
> > > > via
> > > > > npm ( without any additional downloads outside of npm install foo ).
>
> > > > > It needs to expose an API simply enough that I can use this library
> > to
> > > > > consume it:https://github.com/marak/play.js
>
> > > > > It needs to be able to playback wav files of various quality, and
> > maybe
> > > > even
> > > > > mp3s.
>
> > > > > It needs to work cross-platform ( mac / and linux is good enough for
> > now
> > > > ).
>
> > > > >https://github.com/bmeck/node-sfmllookslikea promising start, you

Jeroen Janssen

unread,
May 9, 2011, 2:09:37 AM5/9/11
to nodejs
Hi,

Two more things, how much audio files do you want to play in parallel?

From the SDL_mixer documentation I got that I need to use multiple
channels to do concurrent audio and have notifications per channel
when it's done. There is a default amount of channels that can be
changed if you want more concurrent audio happening.

Did anyone have a chance of checking if node-sdlmixer also works on a
Mac?

Best regards,

Jeroen Janssen

On May 9, 7:52 am, Marak Squires <marak.squi...@gmail.com> wrote:
> I would suggest people try to collaborate. I think if we all pool our
> knowledge we can make this happen. If it's a team effort that brings forth a
> good module, I don't see any harm in sharing the bounty.
>
> Let's see what happens :-)
>
> > > > withhttps://github.com/tmpvar/node-irrklangforaudioplayback. It
> > requires
> > > > > 32bit node, is macos only, and irrklang doesn't have a very
> > > > > permissive license. I'm very grateful that tmpvar was able to make
> > > > > node-irrklang for our JSONloops project in such a limited timespace,
> > but
> > > > > it's time to replace it with something else.
>
> > > > > I'm paying $100 cash ( from my own pocket ) to the first person who
> > can
> > > > > deliver a cross-platform audio playback for node that can be
> > installed
> > > > via
> > > > > npm ( without any additional downloads outside of npm install foo ).
>
> > > > > It needs to expose an API simply enough that I can use this library
> > to
> > > > > consume it:https://github.com/marak/play.js
>
> > > > > It needs to be able to playback wav files of various quality, and
> > maybe
> > > > even
> > > > > mp3s.
>
> > > > > It needs to work cross-platform ( mac / and linux is good enough for
> > now
> > > > ).
>
> > > > >https://github.com/bmeck/node-sfmllookslikea promising start, you

Jacob Chapel

unread,
May 9, 2011, 2:23:18 AM5/9/11
to nod...@googlegroups.com

I will post the library tonight. The timing issue wasn't really an issue. I can't say my stuff will be perfect, but at least it is a foundation that can be built on and improved.

Derek Gathright

unread,
May 9, 2011, 3:50:59 AM5/9/11
to nod...@googlegroups.com
Would someone be so kind as to make a test for me that checks latency.

When I was testing latency for the afplay script, I was just taking a start time and measuring the distance since the start of each exec() call.  Not sure how useful it would be in C-land though.

var start = new Date().getTime();

module.exports.sound = function(path, callback){
    var exec = require('child_process').exec;       
    console.log(new Date().getTime() - start);

    exec('afplay ' + path, function () {
        if (callback) callback();
    });
}

Like Marak experienced, ms latency got pretty high at 10 tracks.

$ node play.js
8
9
11
17
22
26
51
67
152
212
 

Floby

unread,
May 9, 2011, 5:46:45 AM5/9/11
to nodejs
quick question Jacob, are you using other bindings to parse audio
files or are you using only wave files?

On May 8, 11:41 pm, Jacob Chapel <jacob.cha...@gmail.com> wrote:
> I'm working on it, it isn't an easy problem, but hopefully what I make
> solves the issue at hand. Wish I had more time today, but I have to
> get some sleep since I work nights. I want to get default playback
> fire and forget style going, and I will release it.
>
> On May 8, 2:37 pm, Marak Squires <marak.squi...@gmail.com> wrote:
>
>
>
>
>
>
>
> > I've been trying to make this work for over a year, please excuse my sour
> > attitude about high latency audio playback using child processes.
>
> > :-)
>
> > On Sun, May 8, 2011 at 2:33 PM, Derek Gathright <drg...@gmail.com> wrote:
> > > I don't disagree you need C bindings, it's the right way to do it.  Just
> > > offering up a temp hack, which it appears you already knew about. :)
>
> > > On Sun, May 8, 2011 at 2:26 PM, Marak Squires <marak.squi...@gmail.com>wrote:
>
> > >> Audio playback with anything greater then 18ms latency is pretty much
> > >> unacceptable, even that is high.
>
> > >>  Now imagine you are playing 16 tracks at once, still all need to be <
> > >> 18ms. :-\
>
> > >> On Sun, May 8, 2011 at 2:26 PM, Marak Squires <marak.squi...@gmail.com>wrote:
>
> > >>> *cough* that doesn't work.
>
> > >>>https://github.com/Marak/play.js/blob/master/lib/play.js#L50
>
> > >>> The latency is too high, you NEED to use C bindings. I'm not sure how
> > >>> else to say this, I've been trying this for a while. Please prove me wrong.
>
> > >>> On Sun, May 8, 2011 at 2:21 PM, Derek Gathright <drg...@gmail.com>wrote:
>
> > >>>> Though he wanted something native, not just a command line utility
> > >>>>> binding.
>
> > >>>> Oh I know.  But, he's at a hackday, so figured he might be looking for
> > >>>> any working method.  So, here's a solution for OSX.  afplay has been in
> > >>>> since Leopard (2007), so should work on any modern Macbook out there.
>
> > >>>> Took all of 5 minutes to code up.  And no, I don't think this qualifies
> > >>>> for the bounty. :)
>
> > >>>> module.exports.sound = function(path, callback){
> > >>>>     var exec = require('child_process').exec;
> > >>>>     exec('afplay ' + path, function () {
> > >>>>         if (callback) callback();
> > >>>>     });
> > >>>> }
>

Jacob Chapel

unread,
May 9, 2011, 6:20:16 AM5/9/11
to nod...@googlegroups.com
Just wav files using sndfile, though I saw you can use lame or libmad potentially with it.

Jacob Chapel

unread,
May 9, 2011, 6:48:18 AM5/9/11
to nod...@googlegroups.com
Sent a pull request: https://github.com/japj/node-sdlmixer/pull/1

Just added some async code, though it is buggy and needs a lot of work. It is a start. 

I have my portaudio code working pretty reliably, but something with JSONloops causes the audio to play back weird (not to say JSONloops is to blame though), I am still investigating.

Jacob Chapel

unread,
May 9, 2011, 8:35:33 AM5/9/11
to nod...@googlegroups.com
I tried pretty damn hard, but alas, I don't have the knowledge of skills to make this work. I hope someone can do so. I put up what I have done to a repo, patches/forks are welcome. In the end I really just want to see audio be a reality. 


I don't deserve any of the bounty, but I really I was driven to see if I could do it. I learned a lot more about Node than I had already, so that is a good thing. Well worth the time invested. Sorry Marak, I really did want to deliver. 

Bradley Meck

unread,
May 9, 2011, 9:26:49 AM5/9/11
to nod...@googlegroups.com
Ill join the cause tonight. Should be doable in a couple hours, need to figure out how to test latency though.

Jacob Chapel

unread,
May 9, 2011, 9:43:39 AM5/9/11
to nod...@googlegroups.com

One of the big guns joining the fight. Can't wait to see...listen to it.

On May 9, 2011 6:26 AM, "Bradley Meck" <bradle...@gmail.com> wrote:
> Ill join the cause tonight. Should be doable in a couple hours, need to
> figure out how to test latency though.
>

Matt

unread,
May 9, 2011, 10:33:16 AM5/9/11
to nod...@googlegroups.com
I've enjoyed reading this thread, but can someone explain to me the use-case of this?

Matt.

Bradley Meck

unread,
May 9, 2011, 10:38:44 AM5/9/11
to nod...@googlegroups.com
ppl wanting to play music for various things, a nice restful interface would be interesting for parties / making your jukebox.

Nicholas Campbell

unread,
May 9, 2011, 11:19:20 AM5/9/11
to nod...@googlegroups.com
You should take a look at JSONloops to get a use case. Right now it only runs on the Mac afaik. Marak was trying to push the dev of a good cross platform audio module for node so that JSONloops would be able to work cross platform, but also that other people had the ability to use it too for their own purposes.
On Mon, May 9, 2011 at 10:33 AM, Matt <hel...@gmail.com> wrote:
I've enjoyed reading this thread, but can someone explain to me the use-case of this?

Matt.

--

Jacob Chapel

unread,
May 9, 2011, 11:47:13 AM5/9/11
to nod...@googlegroups.com
So I fixed a seg fault (was due to callback code, will have to look into that more), figured out why it was sounding weird with JSONloops, just some settings I had. Now I need to figure out why on small files it is playing them twice in a row, like tick.wav. 

Marak Squires

unread,
May 9, 2011, 12:48:45 PM5/9/11
to nod...@googlegroups.com
Aye, exactly. 

Also, I think getting solid audio support is one of the first baby steps in building full featured desktop apps in node.

- Marak

On Mon, May 9, 2011 at 8:19 AM, Nicholas Campbell <nicholas....@gmail.com> wrote:

Marak Squires

unread,
May 9, 2011, 12:58:22 PM5/9/11
to nod...@googlegroups.com
I'd like to be able to support  at least 16 tracks, which means 16 concurrent sounds playing. 

32 / 64 / 128 would obviously be way better. :-)

Jeroen Janssen

unread,
May 9, 2011, 12:58:59 PM5/9/11
to nodejs
Hi,

I've pushed some updates to https://github.com/japj/node-sdlmixer
(thanks to Jacop Chapel for his initial go at the aync playing of the
audio).

I can now play sound asynchronous with/without callbacks from
javascript using SDL_mixer.

There is still a lot left to do (so it is by no means finished yet).

At the moment there is a limit to 8 sounds 'at the same time' (atleast
on my pc) and there is no channel management yet,
meaning that depending on the length of the audio some channels will
get reused and stop previous playing audio.

I also had a callback 'segfaulting' problem but I solved it although I
am not sure if the current solution is 'the right' one.

Best regards,

Jeroen Janssen
> > > > > >https://github.com/bmeck/node-sfmllookslikeapromising start, you

Marak Squires

unread,
May 9, 2011, 1:05:24 PM5/9/11
to nod...@googlegroups.com
Nice! I'll do some testing after I get out of work today, will let you know how I make it.

Elijah Insua

unread,
May 9, 2011, 1:07:34 PM5/9/11
to nod...@googlegroups.com
what was the problem with node-sfml?

-- Elijah

Marak Squires

unread,
May 9, 2011, 1:26:33 PM5/9/11
to nod...@googlegroups.com
I didn't see any problems with it, I was hoping someone would tie it all up in a nice package. That was kinda my original request, to just bundle it into an npm package without any external deps.

I wanted to create a one liner installer, it seems with sfml you need to download a few things outside of the npm process?

Elijah Insua

unread,
May 9, 2011, 1:34:30 PM5/9/11
to nod...@googlegroups.com
On May 9, 2011, at 12:26 PM, Marak Squires wrote:

I didn't see any problems with it, I was hoping someone would tie it all up in a nice package. That was kinda my original request, to just bundle it into an npm package without any external deps.

got ya

I wanted to create a one liner installer, it seems with sfml you need to download a few things outside of the npm process?

yeah, just some deps that you can probably satisfy with brew/macports/apt/etc

-- Elijah

Bradley Meck

unread,
May 9, 2011, 2:27:30 PM5/9/11
to nod...@googlegroups.com
SFML is painful to install but once you get it working its fine and integrates well with node. I semi-automated install on it, but there are a lot of build edge cases I don't have covered.

Marak Squires

unread,
May 9, 2011, 2:42:24 PM5/9/11
to nod...@googlegroups.com
Aye, that's exactly what I figured. I wanted to solve the edge cases and bundle the source so regular people who don't know much about dragon-land ( like me ) can one line install it.

On Mon, May 9, 2011 at 11:27 AM, Bradley Meck <bradle...@gmail.com> wrote:
SFML is painful to install but once you get it working its fine and integrates well with node. I semi-automated install on it, but there are a lot of build edge cases I don't have covered.

--

Elijah Insua

unread,
May 9, 2011, 3:13:27 PM5/9/11
to nod...@googlegroups.com
So the deps appear to be included in sfml.  I've updated the install script so that it will properly install on OSX


I have a tiny example (https://gist.github.com/963170) that no longer explodes, but it doesn't play any sounds.

@Bradley, have you experienced this problem?

-- Elijah

Marak Squires

unread,
May 9, 2011, 3:16:13 PM5/9/11
to nod...@googlegroups.com
Ohhhh shitttttt, looks like its getting close! 

tmpvar is on the case!

Bradley Meck

unread,
May 9, 2011, 3:17:27 PM5/9/11
to nod...@googlegroups.com
mmm doesnt play sounds... odd. anywho cant work on it til later.

Aaron Krill

unread,
May 9, 2011, 3:22:14 PM5/9/11
to nod...@googlegroups.com
-cough-Qt bindings-cough-

Elijah Insua

unread,
May 9, 2011, 3:29:52 PM5/9/11
to nod...@googlegroups.com
Fixed, looks like sfml doesn't add any callbacks into the event loop to keep node alive.  so it just dies before it gets a chance to play the sound.

updated gist: https://gist.github.com/963170 -- works!

@Bradley, pull request forthcoming

-- Elijah


On May 9, 2011, at 2:17 PM, Bradley Meck wrote:

mmm doesnt play sounds... odd. anywho cant work on it til later.

Stephen Belanger

unread,
May 9, 2011, 3:30:32 PM5/9/11
to nod...@googlegroups.com
Ha, if only. Various UI toolkit libs would be awesome.

Personally I would've just redone JSONloops with TopCube, then you could use the <audio /> element in webkit and control it via websockets. Then you could do cool stuff like EQ in canvas. :)

Stephen Belanger

unread,
May 9, 2011, 3:32:10 PM5/9/11
to nod...@googlegroups.com
Err...meant spectrum graph, not EQ. Brain no workie this morning. >.>

Marak Squires

unread,
May 9, 2011, 3:32:55 PM5/9/11
to nod...@googlegroups.com
Would this mean you could use the same code for a UI on both server and client? I like that idea, but the idea of using one of Tim's unsupported library spikes for a major project ( without having the knowledge to modify tim's lib ) isn't really an option for me.

Marak Squires

unread,
May 9, 2011, 3:33:10 PM5/9/11
to nod...@googlegroups.com
Did tmpvar get the prize with a 10 line commit?!!?!?!? :-D

On Mon, May 9, 2011 at 12:29 PM, Elijah Insua <tmp...@gmail.com> wrote:

Stephen Belanger

unread,
May 9, 2011, 3:37:42 PM5/9/11
to nod...@googlegroups.com
I've been playing around with it and it seems pretty stable. I made a bunch of accessory apps with it like a direct window to futon. It seems to support everything quite well. I played around with canvas a bit. No WebGL though, which I was kind of hoping for. Maybe in a future version.

Marak Squires

unread,
May 9, 2011, 3:40:22 PM5/9/11
to nod...@googlegroups.com
A bit off topic, but I think the better approach for JSONloops for now is to bring Audio playback to the browser versus bringing the UI to the server. Either way, I would be super amped to see any pull requests for JSONloops. 

Jeroen Janssen

unread,
May 9, 2011, 4:59:00 PM5/9/11
to nodejs
Hi,

Hello,

I've pushed node-sdlmixer 0.0.1 to the npm registry.

On my local machine the following works now:
(note I have SDL + SDL_Mixer development packages installed for the
required build dependencies)

npm install node-sdlmixer

and the demo:

$ node
> var p = require("node-sdlmixer");
Opened audio at 22050 Hz 16 bit stereo
numChannels[32]
> p.play("github/node-sdlmixer/wavs/alarm.wav");
Loading github/node-sdlmixer/wavs/alarm.wav
'github/node-sdlmixer/wavs/alarm.wav'
> Playing on channel[1]
Done

I'm not sure what else is coming out of this thread, but I plan to fix
some of the remaining TODO's later this week.
(and hopefully will fill in some of the remaning gaps in my nodejs
addon development knowledge).
It is a fun and interesting learning experiment, regardless of whether
it will actually be used or not.

I did not see anyone confirm it yet, so I am wondering if it works on
a Mac (can someone verify/try it?).

Best regards,

Jeroen Janssen

On May 9, 6:58 pm, Jeroen Janssen <jeroen.jans...@gmail.com> wrote:
> Hi,
>
> I've pushed some updates tohttps://github.com/japj/node-sdlmixer
> > > > > > >https://github.com/bmeck/node-sfmllookslikeapromisingstart, you

Elijah Insua

unread,
May 9, 2011, 5:08:18 PM5/9/11
to nod...@googlegroups.com

ill try in 5

Elijah Insua

unread,
May 9, 2011, 5:25:03 PM5/9/11
to nod...@googlegroups.com
Jeroen,

Looks like it works! nice!

I've sent you a pull request that updates the README to include mac installation instructions.

-- Elijah

Jeroen Janssen

unread,
May 9, 2011, 5:35:07 PM5/9/11
to nodejs
Hi,

Thanks for testing it!
I'm glad it works on a Mac aswell since I could not test it myself.

I pulled in the update to the README.

Best regards,

Jeroen Janssen

Marak Squires

unread,
May 9, 2011, 10:13:33 PM5/9/11
to nod...@googlegroups.com
Hello Everyone -

I'll be reviewing this thread and all the libraries linked for a possible solution in a few hours. In the case that we have more then one working implementation, I'll figure out a fair solution and present it to the group for approval.

I really appreciate everyone who has been participating in this thread, this is awesome! 

- Marak

Jeroen Janssen

unread,
May 10, 2011, 2:20:28 AM5/10/11
to nodejs
Hi,

Apparently something from my build environment (and in my .gitignore)
ended up in the npm publish which caused problems for some people. I
upgraded to the latest npm and basically published version 0.0.2
tagged tar.gz from github instead from my local tree.

All in all, I would like to thank you for the idea of getting this
started. While trying to get this working I have learned a lot about
nodejs development.

It's almost a bit like the ruby weekly quiz, where someone poses a
problem and people can have a go at it and learn from each other.
Maybe this could be done on a regular basis (regardless of whether
there is a 'prize' at the end).

Best regards,

Jeroen Janssen

On May 10, 4:13 am, Marak Squires <marak.squi...@gmail.com> wrote:
> Hello Everyone -
>
> I'll be reviewing this thread and all the libraries linked for a possible
> solution in a few hours. In the case that we have more then one working
> implementation, I'll figure out a fair solution and present it to the group
> for approval.
>
> I really appreciate everyone who has been participating in this thread, this
> is awesome!
>
> - Marak
>
> ...
>
> read more »

Floby

unread,
May 10, 2011, 7:12:18 AM5/10/11
to nodejs
your package name should be just sdlmixer, not node-sdlmixer. I'm
testing it right now. Will tell you how it turns out

Floby

unread,
May 10, 2011, 7:26:47 AM5/10/11
to nodejs
Jacob, is it safe to call a read in the portaudio callback?
https://github.com/chapel/node-pa/blob/master/nodepa.cc#L148
I think this should cause a lot of latency.
The portaudio documentation says that any I/O or system calls should
be avoided in the callback. the audio data should be buffered.

On May 9, 5:47 pm, Jacob Chapel <jacob.cha...@gmail.com> wrote:
> So I fixed a seg fault (was due to callback code, will have to look into
> that more), figured out why it was sounding weird with JSONloops, just some
> settings I had. Now I need to figure out why on small files it is playing
> them twice in a row, like tick.wav.
>
> On Mon, May 9, 2011 at 8:19 AM, Nicholas Campbell <
>
>
>
>
>
>
>
> nicholas.j.campb...@gmail.com> wrote:
> > You should take a look at JSONloops to get a use case. Right now it only
> > runs on the Mac afaik. Marak was trying to push the dev of a good cross
> > platform audio module for node so that JSONloops would be able to work cross
> > platform, but also that other people had the ability to use it too for their
> > own purposes.
>
> > - Nick Campbell
>
> >http://digitaltumbleweed.com
>
> > On Mon, May 9, 2011 at 10:33 AM, Matt <hel...@gmail.com> wrote:
>
> >> I've enjoyed reading this thread, but can someone explain to me the
> >> use-case of this?
>
> >> Matt.
>

Derek Gathright

unread,
May 10, 2011, 9:20:20 AM5/10/11
to nod...@googlegroups.com
I initially ran into some sdl_mixer issues, so removing those packages and reinstalling (via brew) fixed the issue. 

I just tried again and everything worked fine.  This is so cool.

Jacob Chapel

unread,
May 10, 2011, 11:25:57 AM5/10/11
to nod...@googlegroups.com

Sometimes yeah, but in trying it out there wasn't any perceptible latency. Though I switched to their blocking style code since node is backgounding the code already.

There is an issue with playback of different sizes, to use the callback method, it has to sleep the main thread. If you sleep to long small files repeat, too short of sleep and long files get cut off. That's why I moved to the blocking style.

I'm open for suggestions. My c/c++ fu is weak atm.

Djordje Lukic

unread,
May 10, 2011, 8:42:03 AM5/10/11
to nodejs
Hello everyone,

Here is my shiny turd: https://github.com/rumpl/naudio

It uses libvlc for audio playback. The code is ugly as hell since I
stopped the moment I could play a .wav file (I guess it could
play .mp3 or ogg files as well since it's, you know, VLC) and a web
radio (see https://github.com/rumpl/naudio/blob/master/test.js).

Moreover the wscript is not good, I'm putting an absolute path to the
libvlc folder so if you want to test it, you must edit that file.
If anyone wants to fork it and help me make something that resembles a
real node library for audio playback, well then, you are welcome.

A side note: I'm not doing this for the bounty, just for fun (and
anyway you have to have an easy installer which I don't).

Cheers.

On 10 mai, 13:26, Floby <florent.j...@gmail.com> wrote:
> Jacob, is it safe to call a read in the portaudio callback?https://github.com/chapel/node-pa/blob/master/nodepa.cc#L148

Marak Squires

unread,
May 10, 2011, 8:04:36 PM5/10/11
to nod...@googlegroups.com
I'm still reviewing all the libraries. My schedule during the week is a bit out of control. 

I'll be posting my results as soon as I can, thank you! In the mean-time, I'd be interested to hear other peoples results trying these libraries across various systems.

- Marak

Floby

unread,
May 11, 2011, 6:20:21 AM5/11/11
to nodejs
I wonder why I havent thought about libvlc sooner. It's multiplatform,
handles a lot of different formats and playback on its own. I'm
forking it right now =)

On May 10, 2:42 pm, Djordje Lukic <lukic.djor...@gmail.com> wrote:
> Hello everyone,
>
> Here is my shiny turd:https://github.com/rumpl/naudio
>
> It uses libvlc for audio playback. The code is ugly as hell since I
> stopped the moment I could play a .wav file (I guess it could
> play .mp3 or ogg files as well since it's, you know, VLC) and a web
> radio (seehttps://github.com/rumpl/naudio/blob/master/test.js).

Jeroen Janssen

unread,
May 11, 2011, 6:59:22 AM5/11/11
to nodejs
Hi,

A solution based on libvlc might actually be a very good choice than
something like SDL_mixer, since vlc has very rich media support (and
indeed also supports streaming playback).

Although, if you only need wav file playing, it might be a bit
'overkill'.

I'll fork it too and see if I can play with it aswell.

Best regards,

Jeroen Janssen

Linus G Thiel

unread,
May 11, 2011, 7:07:51 AM5/11/11
to nod...@googlegroups.com
I'm pretty sure libvlc is GPL? I think that rules out an MIT licensed
library, as Marak requested. Otherwise, I think libmad and libao also
would have been good candidates, as they seem to have pretty nice
APIs.

--
Linus G Thiel
Hansson & Larsson
http://hanssonlarsson.se/
+46 709 89 03 85

Jeroen Janssen

unread,
May 11, 2011, 8:02:39 AM5/11/11
to nod...@googlegroups.com
Ah,

Indeed that would rule out libvlc from the list.

Maybe an alternative would be ffmpeg bindings? http://www.ffmpeg.org/

Best regards,

Jeroen Janssen

Djordje Lukic

unread,
May 11, 2011, 8:21:41 AM5/11/11
to nod...@googlegroups.com
I agree with you Jeroen that using libvlc is an overkill for what was asked but I found it sooo cool to be able to listen to shoutcast radios using node.

I am not sure that libvlc being GPL (version 2 or later) rules it out since the MIT license is GPL-compatible, any lawyers around? :)

I saw your pull request Floby, will look at it tonight, am at work right now.

Cheers
Cordialement
Djordje Lukic
It is loading more messages.
0 new messages