r/javascript • • Dec 27 '17

SoundJS - a Javascript library for working with Audio. It provides a consistent API for loading and playing audio on different browsers and devices. Currently supports WebAudio, HTML5 Audio, Cordova / PhoneGap, and a Flash fallback

https://github.com/CreateJS/SoundJS
350 Upvotes

31 comments sorted by

33

u/VeryAngryBeaver Dec 27 '17

That's a surprise, I work at gskinner the company behind this library. If there's any questions or comments I'll try to answer them or pass it along to the developers maintaining the library.

8

u/rift95 map([🐮, 🥔, 🐔, 🌽], cook) => [🍔, 🍟, 🍗, 🍿] Dec 27 '17

What does gskinner do?

7

u/VeryAngryBeaver Dec 27 '17

Crazy weird cool things on the web, by request. Or just tools we think are handy. Check out our website

3

u/Craiger23 Dec 28 '17

cool home page, how was that moving image built? is it just a mp4 video created in an adobe app? (my guess)

3

u/kingromes Dec 28 '17

The site uses a video, however it is a recording of this experiment by Grant Skinner in the gskinner lab. It is a canvas-based music visualizer (using EaselJS), which is transformed using CSS3d. Glad you like it!

1

u/Craiger23 Dec 28 '17

I do, as a web developer I always liked that on pages and try to incorporate it myself when applicable.

1

u/ryanmatt0814 Dec 28 '17

I really like the text parallax on the gskinner site. would you happen to know how it's done?

2

u/[deleted] Dec 27 '17

Hey dude. Been using Easel / CreateJS for a few years now after departing from Flash.

Any cool new stuff in the pipeline?

4

u/kingromes Dec 28 '17

We are also working on complete refactors of SoundJS and PreloadJS in ES6. CreateJS is 6 or 7 years old, and a lot of the workarounds, plugins, and polyfills we used to use are no longer necessary. We are aiming to simplify the API and codebase, and ideally add a bunch of new features, such as advanced web audio access.

1

u/[deleted] Dec 28 '17

Yeah good stuff. I've switched to Phaser for some new stuff but a lot of existing work is Easel and still has new content added to it monthly.

Looking forward to Easel updates!

3

u/VeryAngryBeaver Dec 27 '17

Personally I am updating StageGL to support blend modes and some filter pipeline upgrades. Around the office we're seeing what we can do about es6 builds of the libraries. Not to mention we've recently consolidated to a 1.0 release, but I think some paperwork is holding up an official announcement.

Glad we could help.

3

u/[deleted] Dec 27 '17

The 1.0 release did not go unnoticed! I've been working to update my stuff to work from 0.6 to 1.0 since I'm woefully behind.

2

u/invisibo Dec 28 '17

I am super excited for StageGL to take hold for the performance boost. I tried converting one of my main projects to using StageGL a few months ago, but I ran into weird problems out of the norm. I know it's still not ready for production, so I reverted and let it be.

2

u/VeryAngryBeaver Dec 28 '17

I'm working on fixing that. If you feel the need you can hit me up directly with a bug report and repo steps as I'm the StageGL guy.

1

u/invisibo Dec 28 '17

Absolutely noted! On the official release, I will definitely attempt to switch over again. There was a huge performance gain on the parts that worked flawlessly. Thanks!

3

u/Nol188 Dec 27 '17

This is cool, thanks for sharing

3

u/Lakelava Dec 28 '17

Does it add support to codecs the browser doesn't have? If yes, are those codecs added with web assembly?

4

u/kingromes Dec 28 '17

As someone pointed out in this thread, SoundJS doesn't do anything the browser can't already do -- it just simplifies the API, handles browser issues, and assists with determining what file formats can play (etc).

Supporting additional codecs is definitely not on the roadmap at this time, though it is an interesting idea.

-5

u/chabv Dec 28 '17

you lost me on Flash!

0

u/[deleted] Dec 27 '17

[deleted]

15

u/ben174 Dec 27 '17

If you’re streaming audio, you’re probably not gonna notice the 60k lib.

20

u/gieter Dec 27 '17

Not bad for a crossbrowser compatible api. Not everyone had a modern browser.

0

u/[deleted] Dec 27 '17

[deleted]

1

u/gieter Dec 27 '17

60 vs 30 is nothing compared to the cost of finding and fixing crossbrowser issues the library should have done for you.

Also Howler does not have IE8 support and soundjs does. Granted, that should not be a requirement these days.

2

u/brown59fifty Dec 28 '17

This doesn't support IE8 either. Fixing crossbrowser issues? What issues? it's just wrapper around HTML5 APIs, which every browser supported by this lib (so IE9+) support well, and it provides nothing more than native functionalities. It's probably good lib for those who are using that CreateJS ecosystem and want to wrote consistent code, but for everyone else it's a waste of memory.

Sorry if I'm wrong, but that's how it looks like...

5

u/kingromes Dec 28 '17

When SoundJS was released (2010/2011), there was no HTML5 or WebAudio, so it wrapped HTML tag audio, as well as a Flash-based solution (which was left in to help older browsers). It also works as a plugin for more advanced preloading scenarios with PreloadJS. Tag-based audio is a beast that we will be glad to get rid of in a future release. Every browser had quirks and issues, and a ton of work went into supporting all of them (as well as things like Audio Sprites to get around mobile limitations).

WebAudio and PhoneGap/Cordova support was also added over the years. They aren't part of the main library (and don't add to the bloat), but there are things necessary in the main library to facilitate the plugin architecture.

I don't disagree with the main point though. SoundJS has become a bit bloated, and with the well-supported WebAudio API being available pretty much everywhere, the next major release should see a reduction in filesize.

(source: I manage a lot of this stuff @ gskinner)

1

u/brown59fifty Dec 28 '17

I fully understand that! And don't get me wrong, I'm just thinking about using actual version of lib in context of today's world of evergreen browser (not that older versions with backward support).

Thb I'm not a fan of adding more and more external libraries to the project to cover basic functionalities available in browser of out the box... I remember the times when we've got to make hundrets of hack to privide cross-browser compatibility, but now we don't have to. And that's the reason why my opinion someone can get as negative from the beginning ;)

0

u/[deleted] Dec 27 '17

[deleted]

0

u/[deleted] Dec 27 '17

[deleted]

3

u/[deleted] Dec 27 '17

Depends on your target market. Lots of people in Germany have insanely powerful smartphones, but if you're not in a major city, your network connection speed will suck.

0

u/[deleted] Dec 27 '17

[deleted]

3

u/[deleted] Dec 28 '17

I never said that they're from Germany, I said that most Germans have modern smartphones, but shitty network outside of major cities.

0

u/[deleted] Dec 27 '17

[deleted]

13

u/Arve Dec 27 '17 edited Dec 28 '17

Your question is way out of scope for a library like this. The only thing this library is made to do is to provide a cross-browser-compatible means of loading and playing sound.

Analyzing "the pitch of a note in a soundtrack" is a completely nontrivial task. If it's doing something simple like implementing a spectrum analyzer, the WebAudio API or any library that implements it should work. If you're trying to do something like automatically transcribe an arbitrary audio stream to sheet music, you're in for a world of pain plus a bunch of code that you won't find in any audio library anywhere.

(All previous efforts at transcribing music, on any platform, pretty much all suck to the point that it's worthless - this has to do with the very nature of sound. While it's possible to transcribe input from a single instrument like a guitar to then convert to MIDI data, doing so for music with multiple distinct instruments is next to impossible. In either way: There are no libraries that does this for you, and you are going to need to write code from scratch)

4

u/timothyallan Dec 28 '17

Wait, this library doesn't give me a polyphonic Melodyne like feature set in IE8? Totally unusable.

2

u/spoonopoulos Dec 28 '17

It isn’t next to impossible as much as quite complex and of variable utility (depending on the source). There’s a fair bit of literature, mostly in the domain of blind source separation, related to polyphonic transcription and “demixing”, as it were.

2

u/iccir Dec 28 '17

Arve's reply is correct - this is a very hard problem. I don't know of any JS library which implements a solution. That said, if you want to research it, I'd start by searching for "f0 detection" or "f0 estimation". If other music/sound is playing, add "polyphonic" to your search.