npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gameboy-sound

v0.1.2

Published

Easy 3 kB library for 98% accurate Gameboy audio

Downloads

5

Readme

gameboy-sound

Want some hardware-accurate Gameboy music and sounds in your HTML5 game or app? Don't want to load megabytes of .mp3 files? Overwhelmed or frustrated by the Web Audio API?

Enter gameboy-sound, the easy-to-use module that gives you reasonably hardware-accurate sounds in roughly 3 kilobytes. (min + gzip)

Demo

Try it on StackBlitz! This demonstrates most of the capabilities and commands.

Here is another demo which plays an actual song. Compare to the original!

Goals

gameboy-sound intends to deliver a good balance between size, accuracy, and ease-of-use. Its internals are still fairly accurate to how the real hardware works, but it omits some of the more obscure behavior. From a user's point of view, it uses an easy-to-read function-based API, rather than retaining the old notion of writing to registers on an APU. A user should be able to make some kind of sound happen with just one import statement and one function call.

Browser support

Not thoroughly tested, but Chrome and Firefox seem good. Safari seems to run, but does not always playback correctly.

Acknowledgments

This project started as a fork of Grant Galitz's JavaScript Gameboy emulator. I wanted to play convincing retro sound effects in the browser and decided that starting from a working emulator might be the best place to start. Grant's emulator was an excellent place to start from; its audio emulation is very accurate, and it was also clearly written with performance in mind.

I stripped out all of the components except the basics required to generate sound (no CPU cycles, no opcodes, no sprites, no interrupts, no joypad, no registers, no ROM...) and refactored it to make it easier to understand (from the perspective of both a user and a contributor) as well as minify better (less duplicate code, no large function prototypes)

Eventually, I rewrote the entire project from scratch. Instead of using the deprecated ScriptProcessorNode, the project now creates various AudioBufferSourceNodes for the different samples, and renders playback to OfflineAudioContexts to loop music playback. Only a dozen or so lines of code from the original project remain.

License

MIT