GB PCM Converter

From GameBrew
GB PCM Converter
Gbpcmconverter.png
General
AuthorLeaf
TypePC Utilities
Version2015
LicenseMixed
Last Updated2015/09/12
Links
Download
Website

A PC program for converting WAV files to PCM format.

Requires .NET Framework, which can be obtained through Windows Update.

User guide

Converting WAV to PCM

You can either select a file using the "Ref" button or drag and drop a WAV file, and the selected file will be displayed. If you check the output option in that state and press the "Output" button, it will generate a PCM file suitable for the Game Boy.

Only RIFF WAV that can be played on Windows is supported. The tool lacks advanced processing features, so it is recommended to use proper audio waveform editing software to apply noise reduction or other processing before using this conversion tool.

Downsampling, such as 22050Hz to 4096Hz, is (in theory) possible, but upsampling, like 2048Hz to 4096Hz, is not supported.

When the PCM driver writes 4-bit data to the register at a time, there is a trick technique that if you set the envelope flag at the same time as the data and write it, the petit noise can be reduced somewhat, and this is flagged in advance on the data side.

Most of the settings are self-explanatory, but if you set it to 1data/1byte, you have the sub-option "set bit3=1". This is because when the PCM driver writes data to the register 4 bits at a time, it sets the envelope flag at the same time as the data and writes it. This is a technique that can reduce minor noise to some extent, and this is flagged in advance on the data side.

Setting $00 as the data end will replace any data $00 with $01, slightly affecting the audio quality. However, with 1data/1byte and bit3=1 setting, the data $00 becomes $08 (with no impact on audio quality), so this replacement won't occur.

The "16-byte align" check is useful when using PCM with the waveform memory sound source, as it operates on 16-byte (32 data) units. And you should check this option when using waveform memory PCM.

If using the data with GBMC, keep the initial settings (4096Hz, 2data/1byte, 16byte align) and convert as it is.

Regarding the "3bit PCM" option, please refer to the following section for more information. If you convert audio to 3bit PCM, the same data will be output for both the L and R channels. Although it's possible to separate them for 2-channel PCM or stereo playback, it is not very practical (other sounds cannot be played during PCM playback). Therefore, this feature has been omitted.

When using 3bit PCM, the data end is $FF, so the "set $00 as an data end" option is meaningless.

Keep in mind that the data format resulting from adjusting these settings will ultimately depend on the specifications of your playback program. Therefore, it's best to process the data in a way that is most convenient for your purposes.

3-bit PCM Playback with Master Volume

In an attempt to improve the audio quality, a new method for 3-bit PCM playback with Master Volume on the Game Boy was explored. In the previous method, PCM playback involved adjusting volume registers for each channel and using 4-bit waveform data. However, the Master Volume register (NR50) provides an alternative way to adjust waveform output.

The Master Volume register format is as follows:

  NR50: 7 6 5 4 3 2 1 0
        0 L L L 0 R R R
bit6-4: Left output volume
bit2-0: Right output volume

As the final stage of output, this method may offer better resistance to minor noise compared to previous techniques of manipulating volume registers for individual channels. With 3-bit, we can only use 8 levels of volume (from 0 to 7), and the same volume data is written for both left and right channels. The playback source is Channel D, the noise channel, which is initialized as follows:

  • [rNR41] $FF - Length register (not particularly relevant).
  • [rNR42] $08 - Set the envelope direction to upwards, and the volume to 0.
  • [rNR43] $00 - Noise frequency.
  • [rNR44] $BF - The length register is not used, and the key is turned on without using it.

The provided source code and GBROM image (pcm2.zip) enable audio playback at 8192Hz, resulting in clearer sound quality. However, using the master volume control means it's not possible to synchronize playback with background music (BGM).

The source code supports 8192Hz/3bit/2data1byte data playback. If it is set to 1data/1byte, the 3-bit PCM data is output as 0nnn0nnn so that it can be easily written to the register in advance. The "set bit3=1" option should not be checked.

The tool automatically adds $FF at the end of the data. In the source code, playback continues until it encounters $FF.

Note that the variable positioning of PCM has not been tested yet.

Splitting LSDJ Drum Kits

LSDJ has a feature to play 4-bit PCM, and many drum kits have been made available for this purpose. According to the specification, up to 15 PCM files can be defined for one drum kit. Using the "Kit" function, you can split these kits into individual PCM files.

To do this, select an LSDJ drum kit file (*.kit) using the [Ref] button or by dragging and dropping it onto the interface. The selected file will be displayed. Pressing the [Kit] button will output the PCM files contained in the drum kit.

If the "same as source" option is checked, the files will be simply split without any additional processing. No sample rate conversion will be applied. The resulting data will be in the format of 2data/1byte, no end data or 16-byte alignment.

If either "4096Hz" or "8192Hz" is checked, it will be downsampled and output (for GBMC). The format will be 2 data/1 byte, no end data, and with forced 16 byte alignment. Considering the original sampling rate is 11,468Hz, converting to 4096Hz or 8192Hz might lead to some loss, but sometimes we just have to make do with what we can use.

The file names will generally be the original file name + the internal sample name within the kit (3 characters). If there is a loop specified, "_Loop" will be added to the file name. To avoid issues with duplicate sample names, sample numbers will be added for distinction if necessary.

Since the checks are lenient, some files with unusual headers might not be converted properly. However, as long as they are usable in LSDJ, it should generally work fine. The header information was referenced from Little Sound Dj Wiki.

Screenshots

gbpcmconverter.png

External links

Advertising: