Archive for the Audio Category

More PCM player stuffs

Posted in Audio on November 16, 2015 by pcedev

The wave conversion tool is up and running and looping support is working flawlessly. It’s forward looping only, but I’m gonna add ping-pong loop support soon. Ping-pong support will be hard coded into the wave, since it’s too much cpu overhead, or work, to change how the PCM frequency driver works.

So the tool outputs a specialized format for the player with a small header containing the loop points. Looping on the player side doesn’t take any additional cpu resource, which is nice.

Did you know that Batman on the PCE does precalculated frequency scaled waves of a single bass guitar instrument, and actually has a loop point section? There’s the attack part and the loop part of the waveform. It means a tiny sample can be made out to be a really long sound. IIRC, there’s 2 octaves which means a total of 24 notes or 24 samples. It gives the bass guitar instrument a nice punch-y sound that the normal PCE channels just quite don’t reach when emulating/modeling it (although they do a good job).

Anyway, more on the player itself. So octaves follow a formula of 2^a, with a being the octave. This means the rate of change is increasing in between octaves. Notes are section of frequencies along with octaves, and they are also part of that 2^a format, except they exist in between octaves ranges. It now becomes something along the lines of 2^(a+(b/12)), with b being the note (ranging from 0 to 11). The frequency difference/distance between each note increases as the frequency increases. It’s not linear.

Since octaves are an exponential function with a base of 2, I can simply binary shift the frequency to get my octave range. Therefore I only need to store 12 note frequencies in a table for once octave, and the rest can be derived from there. But I need more than just notes and octaves; I need to be able to slide a frequency up and down. So I increased the table from 12 notes, with 32 frequency steps between each note – for a total of 384 entries. Still not bad. Not only do I now have frequency sliding control with precision that I can track, but I now have a method of fine tuning as well.

It works like this: O:N:S. O is the octave, N is the note, and S is the step. S ranges from 0 to 31, any carry/borrow gets added/subtracted from N. N ranges from 0 to 11 and carry/borrow affects O. O ranges from 0 to 7, with 3 being a 1:1 or rather no binary shifting. I build the frequency divider from O:N:S number, but I only need to do this when there’s a change in frequency. And when it is performed, it’s pretty fast. There’s no multiplication: only one table fetch, a few shifts, and one addition (finetune). The other nice thing is, all inter-note frequency steps are the same ratio for any octave. So if you do a vibrato effect, it has the same strength if the note is high pitch or low pitch – unlike period based music players that rarely ever compensate for this. Under period based players, this presents a problem if you have an instrument where you have vibrato effect going on and you want to slide (portamento-to-note) to a higher frequency note – that vibrato effect that sounded perfect might sound too extreme at a higher frequency. You would have to compensate by having a function scale back the vibrato strength while going up in frequency, and this would be trial/error (I have yet to see a music driver do this, but it’s doable). So this resolves that issue.

Anyway, the player (driver) is done but I’m building what amounts to a small music engine to demo it off. So that takes time. Plus, I’m trying to modularize this into sections; the driver, interface support, music engine example. I need to keep them all separate so it’s easy to pick and use just what you need (assuming anyone uses this).


Do I expect this to revolutionize the PCE sound? No. This is more of a proof of concept. There are definitely strengths and weakness of this approach. Some samples will sound dirty, or unpleasant, so it really depends on the sample itself and I believe that puts a limit on how useful this is. The 5bit resolution of the PCM is also another issue; for some samples it’s fine and for others it can be hiss-y or noisy. Techniques like 1 or 2 point (difference) volume-map to keep noise at a minimum might help, but it really depends on the specific waveform. That said, I think the 6bit PCM player (the other approach) has more promise than this, but this approach, this player, is simpler in both execution and interfacing. I’m also reusing some stuff here for that other driver.


PCM player

Posted in Audio on October 31, 2015 by pcedev

That old PCM player that’s in the download in links section? No good. I was looking over it and realized that not only is it convoluted and complex, but the interface really doesn’t show how to use the damn thing. It’s a poor example.

So I revisited it. I’m going to attempt to modularize it into an easy library of sorts. I’ll include macros and routines for basic functions for controlling each channel. I also made it a little more friendly to memory page layouts compared to the fix bank requirement from before. This bumped the cpu resource up by 2.7%. In addition, I added dynamically controlled fixed frequency sample streaming for the last two channels. So 4 XM channels and 2 PCM streaming channels.

I refer to them as XM channels, because they use a linear frequency approach compared to period base system of MODs. It’s a phase accumulator. The nice thing about this, is that I don’t need a huge table to translate notes to frequencies. I actually only need a table of 12 notes at C3 (octave 3). Everything else can be derived by shifting that left or right. The phase accumulator is 19bits long with the top three bits being the whole number and the lower 16bits being the float part (fractional value). So I have a finetune table of 16 points between notes (plus or minus direction) for finetuning the wave form without the need of an external program. And lastly, I have 32 frequency steps in between notes. I could have more… waaayyy more given the 16bit fractional part of the frequency divider, but honestly from my experience 16 usually cuts the cake anyway, so 32 should be enough. The steps are for frequency sliding (or vibrato).

I’ll include a small command line utility that prep a wave file to the format needed for the player. The player supports loop points, so those would need to be included into the waveform directly for that support. I also don’t track the waveform by its length, but rather have an end of marker value in the stream itself. So those need to be included as well.

So the numbers I have for 4 XM channels is 29% cpu resource from the call to the RTI at 117 times per frame (1/60) – for all channels playing.  The frequency division is all handled inside the timer routine, so you would just need to provide the note to play.  For the 4 XM and 2 PCM, that number jumps to 36.6% if all six channels are playing. Still not bad at all. The timer interrupt is actually 6.991khz and not 7khz, but I reset the timer counter ever vblank to keep it in sync, and do an mid-between call to the timer routine – so it ends up being 117 calls per frame or 7.02khz. Honestly, if I skipped it and did 116 I doubt there would be an audible difference.


On the topic of audio, have you guys ever heard the PCE stream 55khz 5bit PCM using the channel’s waveform memory as a buffer? Check it out:   That was recorded from my SuperGrafx. Basically it’s a 1.7khz timer interrupt, which means an interrupt called 29 times per frame. Each interrupt call, just refill the buffer. On the SGX, you only need one channel to do this (or any of the core grafx consoles with the 6280a processor). The regular 6280’s need two channels to do this. Sounds pretty good for 5bit audio. Because of how audio tends to get filtered/blended at that higher range, you can actually interleave channel streams and have them mix together. You could do a ~64khz output setup, but have four streams feeding it in interleave format for a 4 channel PCM stream at 16khz each. Not bad at all, especially considering how light the cpu resource is compared to something like 7khz single channel output the old fashion way. But here’s the crazy thing, as if that wasn’t crazy enough, you can do this with two channels on the SGX and stream 10bit audio in the same fashion. Just let that sink in for a minute…

Posted in Audio, hacks, Megaman, NES2PCE, retro with tags , , , , , , , , , , , , , , , , on February 8, 2014 by pcedev

More Megaman 1 stuff.

Maaaannnn. Talk about a pain. Principle and execution; two very different things. What should have been a very easy upgrade to the load room graphics hook/code, ended up being a nightmare. It broke a lot of stuff that I already had in place. So, some other stuff got changed/upgraded (mostly OAM->SAT conversion). But it’s done and working. Finally. All the enemy sprites for Cutman stage are up and running. All converted to native PCE format. I worked out how to handle the palettes for those enemies too. You know, you don’t realize how much 16 subpalettes just for sprites – is incredibly large for that era. It makes things sooo much easier, and the fact that I still have another set of 16 just for the BG graphics – this is gonna be easy. Wily Wars on the MD/Gen, uses 7+1 colors for sprites. That how the extend the 4 subpalettes to be more than 4. 8 colors for a sprite, isn’t so bad for Megaman style design. BUT WE ARE GOING THE FULL 15 COLORS PER SPRITE! Yeah, baby. I purposely added colors to the sprites, even if you can see them – lol. I wanna have a few screens in the game, surpass the 100+ color count mark.

Anyway, things are coming along. I’m working on the ‘start stage sprite’ load routine, which is different than the load-room-sprites (not sure why). I’ll have something to show off when that’s finished.

Spriggan Mark 2

Posted in Audio, translations with tags , , , , , , , on January 29, 2014 by pcedev

Got in contact with Burnt Lasagna, who did the dubbing for Ys IV English version and also Dracula X:Rondo English dub/translation project. SamIam did the translation of the game for me, as well as translate all the cinema dialog. I just posted all the ADPCM offsets from the script, so hopefully we’ll see an English dub of this translation project. I have one small snag that I need to fix in the game; one of the levels has the translated script to big to fit back in; I need to compress it.

Also gonna need a translation of the manual as well, and some one with some good photoshop skills. Hmm, maybe I should open a RHDN page for this.

If you don’t know, it’s SM2 is like Target Earth or Cybernator – but in a horizontal shmup format. There’s story dialog in game (like an RPG), as well as cinemas in between the stages. It’s definitely an under rated/appreciated game.

Megaman CD update

Posted in Audio, hacks, Megaman, music, NES2PCE with tags , , , , , , , , , , , , , , on January 27, 2014 by pcedev

Since I had to fix the easy/normal bug, I figured I’d clean some other stuff up as well. The CD setup is now distributed in two packs; CD music pack and Cue/Iso pack.

I got rid of all the non-megaman CD tracks (place holders). So everything is Megaman related now. The title screen now has its own track (haha – it’s awesome) and the original game title screen is gone (goes from the new title screen to the stage selection screen). The tracks are now appropriately named, so replacing them with whatever you want – should make it easier. Uploaded and available in the Download and Links section.

Also, I probably won’t be making any updates to MM1 for download – for a while. I’ll post progress, but there’s no real need to upload every time something small is added. I am happy with the state that it is in now; the next public release should contain some major upgrades.

Sound FX

Posted in Audio, hacks, Megaman, NES2PCE on January 21, 2014 by pcedev

Ohh, btw – I’m looking for some sound FX for the Megaman title screen. A ‘schwiinnng’ type effect for the title bar/logo. And a menu cursor movement sound as well. Maybe a game start sound FX? They’re going to be ADPCM, so any source for a sound file should work (wave/mp3/etc).

Showing off

Posted in Audio, hacks, Megaman, NES2PCE with tags , , , , , , , , , , , , , on January 12, 2014 by pcedev

The new CD play routines. Sleeker, better, synced, and no garbage screen. This is run on mednafen, and medanfen has no seek delay. So I added a hard delay in the track play routine, to show what the screen would look like on a stalled or long seek-to-track of the real system.