More PCM and MOD stuff
Some of you already know, that David Michael of Magic Engine made a MOD player for the PCE. No intermediate step for converting the format or anything. You just include the MOD file inside HuC. The player converts the samples over in realtime, etc. Not optimal at all for PCE, for practical purposes. But I’m sure this would have lead to something more PCE friendly.
It was after experimenting and hearing many examples of MODs playing on this PCE player, that I decided I wasn’t going to do a MOD player. The sound was just too poor for most music examples. At first, I thought it was because the samples were only 5bit. So I hacked the engine to play on a 10bit DAC setup. I soft mixed the channels (4x8bit =10bit, so no clipping). Didn’t really hear any difference. Just really slight here and there. So I figured it must be the low frequency of the TIMER irq. That was probably over a year ago or more. Still, in the back of my mind. It nagged at me…
Fast forward to last spring. Digging through PCE sound engines. Looking them in depth, but also looking at how they do sample playback. Some do 4bit samples, most do 5bit. Some do funny stuff like pseudo frequency scaling like Batman (and more, looping certain parts of a waveform to shorten it. I.e. compress the repeating parts for final waveform shaping). One thing I noticed. Crappier samples tend to sound better when something else is playing at the same time. It helps hide the noise of the sample from the low bitrate and playback rate. But a few games were interesting. Some samples were really clear when played by themselves. Something I didn’t expect. Obviously these better than expect sounding samples must have been preprocessed to sound better for the output than others. I know there’s a few techniques for preprocessing and I’ll not get into that in this post, but that got me thinking (as of doing all this work lately).
So I fired up some of these old MOD pce roms that I had made from DM’s huc source yesterday. Testing them out in different emulators because of the problems I’ve been having with certain ones not outputting sound correctly – with stuff I’ve been doing lately. At last I came to YAME. I overclocked the CPU to 21mhz on a whim. Now, normally – this shouldn’t have any effect. Because all the timing is straight off the TIMER IRQ and when I was looking at the code original, it looked fine on the scaler side. That is to say, it didn’t appear to have any issues with “jitter”. Well, I was wrong. Playing those files in yame as that higher speed, removed all the jitter (or almost all of it). I was impressed by the sound. It fixed quite a few issues that these MODs were having. I also noticed something else. The MODs played slower than normal. I don’t think this had to do with the timer code, but more with DM trying to compensate that most MODs use a BPM of 125. That number is derived from PAL vblank of 50hz (50hz x 60 seconds = 3000 / 6ticks = 500 / 4 lines = 125 BPM). Later on they changed the spec so you could independently change the BPM, which made calculating the real BPM a pain in the ass (kind of useless even naming it “bpm”).
Anyway, his MOD player naturally should have been playing all these modes faster. Since PCE is 60hz vblank rate. 120% faster. But they aren’t. They play about the speed of 100BPM. Not even the correct speed, but slower. I haven’t yet re-looked at the code (and probably won’t), but this also might account for some sound issues. Either way, yame at 21mhz playing these MOD files… this was inspiring. No, it doesn’t rival the Amiga, but the sound is fairly decent/acceptable for what it is.
So with that, I’ve decided to modify my existing XM player (which just a MOD/XM FX/pattern compatible player) to do a 4 channel MOD/XM for long samples. Not something that I’d probably use for dev, but for demo purposes or novelty. Just for fun.