Author Topic: Huzak - Yet another music driver  (Read 13118 times)

elmer

  • Hero Member
  • *****
  • Posts: 2148
Re: Huzak - Yet another music driver
« Reply #75 on: January 17, 2017, 11:26:08 AM »
Oh, don't worry about samples right now, first get the thing up and running! I can't wait to hear the results

Getting there!

May I just take the opportunity to say that Deflemask's .hes export if full of totally-redundant register writes! Arrggghhh!!!  #-o


Anyway here's the current work-in-progress HuCard image ...

http://www.dropbox.com/s/rikzc643iafmpkr/Huzak1stWIP.pce?dl=0


I think that it shows that there's been at least a little progress.  :-k

Michirin9801

  • Hero Member
  • *****
  • Posts: 589
Re: Huzak - Yet another music driver
« Reply #76 on: January 17, 2017, 12:30:36 PM »
Oh, don't worry about samples right now, first get the thing up and running! I can't wait to hear the results

Getting there!

May I just take the opportunity to say that Deflemask's .hes export if full of totally-redundant register writes! Arrggghhh!!!  #-o


Anyway here's the current work-in-progress HuCard image ...

http://www.dropbox.com/s/rikzc643iafmpkr/Huzak1stWIP.pce?dl=0


I think that it shows that there's been at least a little progress.  :-k

Hooray~!!
This is great! I'm so glad to be able to hear my cover being used on a proper Rom ^^
The only thing that's missing from what I can hear is the note slide effect (03xx) and other than that, the only issue is that the Noise mode is noticeably louder in here than it is in Deflemask, but the same thing happens in Deflemask's own .hes exports so I'm sure this is a Deflemask problem and not a Huzak problem...

Great job mate! Keep it up ^^

ccovell

  • Hero Member
  • *****
  • Posts: 2245
Re: Huzak - Yet another music driver
« Reply #77 on: January 17, 2017, 12:35:45 PM »
Sounds great!

Will your final ROMs/binaries be in a format that can be easily INCBINed and JSRed to from inside of a demo? :)

elmer

  • Hero Member
  • *****
  • Posts: 2148
Re: Huzak - Yet another music driver
« Reply #78 on: January 17, 2017, 02:37:22 PM »
Great job mate! Keep it up ^^

Thanks!   :D


Quote
The only thing that's missing from what I can hear is the note slide effect (03xx) and other than that, the only issue is that the Noise mode is noticeably louder in here than it is in Deflemask, but the same thing happens in Deflemask's own .hes exports so I'm sure this is a Deflemask problem and not a Huzak problem...

Yep ... the Portamento Effects ($01xx, $02xx & $03xx) are the next things to implement.  :wink:

Misty Blue uses both "Portamento Down" and "Porta to Note".

The difference between the drums in Deflemask and Huzak was driving me nuts ... and then I checked the .hes and found that I was writing exactly the same values to the PSG registers.

I've been using Mednafen for long enough now that I completely trust its emulation ... so I *suspect* that it's a problem with the Ootake emulator that Delek is using inside Deflemask.

I've seen that the problem has been talked about on the Deflemask forums for a while now.

I might try putting in some code to decrease the volume when the noise is enabled.

That would be *nasty* ... but it might be good-enough for a while until a proper fix can be found, or until we find out that something else is causing the problem.


Will your final ROMs/binaries be in a format that can be easily INCBINed and JSRed to from inside of a demo? :)

I'd kinda rather not output the song data as a binary, if I can avoid it.  :-k

The whole idea is to have a toolchain that *developers* can use.

The PCE ROM is just a testbed that I hope to keep improving on so that a musician can hear how things will sound in the game.

The driver itself is completely separate.

There are just a simple functions to hook into your game's own handlers, effectively just ...

KillAllSound()
PlayTune()/KillTune()
PlaySfx()

UpdateAt60Hz()


The converter spits out a source file with some predefined table names that the driver is looking for.

Here's the page on the Deflemask forum where you can download Michirin9801's original .dmf file ...

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


And here's the converted output for the Misty Blue track ...

http://www.dropbox.com/s/d7l8j7wdceaaof6/MistyBlueOpening.s?dl=0


As a programmer, you'll see that the structure is pretty simple.

The only real complexity is in the encoding of the pattern data, and that's a simple bytestream with the following coding ...

Code: [Select]
; Huzak Notes ($00..$57)
;
; Note equates (PC Engine, 440Hz = A4).
;
; HK_CMD_C4 = MIDI note #60 for A440 tuning.
;
; Deflemask displays notes 1 octave lower (440Hz = A3).

HK_CMD_A0 .equ $00 ; T (+0) 0x00..0x57
..
HK_CMD_C1 .equ $03
..
HK_CMD_C8 .equ $57

; Huzak Commands (with data parameter, if needed)

HK_CMD_END .equ $58 ; . (+0) End-of-Pattern
HK_CMD_PAG .equ $59 ; . (+0) Span a 256-byte page offset
HK_CMD_BRK .equ $5A ; . (+0) Pattern Break
HK_CMD_JMP .equ $5B ; . (+1) Set next Matrix Row
HK_CMD_SP0 .equ $5C ; . (+1) Set Even Row Speed
HK_CMD_SP0_TIE .equ $5D ; T (+1) Set Even Row Speed + TIE
HK_CMD_SP1 .equ $5E ; . (+1) Set Odd Row Speed
HK_CMD_SP1_TIE .equ $5F ; T (+1) Set Odd Row Speed + TIE

HK_CMD_PSG .equ $60 ; . (+0) Sample Mode Off
HK_CMD_PCM .equ $61 ; . (+0) Sample Mode On
HK_CMD_NZ0 .equ $62 ; . (+0) Noise Mode Off
HK_CMD_NZ1 .equ $63 ; . (+0) Noise Mode On

HK_CMD_BNK .equ $64 ; . (+1) Select Sample Bank
HK_CMD_INS .equ $65 ; . (+1) Select Instrument
HK_CMD_TIE .equ $66 ; T (+0) Note Tie
HK_CMD_OFF .equ $67 ; T (+0) Note Off

HK_CMD_CDT .equ $68 ; . (+1) Channel Detune
HK_CMD_DEL .equ $69 ; T (+1) Note Delay
HK_CMD_CUT .equ $6A ; . (+1) Note Cut
HK_CMD_CUT_TIE .equ $6B ; T (+1) Note Cut + TIE

HK_CMD_PAN .equ $6C ; . (+1) Set Panning
HK_CMD_PAN_TIE .equ $6D ; T (+1) Set Panning + TIE
HK_CMD_PFF .equ $6E ; . (+0) Set Panning to $FF
HK_CMD_PEE .equ $6F ; . (+0) Set Panning to $EE

HK_CMD_GLI .equ $70 ; . (+1) Volume Slide/Glide
HK_CMD_GLI_VIB .equ $71 ; . (+1) Volume Slide/Glide + Vibrato

HK_CMD_VIB .equ $72 ; . (+1) Vibrato
HK_CMD_PUP .equ $73 ; . (+1) Portamento Up
HK_CMD_PDN .equ $74 ; . (+1) Portamento Down
HK_CMD_PTN .equ $75 ; . (+1) Portamento to Note

; Huzak Commands (with embedded data value)
;
; LEN & WAV both use an embedded value of 0 to signal that the
; true value is in the next byte.

HK_CMD_LEN .equ $80 ; . (+V) $80..$9F Event length (in rows)
HK_CMD_VOL .equ $A0 ; . (+0) $A0..$BF Channel Volume
HK_CMD_WAV .equ $C0 ; . (+V) $C0..$FF Select Wavetable

Michirin9801

  • Hero Member
  • *****
  • Posts: 589
Re: Huzak - Yet another music driver
« Reply #79 on: January 17, 2017, 03:53:32 PM »
Great job mate! Keep it up ^^

Thanks!   :D

No problem ^^

And here's the converted output for the Misty Blue track ...

http://www.dropbox.com/s/d7l8j7wdceaaof6/MistyBlueOpening.s?dl=0

That link was for an outdated version, but I've just updated it with the current version so no worries now ^^

Also, I appreciate your solution for the noise mode's volume, but I've also been taking it into account in the songs I've been making lately! I'm currently covering the Asuka 120% Burning Fest soundtrack on the PCE, all of them with the noise volume in mind...
But still, I'm not the only one who's gonna be making songs for this driver, and the others might not know about the noise volume issue, so I do encourage you to implement this change, at least while the issue persists, as for me, it's all a matter of cranking the volume of the noise mode back up in the DMFs, so no biggy... Keep it up! ^^

DarkKobold

  • Hero Member
  • *****
  • Posts: 1198
Re: Huzak - Yet another music driver
« Reply #80 on: January 17, 2017, 04:06:12 PM »
Will your final ROMs/binaries be in a format that can be easily INCBINed and JSRed to from inside of a demo? :)
I'd kinda rather not output the song data as a binary, if I can avoid it.  :-k

The whole idea is to have a toolchain that *developers* can use.



Hey elmer, I'm having a real hard time following this. (Hell, I've been lost since this whole music issue came to light, so nothing new. :D ) How would you see someone include a delfmask song, or a 5bit sample in their code, if its not an 'include' statement?
Hey, you.

elmer

  • Hero Member
  • *****
  • Posts: 2148
Re: Huzak - Yet another music driver
« Reply #81 on: January 18, 2017, 04:44:52 AM »
How would you see someone include a delfmask song, or a 5bit sample in their code, if its not an 'include' statement?

You'd do an assembly-language-source ".include", rather than a ".incbin" or a HuC "#incbin".

It's more like a HuC "#include", but for assembly-language source.

Wrapping it all up into something that you guys can use on Catastrophy may well require moving to some binary format so that you can switch which banks hold the tune and sound-effects data for each level.

I suspect that the current data format (without banking) is going to be limited to 2 or 3 tunes (there is maximum of 255 "patterns").

elmer

  • Hero Member
  • *****
  • Posts: 2148
Re: Huzak - Yet another music driver
« Reply #82 on: January 21, 2017, 01:36:22 PM »
That link was for an outdated version, but I've just updated it with the current version so no worries now ^^

Also, I appreciate your solution for the noise mode's volume, but I've also been taking it into account in the songs I've been making lately! I'm currently covering the Asuka 120% Burning Fest soundtrack on the PCE, all of them with the noise volume in mind...

Thanks for the updated version ... I love it!  :D

If I'm not misreading things, you actually moved a whole bunch of stuff around between channels ... or perhaps I'm just having another "senior moment".  :-k

I really appreciate that you're trying to compensate for the difference, but I really, really, really hope that we can come up with a better solution so that "what you hear is what you get".

I hope that Delek will fix the volume issue, or just start using Mednafen as the base for the PCE emulation, and so there won't be a need for a nasty hack in the future ... sometime.  :pray:

In the meantime, here's the latest version of huzak, with all of the Portamento effects implemented ($01xx, $02xx, $03xx, $E1xy, $E2xy).

I've also implemented the hack to change the volume on any channels that are in "noise" mode, and have included a bunch of different HuCard ROMs with different settings.

Michirin9801: Can you please try these different ROMs and let me know what the proper volume-reduction is?

I've included 5 versions of Misty Blue, with reductions ranging from -1 to -5.

I *think* that the correct setting is either -2 or -3, but I don't trust my ears enough to make the call myself ... so I'm going to have to rely on your superior knowledge of your own track.  :wink:


At this point, once we've got that "correction" sorted-out, I'm *thinking* that "Misty Blue" is playing correctly in Huzak. If anyone can hear a problem ... I'd love to know.

I'm not sure what to tackle next. Probably the volume-slides, since that should be fairly easy.

The big problems are going to be with the Vibrato and Detune effects, because those are going to be horrible to reverse-engineer, and it would make much more sense to just ask Delek what he's doing ... except that he's currently awol from the Deflemask forums.

Anyway, here is the current set of ROMs, they sound pretty good to me ...

http://www.dropbox.com/s/vlj2ktwdhom34n6/huzak2ndWIP.zip?dl=0

DarkKobold

  • Hero Member
  • *****
  • Posts: 1198
Re: Huzak - Yet another music driver
« Reply #83 on: January 21, 2017, 02:21:46 PM »
How would you see someone include a delfmask song, or a 5bit sample in their code, if its not an 'include' statement?

You'd do an assembly-language-source ".include", rather than a ".incbin" or a HuC "#incbin".

It's more like a HuC "#include", but for assembly-language source.

Wrapping it all up into something that you guys can use on Catastrophy may well require moving to some binary format so that you can switch which banks hold the tune and sound-effects data for each level.

I suspect that the current data format (without banking) is going to be limited to 2 or 3 tunes (there is maximum of 255 "patterns").


This sounds super complicated. Also, would it be possible to have one bank have all the sound effects?
Hey, you.

Michirin9801

  • Hero Member
  • *****
  • Posts: 589
Re: Huzak - Yet another music driver
« Reply #84 on: January 21, 2017, 02:30:47 PM »
The -2 version sounds about right, the only inaccuracy I can spot from what I've put in Deflemask is on channel 4 when the song loops, the thing is that Deflemask automatically cuts off notes when it loops back to the beginning of the song (I don't recall if it happens when it loops with the 0Bxx effect though, it probably does), but in the rom the note that was still playing on channel 4 when the song loops keeps on playing instead of being cut off...
Why does it only happen on channel 4 you ask? Because all the other channels have notes playing immediately as the song starts/loops, I'm sure the same thing would happen in more channels if they didn't have notes right at the start... One way to fix that one my end would be to just put a note off in the beginning of the song in channel 4, but I can already imagine how you're gonna feel about that...
Otherwise, it's great! Just like how I remember it on Deflemask ^^
Great job!

If I'm not misreading things, you actually moved a whole bunch of stuff around between channels ... or perhaps I'm just having another "senior moment".  :-k
The version I had sent you before through my sta.sh was the updated version already >w>
But the version that was still there on the Deflemask forum was old, the most notable change I did was replace one of the wavetables with a new one, but I forgot what else I did in the update... Still it's better and more accurate to the original than the old version which you can still hear in my youtube channel...

elmer

  • Hero Member
  • *****
  • Posts: 2148
Re: Huzak - Yet another music driver
« Reply #85 on: January 23, 2017, 01:35:07 PM »
The -2 version sounds about right, the only inaccuracy I can spot from what I've put in Deflemask is on channel 4 when the song loops, the thing is that Deflemask automatically cuts off notes when it loops back to the beginning of the song (I don't recall if it happens when it loops with the 0Bxx effect though, it probably does), but in the rom the note that was still playing on channel 4 when the song loops keeps on playing instead of being cut off...

OK, thanks!  :D

I'll use the -2 setting from now on, until we can get a better fix.

Nice catch on hearing the problem with the looping!  :wink:

Actually, it prompted me to finally implement the Pattern Break and Position Jump effects properly, so it was a good time to find that problem.


Quote
Why does it only happen on channel 4 you ask? Because all the other channels have notes playing immediately as the song starts/loops, I'm sure the same thing would happen in more channels if they didn't have notes right at the start... One way to fix that one my end would be to just put a note off in the beginning of the song in channel 4, but I can already imagine how you're gonna feel about that...

Well, I've tested what DefleMask does, and I think that I've replicated it, now.

From what I can see, it cuts off notes when you do a Position Jump backwards, but it keeps on playing them if you do a Position Jump forwards, or do a Pattern Break.

I would have thought that you'd actually want to keep the notes playing, even when you loop around ... I can easily imagine that a musician might make use of that.

It's always easy to put a Note Off on a channel at the start of a loop if you want it to stop.

A Note Off is a cheap and easy to do, so I'd rather allow the musician to be able to take advantage of keeping notes playing across the loop-point, if that's what they want.

But ... it doesn't really matter what I think, it's more important to make it behave the same.


***********

Anyway, here's another build with the channel cutting off properly now, and, just-for-laughs, I've also tried to implement the appropriate PC-8801 look to the screen.

The PC-8801 font looks like it's 10-pixels high instead of 8, which we can't do without an expensive bitmap, so I've had to reuse the current font (with a few changes).

So it doesn't really look like the PC-8801, it's more "inspired-by".

Then I added a drop-shadowed version, too, because I firmly believe that drop-shadows make everything better!  :lol:

After some serious squeezing, it's all packed down into an 8KB ROM, but this is probably the last time that I'll try to do that, because it was a severe PITA.


http://www.dropbox.com/s/l3lt0s4ko40c93g/MistyBlueHuzak.zip?dl=0

Go ahead and share this one, if you like; I'm going to post a link to it on the DefleMask forum later on.  :wink:

Michirin9801

  • Hero Member
  • *****
  • Posts: 589
Re: Huzak - Yet another music driver
« Reply #86 on: January 24, 2017, 03:42:11 AM »
I would have thought that you'd actually want to keep the notes playing, even when you loop around ... I can easily imagine that a musician might make use of that.

It's always easy to put a Note Off on a channel at the start of a loop if you want it to stop.

Here's the thing, we certainly would want that, it would make it a lot easier to optimise the song to use less patterns, you have no idea how many times I had to repeat patterns upon patterns in order to have the songs sound the way I want it to sound, or make a new instrument that was just the note still playing, but Deflemask just cuts off the notes when you jump backwards in the song and doesn't care whether you wanted the note to keep playing or not...

Anyway, here's another build with the channel cutting off properly now, and, just-for-laughs, I've also tried to implement the appropriate PC-8801 look to the screen.

The PC-8801 font looks like it's 10-pixels high instead of 8, which we can't do without an expensive bitmap, so I've had to reuse the current font (with a few changes).

So it doesn't really look like the PC-8801, it's more "inspired-by".

Yaaay~ Now it looks a lot more fitting ^^
Oh and, don't worry about that! Yeah it's not an exact replica, but it's plenty close enough!
I also really like the drop-shadow version, great job! ;3

I can no longer spot any inaccuracies with this, it's spot-on with what I've put in Deflemask!
If you can, I'd love to hear you try out these songs with Huzak:
Super Adventure Island 2 - Poka Poka Island:
http://sta.sh/0a46xfxbn2z

Thunder Force IV - Fighting Back:
http://sta.sh/01l3peenzmer

Dragon's Curse - Sidecrawler's Dance:
http://sta.sh/016eybd647y4

None of them has any samples!
« Last Edit: January 24, 2017, 03:46:35 AM by Michirin9801 »

elmer

  • Hero Member
  • *****
  • Posts: 2148
Re: Huzak - Yet another music driver
« Reply #87 on: January 26, 2017, 10:49:51 AM »
If you can, I'd love to hear you try out these songs with Huzak:

Definitely! But they're all going to need me to implement some of the "missing" effects.

Super Adventure Island 2 - Poka Poka Island:

  Ch2 Mtx05 vibrato $0464 by itself, this effect is used LOTS!

  Detune $E588 on Octave 2 notes G
  Detune $E588 on Octave 3 notes D E
  Detune $E590 on Octave 3 notes F

  Mtx 32 Pattern Break in Ch1 and note later in Ch5


Thunder Force IV - Fighting Back:

  Detune $E590 on Octave 4 notes F C G

  Ch2 Mtx25 vibrato $0464 by itself.


Dragon's Curse - Sidecrawler's Dance:

  Detune $E588 on Octave 2 notes A B E F# G#
  Detune $E588 on Octave 3 notes C# D E

  Pattern Break, again.


Now, the Pattern Breaks should already be working, and I've noted them just to remind my to check on that, but the Detune and Vibrato effects are the exact ones that I've mentioned before that I need information from Delek in order to implement.  ](*,)


Well, I've done some digging, and some looking at .hes files, and have found the original ProTracker source code online, and that has given me a good idea of how Delek is processing those effects in DefleMask.

The most-important thing is that I can see now how he's implemented the Vibrato sine-wave, and what its "speed" parameter means.

So I have a decent chance of implementing those effects now, even without Delek's help, but it will take a little time, and it is definitely going to take up some extra memory.

I'm can't see any way around needing to have a fast-multiply available in order to get those effect running, and that means that I'm going to need to include another 2KB of tables to do that quickly-and-efficiently.

Then there's a question of the "Vibrato" effect itself.

Can you tell me how it is *supposed* to work?

From the documentation, it looks like setting Vibrato Depth of "F" should give you a one semitone range for the effect, +/- 1/2 semitone from the original note.

As it is, it looks like there is a bug in Delek's math, because what is actually spit out in the .hes file is + 0.5 semitones, but - 1.5 semitones.

Even worse, it's not a pure sinewave, but the +ve part of the cycle takes the same amount of time as the 3-times-greater -ve part of the cycle, creating a very strange-sounding result.  #-o

Is that intentional, or is it just a bug?  :-k

Gredler

  • Guest
Re: Huzak - Yet another music driver
« Reply #88 on: January 26, 2017, 11:12:00 AM »
I just wanted to pop in and thank you for doing all this hard work Elmer, and Michirin9801 thank you for providing him with such useful examples, awesome work everyone!

Looking forward to hearing more!

Michirin9801

  • Hero Member
  • *****
  • Posts: 589
Re: Huzak - Yet another music driver
« Reply #89 on: January 26, 2017, 11:41:14 AM »
Then there's a question of the "Vibrato" effect itself.

Can you tell me how it is *supposed* to work?

From the documentation, it looks like setting Vibrato Depth of "F" should give you a one semitone range for the effect, +/- 1/2 semitone from the original note.

As it is, it looks like there is a bug in Delek's math, because what is actually spit out in the .hes file is + 0.5 semitones, but - 1.5 semitones.

Even worse, it's not a pure sinewave, but the +ve part of the cycle takes the same amount of time as the 3-times-greater -ve part of the cycle, creating a very strange-sounding result.  #-o

Is that intentional, or is it just a bug?  :-k
Now you caught me off-guard, I'm unsure on how 'exactly' it's supposed to work, but from what I can hear on the tracker itself, setting it to 04xF really has a difference of 1 semitone both upwards and downwards, but it seems to linger on the higher pitch of the vibrato effect a little longer than it does on the lower pitch, but maybe I'm mishearing things...
I tried exporting a .hes file with just a note playing in vibrato on a single channel but it doesn't want to work with Mednafen, and well, if it doesn't work with Mednafen, it won't work with anything because Mednafen runs Deflemask's .hes exports better than anything else I've ever tried using...

I just wanted to pop in and thank you for doing all this hard work Elmer, and Michirin9801 thank you for providing him with such useful examples, awesome work everyone!

Looking forward to hearing more!

Oh no problem! In fact, I'm just as excited about this ^^