Skip to content

Questions about VGM Chip Volume

Technical discussion about the VGM format, and all the software you need to handle VGM files.

Moderator: Staff

  • Quantam Offline
  • Posts: 24
  • Joined: 2020-03-05, 9:25:23

Questions about VGM Chip Volume

Post by Quantam »

Several things in the wiki (https://vgmrips.net/wiki/VGM_Specification) that need clarification for the chip volume entries:

1. For Chip ID (offset 0): "If bit 7 is set, it's the volume for a paired chip. (e.g. the AY-part of the YM2203)". If we were talking about said AY-part of YM2203, would bits 0-6 say the chip ID was AY-3-9801 or YM2203? And in both cases it would be helpful to have a list of all the chip IDs and their paired chips in the wiki.
2. For volume (offset 2): "If Bit 15 is 0, this is an absolute volume setting. If Bit 15 is 1, it's relative and the chip volume gets multiplied by ((Value & 0x7FFF) / 0x0100)." For relative volume what is being multiplied by the aforementioned formula? Does absolute volume ignore the file header volume (offset 0x7c) while relative volume modifies it, or does this quote mean something else?
3. What is the precise meaning of this measure of volume? E.g. a chip like the YM2203 could potentially have different volume levels from the analog SSG pin and the output of the DAC. Likewise there will be analog mixing, amplification, and filtering hardware outside the chip. Which of these two (or both) are accounted for by the chip volume value?
  • Quantam Offline
  • Posts: 24
  • Joined: 2020-03-05, 9:25:23

Post by Quantam »

Okay, I've been digging some in the VGMPlay source to try to answer my questions. It's concerning that I learned a variety of things about the file format that are completely absent in the spec (even things unrelated to my questions). Anyway, here's what I've found, which partially answers my questions:

1. The chip ID will be of the containing chip, e.g. YM2203, not the chip contained. And here's a list of chip IDs:

Code: Select all

#define VGM_CID_SN76489 0u
#define VGM_CID_YM2413 1u
#define VGM_CID_YM2612 2u
#define VGM_CID_YM2151 3u
#define VGM_CID_SEGA_PCM 4u
#define VGM_CID_RF5C68 5u
#define VGM_CID_YM2203 6u // Paired chip: YM2149 (AY-3-8910)
#define VGM_CID_YM2608 7u // Paired chip: YM2149 (AY-3-8910)
#define VGM_CID_YM2610 8u // Paired chip: YM2149 (AY-3-8910)
#define VGM_CID_YM3812 9u
#define VGM_CID_YM3526 10u
#define VGM_CID_Y8950 11u
#define VGM_CID_YMF262 12u
#define VGM_CID_YMF278B 13u
#define VGM_CID_YMF271 14u
#define VGM_CID_YMZ280B 15u
#define VGM_CID_RF5C164 16u
#define VGM_CID_PWM 17u
#define VGM_CID_AY8910 18u
#define VGM_CID_GB_DMG 19u
#define VGM_CID_NES_APU 20u
#define VGM_CID_MULTI_PCM 21u
#define VGM_CID_UPD7759 22u
#define VGM_CID_OKI_M6258 23u
#define VGM_CID_OKI_M6295 24u
#define VGM_CID_K051649 25u
#define VGM_CID_K054539 26u
#define VGM_CID_HUC6280 27u
#define VGM_CID_C140 28u
#define VGM_CID_K053260 29u
#define VGM_CID_POKEY 30u
#define VGM_CID_QSOUND_DSP16A 31u
#define VGM_CID_SCSP 32u
#define VGM_CID_WONDERSWAN 33u
#define VGM_CID_VSU 34u
#define VGM_CID_SAA1099 35u
#define VGM_CID_ES5503 36u
#define VGM_CID_ES5505_6 37u
#define VGM_CID_X1_010 38u
#define VGM_CID_C352 39u
#define VGM_CID_GA20 40u
2. The basic process of computing volume for each chip goes as follows (in GetChipVolume in VGMPlay.c):
  1. Look up the initial volume in a table of volumes, one for each (containing) chip ID
  2. Perform some parameter-specific hacks for certain chips and systems (e.g. dividing YM2203's AY-3-8910's volume by 2)
  3. Divide the volume value by the number of chips of the given type (1-2)
  4. Apply the volume information from the extended header (it's in Q8 format). For absolute mode, throw out the previously computed volume and use the specified volume. For relative, multiply the computed volume by the relative volume (again in Q8 format).
I still don't have an answer to #3, and I don't think the source code contains the information necessary to deduce the answer as it's not clear WHY the volume numbers used are being used; I really need the help of somebody with a whole lotta knowledge about these chips. The reason it matters to me how much amplification is coming from inside the synth/DAC and how much is coming from analog circuitry is that I'm making a hardware VGM player that uses a bunch of synth chips with a microcontroller and I need to know how to mix the signals that come out of the chips (i.e. I need the external amplification parameters ONLY).
  • User avatar
  • ValleyBell Offline
  • Posts: 4768
  • Joined: 2011-12-01, 20:20:07
  • Location: Germany

Post by ValleyBell »

Sorry for the late response. I was sure I wrote an answer but somehow the post was lost. (maybe clicked the wrong button before closing the tab)
  1. maybe the specification should say "SSG-part of YM2203" to make it more obvious that it is not referring to the AY8910 chip itself
    Yes, the ID is always the ID of the "main" chip.
    Currently there are 4 chips that have "main" and "subordinate" parts: YM2203 (FM + SSG), YM2608 (FM + SSG), YM2610 (FM + SSG), YMF278B (OPL4 PCM + OPL3 FM).
    I don't think the chip volume header works for the OPL4, but since the OPL4 mixes PCM + FM together internally the volume levels are constant across all setups there anyway.
  2. Yeah, it is a pretty complicated process with lots of specific hacks to make all the chip volumes sort of sensible for VGM versions <1.70.
    The chip volume is 7.8 fixed point. (linear scale)
    Regarding file header volume gain: That affects the volume of the final mix only. "Chip volume" controls the volume balance between chips instead.
    Both values are independent from each other.
  3. The volume levels apply a simple scaling factor on whatever the sound chip emulators output. The volume level of the sound chip emulators is unfortunately very arbitrary.
    Chip volume lets you define a per-output amplification. We don't have emulation of actual analog filters right now.
  • Quantam Offline
  • Posts: 24
  • Joined: 2020-03-05, 9:25:23

Post by Quantam »

New question not related to volume: why do YM2203 and YM2608 have fields for embedded AY-3-8910 flags but YM2610 does not?
  • User avatar
  • ValleyBell Offline
  • Posts: 4768
  • Joined: 2011-12-01, 20:20:07
  • Location: Germany

Post by ValleyBell »

Because the MAME emulation hard the flags hardcoded for YM2610, but they could be per-machine for YM2203/YM2608.
Nowadays I consider the YM-specific SSG flags to be obsolete. They only changed very emulation-specifc stuff anyway.
Post Reply