Author Topic: Streets of Rage - Fighting In The Street (TurboGrafx-16 Chiptune Cover)  (Read 2239 times)

spenoza

  • Hero Member
  • *****
  • Posts: 2751
Re: Streets of Rage - Fighting In The Street (TurboGrafx-16 Chiptune Cover)
« Reply #15 on: January 09, 2017, 02:00:22 PM »
Dang it, now I want more good belt scroller games on the PCE. There weren't many.
<a href="http://www.pcedaisakusen.net/2/34/103/show-collection.htm" class="bbc_link" target="_blank">My meager PC Engine Collection so far.</a><br><a href="https://www.pcenginefx.com/forums/" class="bbc_link" target="_blank">PC Engine Software Bible</a><br><a href="http://www.racketboy.com/forum/" c

fragmare

  • Hero Member
  • *****
  • Posts: 676
Re: Streets of Rage - Fighting In The Street (TurboGrafx-16 Chiptune Cover)
« Reply #16 on: January 09, 2017, 06:42:45 PM »
I got both of the .hes files to run on my TED v2.2 and they both sound great.

So what's the deal with the 22KHz samples version? Does the PC Engine hardware read them and just play them back at the max sample rate it can do without custom programming or is that included in conversions from Deflemask?

IIRC, each individual PSG channel is capable of many different frequencies, up to and far exceeding 22KHz... at a cost of CPU resource and ROM/RAM space.  7KHz just seems to be the "magic number", by consensus, among programmers types as the optimal rate for using in a game and not hogging up too much CPU resource.  I'm sure Bonknuts or CCovell or somebody could explain why better than I.

ccovell

  • Hero Member
  • *****
  • Posts: 2245
Re: Streets of Rage - Fighting In The Street (TurboGrafx-16 Chiptune Cover)
« Reply #17 on: January 10, 2017, 12:55:44 AM »
As mentioned earlier (?) 7.16 Khz is the fastest setting that the CPU timer interrupt can be set to, making it a natural choice for music engines to use for timing their PCM samples.  Faster than that, you'd need to rely on HSync interrupts from the video hardware, or do CPU wait loops (the brute-force way).

fragmare

  • Hero Member
  • *****
  • Posts: 676
Re: Streets of Rage - Fighting In The Street (TurboGrafx-16 Chiptune Cover)
« Reply #18 on: January 10, 2017, 01:14:58 AM »
Plus, 7.16KHz drums samples are guaranteed to give you those nostalgic Devil's Crush/Blazing Lazers "feels"  :D

Black Tiger

  • Hero Member
  • *****
  • Posts: 11242
Re: Streets of Rage - Fighting In The Street (TurboGrafx-16 Chiptune Cover)
« Reply #19 on: January 10, 2017, 01:34:03 AM »
So does deflemask add in cpu wait loops or something?
http://www.superpcenginegrafx.net/forum

Active and drama free PC Engine forum

fragmare

  • Hero Member
  • *****
  • Posts: 676
Re: Streets of Rage - Fighting In The Street (TurboGrafx-16 Chiptune Cover)
« Reply #20 on: January 10, 2017, 06:05:45 AM »
As mentioned earlier (?) 7.16 Khz is the fastest setting that the CPU timer interrupt can be set to, making it a natural choice for music engines to use for timing their PCM samples.  Faster than that, you'd need to rely on HSync interrupts from the video hardware, or do CPU wait loops (the brute-force way).

So are you saying that you ONLY get that benefit when the samples match the CPU clock?  For example, you couldn't just straight up use the CPU int if, say, the sample was an exact of multiple of 7.16 (like 14.32Khz) at a cost of higher resource usage?

elmer

  • Hero Member
  • *****
  • Posts: 2148
Re: Streets of Rage - Fighting In The Street (TurboGrafx-16 Chiptune Cover)
« Reply #21 on: January 10, 2017, 07:20:46 AM »
So what's the deal with the 22KHz samples version? Does the PC Engine hardware read them and just play them back at the max sample rate it can do without custom programming or is that included in conversions from Deflemask?

The PCE hardware doesn't have any mechanism to sequentially read sample-values from memory.

That's the problem that us programmer-types have to deal with.  ](*,)

It has 1 sample-value-register per channel, and that represents just one instantaneous volume value at one tiny point-in-time.

In order to play back a sample (aka WAV file), the PCE's CPU must run a program to change the instantaneous-value that's in that register thousands of times every second (aka the sample-rate).

That takes a significant amount of CPU time.


So does deflemask add in cpu wait loops or something?

Deflemask's .HES playback code just sits in a tight loop, which their programmer has very-carefully timed, and it does nothing at all except sit there and write instantaneous-values to the PSG's sample-value-registers every 1/32000s, 1/22000s, 1/16000s. or 1/8000s.

It uses 99% of the PCE's CPU just to output those instantaneous-value settings to the PSG's registers at *exactly* the right times to support those different sample-rates.

Then there's an interrupt every 1/60th of a second that stops writing the samples, and writes all of the other PSG registers (like the channel volume, frequency and waveform), and that takes the remaining 1% of the PCE's CPU time.

It's all used-up ... there is no CPU time left.  :shock:

That's fine for Deflemask ... but it is totally impractical in a game, where we'd actually like the CPU to spend some time doing "useful" stuff like updating graphics and responding to player inputs.


So are you saying that you ONLY get that benefit when the samples match the CPU clock?  For example, you couldn't just straight up use the CPU int if, say, the sample was an exact of multiple of 7.16 (like 14.32Khz) at a cost of higher resource usage?

Nope, he's saying that the *fastest* that the timer can run is 7KHz (not 7.16 ... you're confusing the CPU's 7.16MHz clock with the 7KHz timer (7.16MHz / 1024).

The point is, that in normal game programming, we actually write our code so that we spend thousands and tens of thousands of CPU cycles actually updating graphics on the screen, figuring out what sprites to display and where, and responding to user input.

In order to keep on updating the PSG's instantaneous-value registers regularly so that the user hears a continuous sample (aka WAV), we have to interrupt whatever the CPU is doing, and quickly run some code that updates those registers, and then return back to continue processing whatever-it-was that we were doing.

There are only 3 sensible mechanisms available for us to trigger those regular interrupts ...
1) 7KHz timer
2) 8KHz every-other-hblank
3) 16KHz every-single-hblank

That's it. Those are the 3 sample-rates that the PCE sensibly supports.

It costs more CPU time to process an hblank interrupt than a timer interrupt, and the quality-difference between 7KHz and 8KHz isn't enough to warrant the expense, so the 2 normal choices are either 7KHz or 16KHz.

The CPU cost, and ROM cost for using 16KHz samples instead of 7KHz samples is obviously over twice-as-much, and so the normal choice is just to output samples at the 7KHz rate.
« Last Edit: January 10, 2017, 07:50:26 AM by elmer »

Black Tiger

  • Hero Member
  • *****
  • Posts: 11242
Re: Streets of Rage - Fighting In The Street (TurboGrafx-16 Chiptune Cover)
« Reply #22 on: January 10, 2017, 08:01:06 AM »
So then even the "in-game" version of that SoR track is more or less maxing out the cpu resources, because deflemask is simply a wholy inefficient method of producing PCE chip tunes, even when the end result isn't any more special than existing chip tunes from commercial games?
http://www.superpcenginegrafx.net/forum

Active and drama free PC Engine forum

elmer

  • Hero Member
  • *****
  • Posts: 2148
Re: Streets of Rage - Fighting In The Street (TurboGrafx-16 Chiptune Cover)
« Reply #23 on: January 10, 2017, 09:34:53 AM »
So then even the "in-game" version of that SoR track is more or less maxing out the cpu resources, because deflemask is simply a wholy inefficient method of producing PCE chip tunes, even when the end result isn't any more special than existing chip tunes from commercial games?

With the locked-loop code that's in the Deflemask .hes player, I can't see much reason why they couldn't support 44.1KHz or 48KHz samples, if they'd wished to have done so.

It's Deflemask's .hes code that's cr*p, and the reason that it can never be anything other than cr*p, is the ill-conceived decision to allow sample rates other than 7KHz, 8KHz, or 16KHz.

Those are the only ones that can be processed on the PCE with any measure of efficiency.

There's not really even anything wrong with deflemask's .hes exporter ... it was designed to do a single job, and not to be used in new game production. It fulfills its purpose, so I shouldn't really call it cr*p.

The .hes format itself is totally unsuitable for games.

It's just a recording of the register values that are sent to the PSG by each game's own sound driver.

No in-game sound driver ever worked like that (that I know of), because it is terribly inefficient.


Deflemask itself, as a tool, is a perfectly good way to develop music for new games, and has little practical difference to how folks used to create music back-in-the-day, except that it's a lot more user-friendly with its GUI and its in-GUI emulated playback (what-you-hear-is-what-you-get).

It is actually by-far-the-best way that I've seen to develop music for these old systems, and beats the heck out of what was available BITD.

There are only a couple of "tricks" (that I know of) that the old drivers could do that Deflemask can't (currently), but that can be worked-around, and possibly added in future versions.

Just, for-gawds-sake, limit yourself to never using anything other than 8KHz or 16KHz samples in it (and hopefully 7KHz, someday)!  :pray:

The biggest problem, at the moment, is that there is no way to get the music data out of deflemask and into a format that can be used efficiently in an in-game sound driver.

That's what I'm currently working on doing.

The way that the music notes, and timing, and effects data themselves are created is perfectly fine for in-game use, and has no important difference from how Japanese developers used MML back in the 1980s/1990s.

Remember ... pure MML data from a text file, or exported from 3MLE isn't usable with the PCE's System Card Player either. It needs to be translated/compiled into the right format for that driver to understand, and until Arkhan wrote Squirrel, nobody here could use that, either.

Now we just need to do the same sort of thing with deflemask data.

****************


While I continue to be mean to poor bonknuts about it ... there's no particular reason to say that the 16KHz sample rate is a bad one to use. It's just a balance of how much CPU power and memory space you have, and how you choose to use it.

My background prompts me to fight to keep as much time as possible available for the game itself, but that doesn't mean that it's always the right thing to do, especially at points where the game code isn't actually doing very much (i.e. title screens, etc).

It's not even a hard-and-fast rule for in-game use ... it all depends upon what your game code is doing. It's up to the programmer to know that, and for any development team to decide for themselves.
« Last Edit: January 10, 2017, 10:27:05 AM by elmer »

ccovell

  • Hero Member
  • *****
  • Posts: 2245
Re: Streets of Rage - Fighting In The Street (TurboGrafx-16 Chiptune Cover)
« Reply #24 on: January 10, 2017, 11:08:57 AM »
7KHz (not 7.16 ... you're confusing the CPU's 7.16MHz clock with the 7KHz timer (7.16MHz / 1024).

No confusion... I was just bad at math (7.16 / 1024), sorry.

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Streets of Rage - Fighting In The Street (TurboGrafx-16 Chiptune Cover)
« Reply #25 on: January 10, 2017, 12:46:31 PM »
Just to add to the discussion:

 There is 14khz mode too. You use the timer interrupt, but you have a timed loop to write the second cycle before exit. Normally, this would instantly put a restraint on cpu resource at 50% (because of the timed loop), but you could do something like 40% with a shorter loop. In that timed loop, you could also support additional sample to other channels for FREE. Or you can do 10.5khz with every other timer call being timed loop to two samples .. for roughly ~31% cpu resource. All using the timer interrupt (not hysnc).

 But honestly.. not a whole lot of samples really benefit from 16khz vs 7khz with 5bit resolution. 7khz @ 8bit sounds much better than 14khz @ 5bit.

Black Tiger

  • Hero Member
  • *****
  • Posts: 11242
Re: Streets of Rage - Fighting In The Street (TurboGrafx-16 Chiptune Cover)
« Reply #26 on: January 10, 2017, 12:53:53 PM »

 But honestly.. not a whole lot of samples really benefit from 16khz vs 7khz with 5bit resolution. 7khz @ 8bit sounds much better than 14khz @ 5bit.

I didn't notice a difference between the 8KHz and 22KHz samples playing through my TV set.
http://www.superpcenginegrafx.net/forum

Active and drama free PC Engine forum

fragmare

  • Hero Member
  • *****
  • Posts: 676
Re: Streets of Rage - Fighting In The Street (TurboGrafx-16 Chiptune Cover)
« Reply #27 on: January 11, 2017, 12:47:51 AM »
I'm pretty sure I get it now.  7KHz samples are "almost" free, where as anything more requires some big elaborate loop and hogs CPU time.  Makes sense.  That being said, I wasn't saying that 5 channel DMF/HES i linked are ready-to-go in any kind of game or demo, it could probably be vastly optimized more.  I'm just saying that's how it would sound if it were.  :)

BTW, Updated the links in original post with new files.  The 5 channel version includes just about everything from the 6 channel version now, plus cleaner/louder 8khz samples and now sounds ALMOST the same as the 6 channel version.  Both should sound about as close as I'm going to get to the Genesis track without clean-sounding wave phasing to get that hard KNOCK out of the first 29ms or so of the synth bassline beat.
« Last Edit: January 11, 2017, 12:52:00 AM by fragmare »

Black Tiger

  • Hero Member
  • *****
  • Posts: 11242
Re: Streets of Rage - Fighting In The Street (TurboGrafx-16 Chiptune Cover)
« Reply #28 on: January 11, 2017, 02:40:30 AM »
Can you please make a version with 6 channels and 8KHz samples? :pray:
http://www.superpcenginegrafx.net/forum

Active and drama free PC Engine forum

fragmare

  • Hero Member
  • *****
  • Posts: 676
Re: Streets of Rage - Fighting In The Street (TurboGrafx-16 Chiptune Cover)
« Reply #29 on: January 11, 2017, 03:46:04 AM »
Can you please make a version with 6 channels and 8KHz samples? :pray:

I could make a DMF version with 32KHz samples, then you could go into Deflemask and just set the sample rate to anything you want and export to HES :D

I probably should have made the full version's samples 32KHz to begin with heh

I gotta ask, though... why?  Just gotta have that slightly muffled Devil's Crush drum sample sound?  ;)
« Last Edit: January 11, 2017, 04:02:57 AM by fragmare »