|
Post by turboxray on Dec 16, 2019 5:09:31 GMT
Years ago, 4+ probably, I wrote about different setups for sample playback. I had quite a few different scenarios, but one interesting one was 4 PCE channels + 4 7bit PCM channels, at ~17% cpu resource at 7khz. I actually completed this, as well as other setups (4+6, 4+8, and 4+10 @ 30% cpu resource, etc). The PCM channels have software volume as well as loop points (just no frequency scaling). It's not that difficult to setup, so I kinda figured someone else would have put something similar out by now. I always found it interesting, because this is basically what the Neo Geo did; used a crap load of fixed frequency PCM channels (ADPCM, but still) and sometimes paired it with 4 FM channels.
7khz actually sounds pretty decent with 7bit samples. The only ones that I found that could definitely use more frequency were hi-hats, crashes, etc. I mean you can kinda get away with snares at 7khz (Air Zonk does). Curious, I did some tests to see where that threshold was and what was the fastest way to get some more frequency resolution out of the PCE for cheap. One way, is to use the TIMER interrupt like normal, but write a second sample to the same sound port. The key, is to try to give it some distance between the writes. Basically, if you wrote to a DAC at the beginning of the interrupt and then again half way through - you'd get 14khz. But you're now using 50% cpu resource. So, I got to thinking what if you wrote at 20~25% (200~256 cycles from the first sample)? It's 'technically" two sample writes, being 14khz, but the perception is closer to 10~11khz because it's not as equal in temporal distance. 10khz has a noticeably crisper sound than 7khz, but especially for samples that are more sensitive to temporal resolution (like the mentioned samples). You'd think the output would be 'jittery' and noticeable, but it's not really a 'jitter' per se because the timing is almost exact each time. It's a strange effect, but definitely works in our favor. The problem arises.. what are you going to do in those 200~256 cycles in between? If you're doing more advance audio stuff, like I mentioned in the opening, you can put that block space to good use (I mean, you're just gonna be doing it somewhere else so.. why not some of it here?).
To kind of put things into perspective, Air Zonk's sample handling isn't optimal. The decompression time, along with the music engine, it about 22~24% cpu resource (with sample being a huge part of that time). So anywhere from 17~24% shouldn't be that bad. Plus, it's a really nice sound upgrade. I already have a few combinations working, and the interface to the PCM engine is pretty easy to use (assign a sample to a pseudo channel, set the volume level, and use start/stop commands- just a simple API with requests that are buffered and processed once a frame).
A little info on the PCM mixer; for the 4 PCM 7bit channels, I'm not using the full 10bit PCM resolution. Mostly because mixing to a 9bit output is a bit faster than 10bits (it's mixing at 9bits, but scaling to 10bits for loudness). But pairing two 9bits wouldn't be so bad, given something like 6,8,10 PCM channels as pairs of 3,4, and 5 channels. Given that GBA software driver mixed all PCM channels to 9bit, it's a good comparison/perspective. You still have 4 stereo normal PCE channels on top of the PCM.
EDIT: Opps, forgot to mention that I'm taking a 3 week vacation for xmas. I was going to use some of that time to release this PCM source/engine.
|
|
|
Post by SignOfZeta on Dec 16, 2019 17:54:47 GMT
Beatmania IIDX for PCE confirmed!
|
|
|
Post by turboxray on Dec 24, 2019 20:01:32 GMT
somewhat related (this is for the 4 sample-synth driver I have for the PCE):
I was messing around with some tests for PCE. Mostly different configurations for samples, sample synth, etc. And I was trying to optimize the re-sampler code for something faster (for higher frequency playback), and it dawned on me... I'm doing a 24bit fixed point phase accumulator for sample channel, when all you need is 16bit fixed point accumulator. For some reason I thought I needed 1hz increments, but then looking at the note frequency table - I realized I need HZ increments in note frequencies not sample output frequencies. I.e. Note C octave 3 is 130.81hz. So if set 7000hz output to be calibrated for C3, I would need 7000 / 130.81 = 53.44hz resolution. Well, 7000 * (1/256) = 27.34hz steps. Simply put, I should be under at least half the resolution for stepping. I mean, if I need finer control, I alternate between two steps every so many cycles to get finer control.
I tested this out. I left the 24bit PHA numbers for frequencies as is, but only used the upper 16bits and it sounded the same. I couldn't hear any loss (as expected). It also had the nice benefit of freeing up like 5% cpu resource for mixing 4 re-sampled channels. So that was kinda nice; 32% cpu resource for 6 samples play on 6 channels (4 resampled and 2 straight output). My buffered version, which uses more ram, cuts it down to 29% for full 6 channel usage.
The original intent wasn't for a MOD/SNES/ whatever re-sample synth for the PCE. What I wanted was to augment the PCE's sound, not replace it. So the goal wasn't to use all 6 channels for sample output @ 29% cpu resource (but it's there if you wanted to). But rather something like 2 resampled, 2 straight output (maybe one for SFX and one for drums/whatever) at like 21% resource. You know, things like pairing a sample channel with a regular PCE channel to mix in some timbre or whatever, and/or a pluckier/punchier bass.
In the original post above, about mixing channels into a single mono channel, I'll have the option to make one or two channels sample-synth (which will now be faster thanks to a smaller PHA).
|
|
|
Post by elmer on Dec 28, 2019 22:03:32 GMT
Interesting stuff.
If Delek ever releases his next version of deflemask with the PC Engine improvements that have been in limbo for years, then it would be interesting to use techniques like these to make the sample-playback channels work well (and still allow for simultaneous sampled sound-effects).
|
|
|
Post by turboxray on Dec 28, 2019 22:45:57 GMT
Interesting stuff. If Delek ever releases his next version of deflemask with the PC Engine improvements that have been in limbo for years, then it would be interesting to use techniques like these to make the sample-playback channels work well (and still allow for simultaneous sampled sound-effects). What improvements were submitted to deflemask? Deflemask is fine and all, but if I was working with a musician for PCE, I'd definitely make an engine from scratch to their wishes/specs haha. I mean deflemask could be used to quickly prototype stuff if needed. There's still some audio tricks deflemask doesn't do for PCE though.
|
|
|
Post by elmer on Dec 29, 2019 7:04:00 GMT
It's stuff that Michirin9801 and I (and others) requested that Delek change years ago when he was talking about fixes for the much-delayed 0.12.1 ...
1) Fix incorrect noise volume level (a problem from Deflemask's use of Ootake code) 2) Fix not supporting all of the PCE's different noise frequencies (which degrades drums and other use of noise) 3) Add "envelope" changes to allow switching between noise and tone at 60Hz, to use for drums and other effects, just like the Sytem Card player (and Squirrel) allows. 4) Allow for more 32-byte instruments.
Nothing earth-shattering, but it will make deflemask more usable and closer to the capabilities of other PCE drivers from the 80s/90s.
Yes, you can absolutely create a more capable driver if you wish to, there is nothing "magic" or particularly "special" about Deflemask's capabilities, and nor does it have many (if any) substantial technical improvements over the System Card player (and Squirrel).
What it has, is a user-interface that makes it "experimentable-wtih" and "sort-of-understandable-and-fun-with-immediate-feedback" for a lot of modern retro-musicians.
Unless you can find a really talented musician who is willing to work with the enhanced tech that you provide, and do so within the limitations of the memory space and CPU time that your game-or-demo-engineer can afford, then your ability to "do more" with the hardware is likely to be somewhat under-used.
I hope that you can find both that musician, and an appropriate project to work on.
|
|
|
Post by turboxray on Dec 29, 2019 17:52:33 GMT
I contacted someone that said they were interested in PCE project with music, so we'll see. If nothing else, I'll mature a project to a point where I can entice chiptuners haha. Did anyone make an engine for deflemask yet? I don't mean the 'cooked' player. I knew that deflemask supported waveform updating, but does it support waveform corruption? www.youtube.com/watch?v=V845pHyaePk I.e. you let the channel play as normal (normal note, frequency, etc), but at a low frequency you write updates to the data port. It updates the waveform memory without turning off the channel; update gets applied to waveform memory via the current WSG playback pointer value. No clicks, no pops, and really resource light (fixed point counter against 60hz. As little as one update per 'tick').
|
|
|
Post by elmer on Dec 30, 2019 0:08:47 GMT
I contacted someone that said they were interested in PCE project with music, so we'll see. If nothing else, I'll mature a project to a point where I can entice chiptuners haha. Cool! I don't know if you were still around back then, but Fragmare became rather proficient with producing deflemask cover-tunes that included some heavy sample usage. He'd probably love the idea of your tech, and the realtime mixing of multiple sample channels. Did anyone make an engine for deflemask yet? I don't mean the 'cooked' player. Mine has been in limbo for ages while I try to get up the interest to finish it off to a releasable point. Partly I wanted to wait for the official deflemask improvements so that I don't have to fix stuff when it is released (since I already support some of the new stuff, but in possibly-incompatible ways). Again, I can't remember if you were around back then, but you might have missed these ... www.dropbox.com/s/qsmjfvrcmgv4tr1/Michirin9801-2017-07-29.zip?dl=1I knew that deflemask supported waveform updating, but does it support waveform corruption? Nope, but you could always ask Delek to add it, if you can provide some examples it its use. He's promising a "biggest-update-ever" at some point ... but gawd knows when that will be.
|
|
|
Post by turboxray on Jan 5, 2020 3:40:58 GMT
Update: I've been working on making this 4 soft-mixed channel demo that I had up and running, making it all nice and package-pretty.. but I ended up re-writing a LOT of it. It's the same thing, just code is organized a little better (and a little more modularized to fit in different configurations). But I did run into a problem with my optimization technique. Or rather, how the data is stored. Originally, the demo that I had working ran at 15.6khz (off the VDC ISR) and I had the sample buffer length set to 256 along with samples having an offset of 256 bytes. But 116 doesn't fit cleanly into that (it more complicated than that, but that's the general problem). You see, I don't want to check for bank overflow on EVERY sample. It was fine for in-the-moment version like the HuPXM driver, but that's a waste to do that in this buffer system. So I need to change my wav2pce app to output a different format. Instead of just a binary file, it's going output an ASM file with macros in between sets of 116 samples (as .db directives). The macros, when assembled, will fix all alignment issues. But of course this means you lose 72 bytes for every 8k bank crossing. Honestly, I'm not really concerned with that little of loss, but I'll probably add an option in the future to do 58 samples chunks for a 14-byte bank boundary loss. My original demo didn't have it, but I added in support for forward-looping on the fixed samples for this version. It only cost a total 0.7% for all 4 mixed channels. Figured that was worth the hit hahah. Tangent: Probably mentioned this before, but Batman on the PCE actually does some sampled-based synth. It's on the bass guitar. It doesn't scale the sample in realtime, but instead has 28 samples (12 notes, 2 octaves). But it doesn't take a whole lot of space because they did an small "attack" sample, and then a looping sample part. Both parts, but especially the looping part, can be shaped with a volume envelope (basically like MODs did). It made for a pluckier/punchier bass instrument. It's pretty awesome actually. And it's also pretty dumb no other PCE game did that But anyway, that's what looping gets you; allows you to expand out an instrument sound without using a lot of space. Future stuffs: Not part of this project specifically, but definitely related (and will be the next PCE project I release after this), is option to output re-sampling of a smaller buffer (in place of whatever soft mix channel). Think of it like a mini 16 or 8 sample buffer just like the normal PCE channels, but soft mixed. It'd give back mini "WSG" channels so you're not stuck with just samples. But the really nice thing, is that all those fancy wave swapping effects deflemask allows you to do? This would allow that but with perfect sync'ing and no clicking haha. With 16 samples per waveform, you could make some crazy morphing transitions. All done with 8 total channels at a very reasonable price I'm personally more hyped about that than the HuPCM resampler that I worked on.
|
|