SMPS Music Question

Discussion in 'Engineering & Reverse Engineering' started by Alriightyman, Sep 14, 2012.

  1. Alriightyman

    Alriightyman

    I am back... from the dead! Tech Member
    354
    3
    18
    Largo, FL
    0101001101101111011011100110100101100011 00000010: 0101001100000011 01000101011001000110100101110100011010010110111101101110
    In the Voice and Note Editing section of the Music Guide, I had a few questions.

    Does the LFO Enabled have to have a particular value or is it like a switch (off/on)?
    Also, the Total Level is a byte ( and Second Decay as well), is there any restrictions as to what range it has or does it use the full byte (0 - 255)?

    Thanks.
     
  2. flamewing

    flamewing

    Emerald Hunter Tech Member
    1,153
    38
    28
    France
    Sonic Classic Heroes; Sonic 2 Special Stage Editor; Sonic 3&K Heroes (on hold)
    Using the LFO requires you to do a lot of things. First, you have to globally enable the LFO using register 22h of the YM2612; this register has a 1-bit flag (enable/disable) in b3, and a 3-bit frequency selector (bits 0-2). After doing this global enable, you have to enable per-channel sensitivity to the LFO; this is the panning/AMS/FMS byte (YM2612's B4h+ registers). After the global enable and the per-channel sensitivity enable, you then enable the per-operator amplitude modulation flag (the voice bytes you are thinking of). If AMS = 0 for the channel, toggling the LFO enabled [AM] bit in the voice operators does nothing.

    TL is a 7-bit value: 0 is the loudest, 127 is the quietest. The S3&K driver uses bit 7 for another purpose in the voice data -- whether or not the operator in question is an output or feedback channel -- and while the S1 and S2 drivers do the same computation differently, they are nevertheless remarkably consistent about setting bit 7 of TL with this same meaning.
     
  3. Alriightyman

    Alriightyman

    I am back... from the dead! Tech Member
    354
    3
    18
    Largo, FL
    0101001101101111011011100110100101100011 00000010: 0101001100000011 01000101011001000110100101110100011010010110111101101110
    Ok, thanks. So, TL is a 7-bit value, but what is bit-7 actually used for?

    As for enabling LFO, does the sound driver take care of that or is this something a SMPS Song has to do (I didn't see a coordination flag or anything)? Obviously there is something I am still missing here.
     
  4. flamewing

    flamewing

    Emerald Hunter Tech Member
    1,153
    38
    28
    France
    Sonic Classic Heroes; Sonic 2 Special Stage Editor; Sonic 3&K Heroes (on hold)
    Bit 7 of TL is not used by anything for the YM2612; neither is it used in S1 and S2 drivers (even though it is set "correctly" for all songs).

    In all Sonic drivers (S1, S2 and S3+), bit 7 of TL is set on voices for all operators that are output operators, and cleared for feedback operators; this is done based on the algorithm specified in the voice data. There are a few exceptions to this -- there is a song in S3&K (can't remember which one) that has bit 7 set for a feedback operator set In S3+ driver, but if memory serves, no songs have bit 7 clear if the algorithm specifies that the operator in question is an output operator.

    The effect is that for any output operator, the track's current volume is added to the operator's TL (as specified by the voice) before being sent tot he YM2612. Bit 7 is stripped off whether or not it is set (meaning a quiet enough track with a quiet (high) enough TL can result in loud sound) before the result is sent to the YM2612.

    As I said, S1 and S2 drivers ignore bit 7 of TL and decide whether the track's volume should be added to the operator's TL or not in a different (but almost entirely equivalent) way.

    Regarding the LFO: it is something that has to be done manually. For stock S1 and S2 drivers, it can't be done; for S3, S&K and S3D drivers, it can be done, but it is not meant to: coordination flag $E0 can be used to enable AMS and FMS sensitivity for the track (due to an incorrect assumption in the coding of this CF -- valid also for S1 and S2), coordination flag $EE can be used to enable the LFO and set its frequency, and you can specify the AM-enable on the voice data.

    Using CF $E0 to set AMS and FMS data has its downsides -- you can only set bits, you can't clear them. My modified S3&K driver adds a meta-CF ($FF $09) that allows you to send an FM command to the appropriate part of the YM2612 for the current track, meaning you can better configure the AMS and FMS. I have thought of adding explicit support for the LFO through a meta-CF, but it is an exercise in space management; I would also have to finally figure out what it takes to use the driver in S2.
     
  5. ValleyBell

    ValleyBell

    Tech Member
    243
    14
    18
    researching SMPS sound drivers
    Most SMPS 68k games have a seperate LFO coord. flag (usually E9) that handles the LFO. It has 2 parameter bytes. One sets register 22 and enables the AM On bit of all 4 operators (if the respective bit is set) and the other one sets the AMS/FMS bits in the Pan/AMS/FMS register. (That's how Ristar does it, IIRC.)
    I've seen that one too in pre-SMPS drivers (e.g. Ghouls 'n Ghosts: Ending) and SMPS Z80.

    Sonic 1's SMPS driver is a slightly reduced version of the "usual" SMPS driver anyway.