DefleMask Forum

DefleMask => ROM-builders => Topic started by: elmer on January 24, 2017, 04:27:00 PM

Title: Huzak - A DMF-based sound driver for PC Engine homebrew.
Post by: elmer 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) ...
Title: Re: Huzak - A DMF-based sound driver for PC Engine homebrew.
Post by: Michirin9801 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!
Title: Re: Huzak - A DMF-based sound driver for PC Engine homebrew.
Post by: RazerBlue6 on January 30, 2017, 01:32:27 PM
Oh shit, sick, this would be very nice to use in final renders

Kudos to u
Title: Re: Huzak - A DMF-based sound driver for PC Engine homebrew.
Post by: Delek on February 02, 2017, 01:07:16 AM
This is amazing! :)
Title: Re: Huzak - A DMF-based sound driver for PC Engine homebrew.
Post by: Michirin9801 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...
Title: Re: Huzak - A DMF-based sound driver for PC Engine homebrew.
Post by: elmer 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.
Title: Re: Huzak - A DMF-based sound driver for PC Engine homebrew.
Post by: elmer 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!
Title: Re: Huzak - A DMF-based sound driver for PC Engine homebrew.
Post by: elmer 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
Title: Re: Huzak - A DMF-based sound driver for PC Engine homebrew.
Post by: Delek 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.
Title: Re: Huzak - A DMF-based sound driver for PC Engine homebrew.
Post by: elmer 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
Title: Re: Huzak - A DMF-based sound driver for PC Engine homebrew.
Post by: elmer 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.
Title: Re: Huzak - A DMF-based sound driver for PC Engine homebrew.
Post by: Pegmode 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....
Title: Re: Huzak - A DMF-based sound driver for PC Engine homebrew.
Post by: Fragmare 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
Title: Re: Huzak - A DMF-based sound driver for PC Engine homebrew.
Post by: Michirin9801 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...
Title: Re: Huzak - A DMF-based sound driver for PC Engine homebrew.
Post by: Fragmare 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.
Title: Re: Huzak - A DMF-based sound driver for PC Engine homebrew.
Post by: Michirin9801 on February 26, 2017, 06:53:13 PM
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.
And that's exactly why the LFO is useless... Anything it can do, you can do even better with the Vibrato and Detune effects, while freeing up a channel at the same time! So just don't use the LFO, it's a waste of a channel...
Title: Re: Huzak - A DMF-based sound driver for PC Engine homebrew.
Post by: elmer on March 05, 2017, 07:08:13 PM
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.

Well ... whoops, I was wrong about that, and I'd gotten the Tremolo totally wrong!  :o

After another many, many days of creating tests and staring at .hes output, I think that I've finally got all of DefleMask's "quirks" replicated when it comes to the Volume Slide and Tremolo effects.

There are some very strange things going on in there, some of which must surprise the heck out of musicians when they're making their tracks.

Anyway, to celebrate, here's the PCE ROM of Spoony Bard's Blood-Stained Lake.
Title: Re: Huzak - A DMF-based sound driver for PC Engine homebrew.
Post by: RazerBlue6 on March 06, 2017, 08:54:09 AM
The LFO isn't really that useful indeed because of software can just replicate it without losing a channel.

I attached a .dmf that shows what it does and it's not that special lol
Title: Re: Huzak - A DMF-based sound driver for PC Engine homebrew.
Post by: elmer on March 07, 2017, 03:07:05 PM
The LFO isn't really that useful indeed because of software can just replicate it without losing a channel.

I attached a .dmf that shows what it does and it's not that special lol

Thanks!

Yeah, I don't think that there's any point in implementing that effect in Huzak.

You can use the Vibrato effect for a normal frequency-warble, and you can use manual Detune effects for a really-low-speed variation over time if that's what you want to do, both without sacrificing a channel.
Title: Re: Huzak - A DMF-based sound driver for PC Engine homebrew.
Post by: RazerBlue6 on April 28, 2017, 11:04:38 AM
Has there been any progress on this still?
Title: Re: Huzak - A DMF-based sound driver for PC Engine homebrew.
Post by: elmer on April 28, 2017, 03:32:21 PM
Not much since Huzak was used to make the PCE ROMs for Michirin9801's last album.

https://michirin9801.bandcamp.com/album/best-of-michirin-vol-1

Working on that pointed out a few important bugs in Huzak that have been fixed, and now all of that album's PCE .dmf files (that don't use samples), play back fine with Huzak.

As does SpoonyBard's track that I converted, and a couple of Fragmare's tracks that don't use samples.

I still need to add arpeggio, retrigger and sample support to Huzak, but have taken a break from the tedious (and totally pointless waste-of-time) of reverse-engineering Delek's playback choices from .hes files.

It's on my list of things to get back to, but since there's only one homebrew project that currently needs it, and they don't need it *yet* ... I've been working on other higher-priority tasks.

P.S. I'm also kinda waiting to see what Delek does with v12.1, and whether it's going to implement the noise-mode switching in the Wave Macro that people have been asking for.
Title: Re: Huzak - A DMF-based sound driver for PC Engine homebrew.
Post by: cTrix on May 04, 2017, 03:10:25 PM
Appreciating the work you are doing here!  Looking forward to making some PCE tunes with Defle.

I got half way though coding and cobbling together an OpenMPT > MML > HuSIC > Compiler workflow and gave up due to my early tests misinterpreting commands and additional tuning / timing issues.  For a simple converter that just did note on / off with a similar sounding result to the preview, it worked for some of the note range - but anything beyond that just started getting too tricky.  (Making a wav generator to create preview samples was fun though!)

If I get some time, I'll try and get you some additional DMF source files. (I only have a bunch of test phrases at this point).

I'm happy to do hardware testing for you if you need it (have 2 PC engines + flash card kit)
Title: Re: Huzak - A DMF-based sound driver for PC Engine homebrew.
Post by: elmer on May 07, 2017, 06:58:06 PM
I got half way though coding and cobbling together an OpenMPT > MML > HuSIC > Compiler workflow and gave up due to my early tests misinterpreting commands and additional tuning / timing issues.  For a simple converter that just did note on / off with a similar sounding result to the preview, it worked for some of the note range - but anything beyond that just started getting too tricky.

Ouch, that must have been an absolute monster to try to get working! I sympathize.

If Delek had actually released a C-code standalone .dmf player, then at-least people could have seen how he was processing his effects-chain, and a lot of the mind-numbingly tedious reverse-engineering and guessing could have been avoided, especially when it comes to things like the complex interactions between the Channel-Volume/Volume-Slide/Tremolo/Volume-Macro.


Quote
If I get some time, I'll try and get you some additional DMF source files. (I only have a bunch of test phrases at this point).

I'm happy to do hardware testing for you if you need it (have 2 PC engines + flash card kit)

More PCE .dmf files are always useful, thanks!

As for real hardware, thanks again, but I have plenty of it and Huzak seems to be working fine.

The most-important tests (from my POV) are having the people that create music in DefleMask actually try out Huzak, and point out if it sounds different to DefleMask (it generally shouldn't).

Although some of the things that DefleMask supports will never be usable in Huzak, because it's targeted for in-game usage, and can't afford the lunacy of things like 32KHz/22KHz/11KHz samples.

7KHz (which DefleMask doesn't support) is the "sane" game-usable sample-rate on the PCE, unless you're using the CD's ADPCM chip (which DefleMask also doesn't support).

Even then, as people like Falcom (back in the day) and Michirin9801 (in the modern day) have shown, you don't need samples to make good drumkits and percussion on the PCE ... although (IMHO) Delek badly needs to add support for the Wave Macro Noise Switching capability that people are asking for, and also support the extra Noise Frequencies that the PCE hardware supports.
Title: Re: Huzak - A DMF-based sound driver for PC Engine homebrew.
Post by: RazerBlue6 on October 08, 2017, 08:44:01 PM
Hey Elmer, I made an account for the PC Engine forum, currently waiting on getting an active account.

Wanted to let you know I have a file that will probably put Huzak to the test.
It does have PCM, but I am not interested in having the PCM converted; the PSG stuff is quite heavy enough I think.
Here's a link to it. https://soundcloud.com/deltarazero/masked-byte

If you're interested, I'll hear that from you and I'll send the .dmf your way.
Title: Re: Huzak - A DMF-based sound driver for PC Engine homebrew.
Post by: Delek on October 10, 2017, 07:35:55 PM
although (IMHO) Delek badly needs to add support for the Wave Macro Noise Switching capability that people are asking for, and also support the extra Noise Frequencies that the PCE hardware supports.
This is already working in the Develop version of the tracker. Will be released soon.
Title: Re: Huzak - A DMF-based sound driver for PC Engine homebrew.
Post by: Michirin9801 on October 11, 2017, 02:46:06 AM
although (IMHO) Delek badly needs to add support for the Wave Macro Noise Switching capability that people are asking for, and also support the extra Noise Frequencies that the PCE hardware supports.
This is already working in the Develop version of the tracker. Will be released soon.
Yay~ Looking forward to that!
Title: Re: Huzak - A DMF-based sound driver for PC Engine homebrew.
Post by: elmer on October 27, 2017, 04:08:28 PM
Wanted to let you know I have a file that will probably put Huzak to the test.
It does have PCM, but I am not interested in having the PCM converted; the PSG stuff is quite heavy enough I think.
Here's a link to it. https://soundcloud.com/deltarazero/masked-byte

If you're interested, I'll hear that from you and I'll send the .dmf your way.
Hi! Sorry I've been so quiet recently.

That tune sounds really nice, and I think that I can hear a few effects in there that will give me some new features to test.  8)

I'm not opposed to PCM ... but just dreading the amount of programming time-and-fiddling that it will take to have my DMF2HUZ program automatically convert the samples to 7KHz for playback, and then lay them out in a form that HuC won't choke on (since most of huzak's target modern PCE developers don't write in assembly).


This is already working in the Develop version of the tracker. Will be released soon.
That's absolutely excellent, thanks!  ;D

I really hope that you'll document how you've implemented those features so that I can make huzak compatible without spending too many hours staring at dumps of .hes files!
Title: Re: Huzak - A DMF-based sound driver for PC Engine homebrew.
Post by: MooZ on May 17, 2018, 01:23:35 PM
Sorry for necro-posting but is there any news ?