Question

With this emulator http://www.codebase.es/jsgb/ I did this project https://github.com/rafaelcastrocouto/gbonline.

Now I want to emulate the sounds and music with the html5 audio API, but I have no idea where to start. I've looked at the emulator code and the manual but I'm far from understanding what's going on there.

Emulator code: https://github.com/rafaelcastrocouto/gbonline/blob/gh-pages/script.js Manual: http://nocash.emubase.de/pandocs.htm

Can you guys explain me how it should be done, maybe some pseudo code???

Was it helpful?

Solution

I found out that there are four ways to get sound out of emulator described in the Pan Docs referenced to in credits section Codebase. Inside the Pan Docs section of I/O Ports is a chapter named Sound Controller. There is written:

There are two sound channels connected to the output terminals SO1 and SO2. There is also a input terminal Vin connected to the cartridge. It can be routed to either of both output terminals. GameBoy circuitry allows producing sound in four different ways:

  • Quadrangular wave patterns with sweep and envelope functions.
  • Quadrangular wave patterns with envelope functions.
  • Voluntary wave patterns from wave RAM.
  • White noise with an envelope function.

So it's necessary to implement audio workers that match the characteristic of the previous list. For example using a library like Flocking, and build for each way sound can be created one synthesis matching the details in the following sections of that article.

After finishing that step an extension of script.js in your Git repo is necessary (like the other registers starting at line 240) to connect sound registers. Those registers need to trigger and select the appropriate synthesizer.

Hope this will help a bit.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top