Chat

Author Topic: Huzak - A DMF-based sound driver for PC Engine homebrew.  (Read 4067 times)

Offline elmer

  • Newbie
  • Posts: 31
  • Delek FTW
Huzak - A DMF-based sound driver for PC Engine homebrew.
« on: January 24, 2017, 04:27:00 PM »
Hi!

I'm writing a sound driver for use in PC Engine homebrew games, so that we can use DefleMask to create music/sound-effects.

The idea is to release it under the Open Source MIT License and have folks be able to use it with either HuC or assembly-language games.

A lot of the basic driver features are now working, so I'm attaching an example PC Engine ROM that you can play in an emulator, or download to a Turbo Everdrive and play on a real PC Engine.

It is Michirin9801's cover of the Misty Blue Opening track that you can find here on this forum ...

http://www.deflemask.com/forum/show-off-your-work/cover-game-music-on-a-different-system/msg4232/#msg4232


Now, there's still some way to go before this is finished, and I'm going to need Delek's help with the details of how he's chosen to implement the Vibrato and Channel Detune effects, since there are lots of different ways that he *could* have done it.

FYI, I've implemented a correction-factor for DefleMask's noise-too-loud/soft issue so that the ROM sounds like the .dmf does in DefleMask, rather than the .hes export where the drums sound too loud.

That seems to be an issue somewhere in DefleMask's use of Ootake internally, causing musicians to dial-up the volume of noise output, which then sounds too loud when played on real hardware, or in Mednafen.

Anyway ... here's the ROM (packed into a zip file because I can't upload a .pce HuCard ROM file) ...

Offline Michirin9801

  • Full Member
  • Posts: 257
Huzak - A DMF-based sound driver for PC Engine homebrew.
« Reply #1 on: January 24, 2017, 09:19:07 PM »
If someone has contact with Delek, could you please direct him to this thread as soon as possible?
I mean seriously, elmer's really on to something here, this is gonna enable us to use Deflemask to make music for real PC engine homebrews and demos! Get him on-board!

Online RazerBlue6

  • Newbie
  • Posts: 35
  • PC Engine Masterrace
    • Twitter
    • Email
Huzak - A DMF-based sound driver for PC Engine homebrew.
« Reply #2 on: January 30, 2017, 01:32:27 PM »
Oh shit, sick, this would be very nice to use in final renders

Kudos to u

Offline Delek

  • Salí para ver
  • Administrator
  • Hero Member
  • Posts: 1770
    • Delek's Website
    • Email
Huzak - A DMF-based sound driver for PC Engine homebrew.
« Reply #3 on: February 02, 2017, 01:07:16 AM »
This is amazing! :)

Offline Michirin9801

  • Full Member
  • Posts: 257
Huzak - A DMF-based sound driver for PC Engine homebrew.
« Reply #4 on: February 02, 2017, 03:35:07 AM »
This is amazing! :)
Glad you answered! It would be really great if you could contact elmer because he's in need of some help understanding how exactly Deflemask does certain things so that he can implement them into his sound driver, by the way, is there any way that this driver could be officially implemented into Deflemask?
Also, there are a few things that could be changed/implemented into the PC engine such as fixing the white noise as pointed in this thread: http://www.deflemask.com/forum/general/about-noise-mode-on-the-pc-engine/
Allowing for the notes below C#0 that the PC engine can play but aren't supported in Deflemask, and maybe adding a PC engine CD variation with the ADPCM channel as a 7th sound channel?
Maybe I'm asking for too much, maybe you're too busy to do these things right now, but maybe, just maybe, you could get elmer to help you with some of these changes? I mean, both of us want Deflemask to be usable for PC engine homebrew, and I want to be able to get more out of the system with this tracker, if you guys could collaborate on this, it would make the lives of us PC engine musicians so much better!
Thanks in advance for your attention...

Offline elmer

  • Newbie
  • Posts: 31
  • Delek FTW
Huzak - A DMF-based sound driver for PC Engine homebrew.
« Reply #5 on: February 02, 2017, 06:55:55 PM »

Glad you answered!

Me, too!  ;D


It would be really great if you could contact elmer because he's in need of some help understanding how exactly Deflemask does certain things so that he can implement them into his sound driver

I *think* that I'm sort-of-OK at this point, now that I've looked at the .hes output and figured out basically how the detune and vibrato parameters effect the frequency/period settings of the hardware  registers.

It's a bit of a PITA that I need to do a couple of multiplies in there, and implementing the detune is wreaking havoc on the code size, but it's coming along.

It would certainly be really nice to check out the code in Delek's built-in driver, just to make sure that I'm doing things in the same order, and that the math is the same.

I'd definitely like to find out why the vibrato *seems* to be unbalanced in the .hes output (+0.5 & -1.5 semi-tones in a distorted sine-wave).


Quote
Also, there are a few things that could be changed/implemented into the PC engine such as fixing the white noise as pointed in this thread: http://www.deflemask.com/forum/general/about-noise-mode-on-the-pc-engine/
Allowing for the notes below C#0 that the PC engine can play but aren't supported in Deflemask, and maybe adding a PC engine CD variation with the ADPCM channel as a 7th sound channel?

These would be lovely, together with the Noise On/Off trigger in the Wave Macro, but I can see that Delek is very busy at the moment, so I'd be surprised (but happy) if he had time to look at them before the 12.1 release.

Some of those features (like the Wave Macro change) are already in Huzak, and some will be implemented as it continues to mature.

Offline elmer

  • Newbie
  • Posts: 31
  • Delek FTW
Huzak - A DMF-based sound driver for PC Engine homebrew.
« Reply #6 on: February 07, 2017, 05:34:28 PM »

It would be really great if you could contact elmer because he's in need of some help understanding how exactly Deflemask does certain things so that he can implement them into his sound driver

I *think* that I'm sort-of-OK at this point, now that I've looked at the .hes output and figured out basically how the detune and vibrato parameters effect the frequency/period settings of the hardware  registers.

OK Delek, I'm going to need your help with some information, after all.

I've got the detune and vibrato implemented, and the detune is really *close* to yours, but it's not *perfect*.

I'm multiplying the detune (basically +/-127) by the difference in period to the next note, and then dividing by 128, and adding that to the period.

So with rounding, that's ...

change = (((period_table[note-1] - period_table[note]) * (detune - 128)) + 64) / 128;

My actual implementation is a tiny-bit different for increased speed as assembly-language, but that's basically it.

2 things to note ... I'm always using the period-difference to the next lower semi-tone, because it's larger, and I do allow the calculation to return 0, rather than returning a minimum of 1.

For instance, when the period difference is 7, and the detune is $88 (1/16th semitone), then that math comes out to 0, where with a period difference of 8, the math rounds up to 1.


Can you please tell me what you're doing inside DefleMask? Do you force a minimum change of 1 whenever the detune is enabled (i.e. not $80)?

Are you doing a realtime calculation whenever you set the period, or are you using pre-calculated lookup tables (and if so, how many?).

If you are using lookup tables, would you mind posting the code to generate them?

I'd also love to see your table of note-to-frequency, since I've seen a couple of off-by-one differences to the table that's in the official Hudson PSG documentation.

Thanks!

Offline elmer

  • Newbie
  • Posts: 31
  • Delek FTW
Huzak - A DMF-based sound driver for PC Engine homebrew.
« Reply #7 on: February 11, 2017, 09:42:05 PM »
OK, I tweaked my math a bit more for the Detune Effect, and ripped DefleMask's tone-2-period tables out and am using those now (they're off-by-one on a few tones compared to Hudson), and now I'm getting the same detune values as DefleMask (within the limits of testing).

I did make my Vibrato Effect behave almost identically to DefleMask's odd off-balanced sine-wave, but then I changed it back to a real sine-wave and just reduced the Vibrato Depth a bit in order keep the same depth, but avoid messing up my Vibrato Mode implementation.

As far as I can tell, it *sounds* the same as DefleMask, but the actual values are a bit different. There's a bit more room for differences in Vibrato than in Detune while keeping the same sound, so I'm happy with the result.

I'd post some ROMs, but since nobody had downloaded the last one, there doesn't seem much point.

Anyway, now it's on to implementing other effects.

Oh ... the driver currently peaks (worst-case) at 5-6% CPU usage, which means that we're on well on track for in-game usage.  ;D

Offline Delek

  • Salí para ver
  • Administrator
  • Hero Member
  • Posts: 1770
    • Delek's Website
    • Email
Huzak - A DMF-based sound driver for PC Engine homebrew.
« Reply #8 on: February 11, 2017, 10:53:59 PM »
Sounds awesome. And yes, maybe the Defle vibrato have balanced issues on non FM based soundchips. I will check that out later.
Btw, I need to document how my tracker parses the commands but is a FUCK TON of code. The good thing is that if I do this the amount of apps that uses the Defle engine will skyrocket maybe.

Offline elmer

  • Newbie
  • Posts: 31
  • Delek FTW
Huzak - A DMF-based sound driver for PC Engine homebrew.
« Reply #9 on: February 13, 2017, 01:29:25 AM »
Sounds awesome. And yes, maybe the Defle vibrato have balanced issues on non FM based soundchips. I will check that out later.

The continuing development on Huzak is mainly talked about on the PCEngineFX.com forums, because that's my main PCE Developer hangout.

Since I don't expect you to sign up for an account there, here's what I found out about the Vibrato output in the .hes files, in reply to Michirin9801 ...


Here is my DefleMask test, which is your Misty Blue, with the 1st Matrix Row changed to have empty patterns everywhere except for one test-channel ...

http://www.dropbox.com/s/s98ax5vk1o75xca/vibrato-test.dmf?dl=0

Playing that in DefleMask gives what I'd describe as a wah-wah sound.

It seems audibly less "regular" than the example from Wikipedia.

It's a C1 note, with an $041F effect (speed 1, depth 15).

That's a Vibrato Speed of 1/64th cycle per 1/60s -> 64/60s -> 1.07s-per-cycle, and a Vibrato Depth of, according to the docs, "Maximum depth is a full note.".

OK, if I choose to read "note" as "tone" instead, then we're talking about a range of +/- 1 semitone.

+1 ... -1 = 2 semitones = 1 tone.


Now, looking at the data that's output in the .hes file, the original "period" (not frequency) is $06ae.
And with the vibrato, the period varies between $0673 and $073C.

Here's a quick table of the period values that surround C1 ...

C1# $064F
C1  $06AE
B0  $0714
A0# $0780


Looking at that, you can see that the frequency varies between - 1.5 semitones and + 0.5 semitones.

But looking at the timing data as well shows that the pattern of the vibrato is like this ...

-----
|   |
|   |
    |   |
    |   |
    |   |
    |   |
    |   |
    |   |
    -----


... instead of ...

-----
|   |
|   |
|   |
|   |
    |   |
    |   |
    |   |
    |   |
    -----


Which is why it *sounds* different, to my ear.

BUT, and it's a huge "but", there is nothing "wrong" in absolute terms in having that unbalanced vibrato waveform.

AFAIK it is a valid, if very unusual, choice.

I'm trying to figure out if it's a deliberate "choice", or just a math-error in Delek's implementation.  :-k

Offline elmer

  • Newbie
  • Posts: 31
  • Delek FTW
Huzak - A DMF-based sound driver for PC Engine homebrew.
« Reply #10 on: February 16, 2017, 05:54:49 AM »
The $0Axy, $05xy, $06xy Volume Side effects are now working.  :D

Which was a total PITA since DefleMask is NOT processing those in the way that I'd expect, but ... ho, hum.

The $07xy Tremolo effect is also working, but needs another hour or so of testing to confirm that the "range" is correct.

After this, it's just the $00xy Arpeggio, and $1701 Sample processing left to do.

Oh ... there are also the $12xx & $13xx hardware LFO effects, but since I've never seen anyone waste a channel to use those, they'll only be implemented if someone provides a useful .dmf example that actually needs them.

Offline Pegmode

  • Member
  • Posts: 128
  • Allergic to FM
Huzak - A DMF-based sound driver for PC Engine homebrew.
« Reply #11 on: February 17, 2017, 08:19:52 PM »
Oh ... there are also the $12xx & $13xx hardware LFO effects, but since I've never seen anyone waste a channel to use those, they'll only be implemented if someone provides a useful .dmf example that actually needs them.
EHHHHHHH.

Actually having tried to do something with the LFO it's pretty garbage. The effect is used in the last few patterns....

Offline Fragmare

  • Jr. Member
  • Posts: 52
  • Delek FTW
Huzak - A DMF-based sound driver for PC Engine homebrew.
« Reply #12 on: February 19, 2017, 09:47:15 AM »
I've thought about covering Stab & Stomp! from Battle Garegga, and attempting to use the PCE's LFO effect to simulate that far warbling effect that comes in at around ~0:30 and again at around ~1:30

https://www.youtube.com/watch?v=Q01VRTyO5Yk

Not sure if it could/should be done with LFO, but I still might cover that song

Offline Michirin9801

  • Full Member
  • Posts: 257
Huzak - A DMF-based sound driver for PC Engine homebrew.
« Reply #13 on: February 19, 2017, 06:14:15 PM »
I've thought about covering Stab & Stomp! from Battle Garegga, and attempting to use the PCE's LFO effect to simulate that far warbling effect that comes in at around ~0:30 and again at around ~1:30

https://www.youtube.com/watch?v=Q01VRTyO5Yk

Not sure if it could/should be done with LFO, but I still might cover that song
That effect can't exactly be achieved with LFO, you see, the LFO works more like a vibrato, it doesn't modulate the waveforms like that...
You could achieve a kinda-sorta similar effect with wave-phasing, or with some really extreme use of 2 out-of-phase vibrato channels, but the former would be your best bet and the easiest to accomplish...

Offline Fragmare

  • Jr. Member
  • Posts: 52
  • Delek FTW
Huzak - A DMF-based sound driver for PC Engine homebrew.
« Reply #14 on: February 26, 2017, 09:22:16 AM »
I've thought about covering Stab & Stomp! from Battle Garegga, and attempting to use the PCE's LFO effect to simulate that far warbling effect that comes in at around ~0:30 and again at around ~1:30

https://www.youtube.com/watch?v=Q01VRTyO5Yk

Not sure if it could/should be done with LFO, but I still might cover that song
That effect can't exactly be achieved with LFO, you see, the LFO works more like a vibrato, it doesn't modulate the waveforms like that...
You could achieve a kinda-sorta similar effect with wave-phasing, or with some really extreme use of 2 out-of-phase vibrato channels, but the former would be your best bet and the easiest to accomplish...

Yea, that's about the ONLY effect I've been able to get out of experimenting with the LFO feature is some vibrato... but I could always just use, you know... the actual vibrato effect haha.