Skip to content

VGM wait commands and accuracy

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

Moderator: Staff

  • ericde45 Offline
  • Posts: 4
  • Joined: 2022-12-27, 17:31:05

VGM wait commands and accuracy

Post by ericde45 »

Hello all,

i'm new here, and of course i come with questions :)

i'm trying to code a VGM player for Atari Jaguar, to replay YM2151 files, as a first step ( there is a lot of x68000 nice tunes on the net)
i already created an Amiga module player, and an YM2149 player so i have good knowledge of Atari Jaguar limitations.

On Jaguar, the audio is managed by a 24 mhz DSP with 8 KB of ram, and 2 x 16 bits DAC. nothing more.
the 'game' when coding on Jaguar, is always to use only the DSP and its local memory to play audio, to avoid using the main memory bus, that is shared.

i doubt that the Jaguar is able to read VGM files are 62500 Hz.
so i thought i could rebuild the VGM file with recalculating waits and alter the emulated YM2151 registers at a lower frequency than 62500 Hz

with the experience you have, what do you think would be an acceptable frequency to read VGM files and still have nearly the same sound as a replay on PC ?

thanks


PS : an example of a atari ST YM replay i created, on Jaguar : https://youtu.be/9iGlcPxtzjY
  • User avatar
  • ValleyBell Offline
  • Posts: 4768
  • Joined: 2011-12-01, 20:20:07
  • Location: Germany

Post by ValleyBell »

VGM files run with an internal tick rate of 44100 Hz. (no idea where you got the 62500 Hz from)

If the music you want to play does not have streamed PCM data, then going as low as 60 Hz can work well.
For streamed PCM (e.g. YM2612 DAC and YM2149 PCM songs) the minimum Hz equals minimum sample rate if the PCM streams. If you play PCM streams with 8 KHz accuracy, you only get 8 KHz audio, etc.
  • ericde45 Offline
  • Posts: 4
  • Joined: 2022-12-27, 17:31:05

Post by ericde45 »

thanks for the answer.
62500 is 4 000 000 hz, clock frequency of the YM2151 for the x68000, divided by 64.
i got that by tracing vgmplay
reading of vgm commands seems done at 62500 Hz, and audio samples created with the core emulation are played at 44100.


so, 60 hz would be unoticed for synthetic instruments, even if that involves a delay in modifying the operators and notes played, compared to VGM PC replay.
i'll go that way. 60 Hz and something like 20KHz for samples calculations seem reachable on Jaguar
  • User avatar
  • ValleyBell Offline
  • Posts: 4768
  • Joined: 2011-12-01, 20:20:07
  • Location: Germany

Post by ValleyBell »

ericde45 wrote:reading of vgm commands seems done at 62500 Hz, and audio samples created with the core emulation are played at 44100.
You got that just the wrong way around.

VGMs are always read at 44100 Hz. (Quote from the specification: "VGMs run with a rate of 44100 samples per second")
The sound cores may output other sample rates (e.g. 62500 Hz) and that is resampled to whatever your final output sample rate is. (usually 48000 or 44100 Hz)
  • ericde45 Offline
  • Posts: 4
  • Joined: 2022-12-27, 17:31:05

Post by ericde45 »

yes, i digged it, following your answer, and you're obviously right.

i think i will create a convert code in C, to pack vgm commands together, according to my vgm commands reading frequency.

i'd like to first check that, for example, if i go to 60 Hz to read VGM commands, i don't have too many writes to the same register of the YM2151, in the same block.

if so, i will have to increase to more than 60 Hz

and i'll have another process, to create samples at something like 16000 Hz ( i was able to reach 54 KHz for Amiga modules )
Post Reply