Sampled based synth driver for PCE

Discussion of development of software for any "obsolete" computer or video game system.
Post Reply
Posts: 55
Joined: Thu Oct 31, 2019 12:56 am

Sampled based synth driver for PCE

Post by turboxray » Tue Dec 31, 2019 5:22 pm

I've had this for a number of years and really didn't do anything with it, so I figured I'll make it public. It's a sample based player for the PCE. There are 6 channels total; 4 have frequency scaling and 2 are fixed frequency (7khz). Everything runs off the Timer interrupt, so the base output is 7khz. There's no software mixing, so everything simply gets written to the channel's DAC. The wave data is 5bit, but each channel has hardware volume (so no resolution loss for lower volume), and each channel has the normal PCE stereo panning options.

It's not a music engine or mod player. It just a library with some APIs to make it feel like you have additional hardware support for the PCE. The driver by itself is rather boring without something to show it off, so I hacked together a crappy XM player haha. It literally has thee minimal support for XMs (I think like 3 FX are supported, no envelopes, 4 channels only, etc). It was just enough to get something too use the driver. I have about 5 or 6 songs, already compiled if you just want to check them out. If using an emulator, highly recommend mednafen because other emulators tend to distort 7khz DDA playback. Basically I exported all the wave files and converted them for the driver compatibility (wav2six util), then rip just the core part of XM file without the samples, and incbin that for the player to feed on. Nothing fancy.

Some specs on the driver (not the XM player):
It supports sample forward-looping, but not ping-pong. I still need to make a converter to ping-pong baked into the sample as forward-looping.
Hardware volume for all channels in DAC mode, with stereo panning as well.
This version runs without a buffer, so the ram foot print is really small. It makes it easier to integrate with a PCE projects, but means there's a 6-7% cpu overhead because of this.
The timer ISR is resynced to vblank every frame so it doesn't wonder out of phase.
This version uses a 24bit fixed point PHA for the resampling, but 16bit fixed point is actually enough to accurately resample the streams. 16bit fixed point mode would save about 4-5% cpu resource when all 4 resampled channels are playing.
The timer playback ISR re-enables interrupts so as not to stall video interrupts (H-int). Would need a tight H-int routine to keep the jitter minimal. I do have a version that runs off H-int routine, as PCE can generate an interrupt for every scanline (262 scanlines), for when you need lots of H-int FX and PCM playback - but it's not publicly available yet.
This playback driver does all the bank mapping and resampling in the ISR itself, to make it more flexible. But buffer playback with a separate could shave off 6-7% cpu resource for max channels playback.
Two of the channels are fixed frequency (I fixed instruments and game SFX could use it). The two channels are paired, so they can be combined for 10bit output stream (with 4, 6, or 8 software channels mixed outside the player at 7bit resolution for software each channel).
Channels can be easily switched between sample output and normal PCE instrument output.
Currently, if all 6 channels are playing samples, then the ISR consumes about 36% cpu resource (for the 24bit PHA, ~32% for 16bit PHA). With optimization, that number drops to about 26% cpu resource.
Note C Octave 3 is set at the base frequency of 7khz.
The driver support up to octave 6. It's linear stepping for frequencies, and has 32 steps between each note.

A note about the XM examples: Those note frequencies are in the 14-56khz range! The poor little driver is skipping samples like crazy. That, and 99% of the FX missing from the player, make for some rough examples haha. None of the samples in the example songs are filter, reduced, or retouched at all example the sample depth (converted to 5bit). So they aren't the best examples to show off the driver, but rather how to use it?? Ehh.

The goal wasn't to make a MOD player for the PCE. It's to augment the PCE's sound with just a little more umphf. I.e. find samples that sound good in the 7-14khz range. I imagine pairing resampled channels with normal PCE channels might help masked some of the noise (for the samples with higher frequencies).

Post Reply