Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gameboy-sound

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gameboy-sound

Easy 3 kB library for 98% accurate Gameboy audio

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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

FAQs

Package last updated on 08 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc