Help wanted for sound & music stuff

Discussion in 'Discussion and Q&A Archive' started by SpirituInsanum, Mar 19, 2013.

Thread Status:
Not open for further replies.
  1. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    It's time for my hack to sound somewhat decent.

    I'd need a way to turn all the music and sound files into asm. That would be fairly easy (I'd probably simply use equates and dc.b/w) if not for the stupid little-endianness & absolute addressing style of the z80 driver I'm using.

    Of course, the point of the whole change is to move them easily while making edition a little more user friendly (the user being me in this case, so I care a bit). I'll have to import sounds from the other games, and it seems to be the main issue.

    So, is there an easy way to deal with this problem? What I'd like is a kind of easy to use macro for all the header/jump/conditional jump and such. Something that works for both sounds and musics if possible. I guess the assembler has such hidden functions somewhere, but the documentation seems hard to find. :/

    Also, I'll have requests for some music in the near future, so I'll need volunteers for a bunch of adaptations and most likely remixes (and because I'm very bad at this, I have very high expectations :D ).

    -Edit: to make it easier to understand, I'd need a macro which would be equivalent to:

    dc.w ((music1_address+music1_voices)&$00FF<<8+(music1_address+music1_voices)&$FF00>>8) ;  (I think it would be something like this)

    for the voice pointer in the header, with music1_address and music1_voices as parameters (or even better only music1, but I'm not that optimistic). 

    And others for the loops and such, but once I'll have the first one it should be easy for me to create the other ones.
     
    Last edited by a moderator: Mar 19, 2013
  2. Spanner

    Spanner The Tool Member

    Joined:
    Aug 9, 2007
    Messages:
    2,570
  3. ThomasThePencil

    ThomasThePencil resident psycho Member

    Joined:
    Jan 29, 2013
    Messages:
    910
    Location:
    the united states. where else?
    Hold on there, Spanner. It doesn't seem like he's using the Sonic 1 sound driver; the Sonic 1 driver uses relative addressing, not absolute addressing. I would say he's using the Sonic 2 sound driver, as it is a Z80 driver just like the one he's mentioning and if I recall correctly it uses absolute addressing, but even the Sonic 2 sound driver isn't written in fucking little-endian (because that would make it even more of a pain in the arse to work with than it already is :p).
     
  4. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,902
    Location:
    italy
  5. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    Nope, I tried that and it gives me an error message about a dll I don't have. Besides, it looks like it turns the data into an asm version compatible flamewing's sound driver, which won't compile properly with s1 (apparently "function" is not supported by the assembler).
     
  6. Crash

    Crash Well-Known Member Member

    Joined:
    Jul 15, 2010
    Messages:
    302
    Location:
    Australia
    I've rewritten the macros in flamewing's _s1smps2asm_inc.asm file to be compatible with the Sonic 1 and Sonic 3 drivers. It's kinda messy and unfinished and not really ready for public release, and it might not actually work properly outside of my hack, but it might be an alright starting point for you: https://dl.dropbox.com/u/54418567/_s1smps2asm_inc.asm
     
  7. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    Thanks Crash, it helps a lot. It's easy to read so I made it work easily enough.

    But now I have to convert all the original musics and do all my changes and fixes again. So...

    Another question now:

    In order to "fix" (let's call that fixed haha) the music of spring yard, I originally had to double the length of notes for all channels excepted FM4 (and increase the global pitch or something like that). FM4 uses the flag E5 to increase its speed ("dividing timing for the current track"), but I can't find any equivalent for it in s3's sound driver.

    What would be the best workaround for this?

    Edit: Since apparently there's no other way, I did it again. It doesn't sound great but it works.
     
    Last edited by a moderator: Mar 20, 2013
  8. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    I have a very specific question:

    What are the instruments (voices) supposed to be in Labyrinth's music? And/or what would be good alternative voices?

    I really want to change them, have the whole thing give it an 'ancient ruins in a jungle' ambiance. I tried quite a few combinations but it's obvious I can't make anything good by replacing voices at random. :/
     
    Last edited by a moderator: Mar 22, 2013
  9. Crash

    Crash Well-Known Member Member

    Joined:
    Jul 15, 2010
    Messages:
    302
    Location:
    Australia
    In the original demo the lead's a plucky sounding synth with brass and strings as backing.

    http://www.youtube.com/watch?v=XP4k7Q5dlK0

    You could probably use flute/pan pipe sounding instruments for the backing, but 'jungle' themed music tends to have a lot of percussion so you might need to do more than just replace the voices to get the sound you're after.
     
  10. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    A pan pipe, that's an excellent idea. :)

    I've been listening through the musics of s1->s3d, but couldn't identify any (I can hardly tell a piano from a brass though, so it doesn't mean there isn't any >_> ).

    Does anybody know if there's one in a music so I could take it from there? Either that or a pan pipe voice in smps voice format if there's such a thing.

    I couldn't find flutes and such in the voice archive btw, is there any?
     
  11. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,902
    Location:
    italy
    The closest thing you can find is probably the instrument that plays some background notes in Aquatic Ruin Zone, which is basically a triangle wave. Its SMPS data, in Sonic 1 format, is 3A 32 01 52 31 1F 1F 1F 18 01 1F 00 00 00 0F 00 00 5A 0F 03 1A 3B 30 4F 00. I'm not sure if there are better flutes at all.
     
  12. c1owd

    c1owd Previously 'CarrascoZX0' Member

    Joined:
    Dec 13, 2008
    Messages:
    364
    39 08 06 04 12 1F 1F 1F 1F 14 09 09 02 00 00 00 00 8B 5A 3A 3A 10 28 29 80 - Dangerous Seed / Flute (Lower the channel an octave.)
    03 06 04 32 02 14 12 0E 0E 00 12 10 0C 00 00 00 00 0A 3A 5A 1A 26 28 24 00 - "E. Flute"
    3A 04 08 08 04 14 12 0F 0E 05 0F 0F 02 00 00 00 00 1E 2E 2E 0E 32 32 2D 00 - "Old Flute" (Lower the channel an octave.)
    2B 32 04 32 72 14 12 0E 4E 00 12 10 0C 00 00 00 00 0A 3A 5A 1A 1C 22 28 00 - "E. Flute 2" (^)
    3B 06 02 02 01 12 14 19 4F 08 05 01 01 01 01 01 01 76 FA F8 F9 1F 39 1F 00 - "Flute"

    Try these. =)

    EDIT: Also, the voice nineko posted is a really good one too.
     
    Last edited by a moderator: Mar 23, 2013
  13. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    Thanks.

    I tried them, almost got the old flute to sound good there, but... Is there some kind of special volume trick about those?

    It seems just impossible to change it, they always play at the same volume. Setvol and altervol (E4 and E6 in s3's driver) are simply ignored with those voices. :|

    I tried with another voice (a brass from the uvb) and the volume is properly changed where it has to be, but as soon as I switch to one of those, the volume changes don't work anymore. :/

    edit: btw, do I have to change Nineko's flute from s2's voice format?

    edit 2: after experimenting a bit with the voice parameters, it *looks* like the last one on the line will allow volume control. Is that right? If I set it to 80, I'm apparently allowed to increase and decrease the volume, but I'm not sure it really sounds the same (maybe the 3 parameters before it have to be changed as well?)
     
    Last edited by a moderator: Mar 23, 2013
  14. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,902
    Location:
    italy
    I already performed the byte swap for you. I only deal with instruments formatted for Sonic 1/3/K.

    You're on the right track, but you should learn more about the algorithms before you edit the "volume" in that way. Basically, the last 4 bytes alter the "total level" of the instrument, but how and in which order depend on the algorithm. The fourth one (e.g. the very last one, as you noticed) is always an output operator, but the other three might be processed in different ways. Yes, 00 = 80 = max (the MSb is ignored), and increasing it will decrease the volume, but I don't recommend you to edit instruments in this way (even though I often do that, it's not good practice). If you are interested, you can download the 2612 Instrument Editor (originally written by me, then improved by ValleyBell) and play around with that. It's included in ValleyBell's mid2smps download pack, I think. As I said I don't use it because I like to work with pure hex but that's because I know how algorithms work.
     
    Last edited by a moderator: Mar 23, 2013
  15. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    Aaw sorry, I forgot you wrote that... -_-

    Well, I really just wanted some control over the volume (therefore that question about versions, although I really can't tell the difference with those bytes swapped), if replacing the final 00 with 80 is enough and doesn't break anything, that's ok for me. ^^'

    I couldn't make the flute work with other instruments though. So far the best I have is a mix of voices from the uvb and marble garden, +hi wood block and mid tom for the dac.

    Any volunteer to test it (I'll pm it) and tell me if it's somewhat acceptable from a musical standpoint?
     
  16. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,902
    Location:
    italy
    Hold on, 00 == 80, since the MSb (Most Significant bit, not to be confused with MSB (Most Significant Byte)) is ignored. If you replaced 00 with 80 it should yield no effect at all. To reduce the volume you should increase the value.
     
    Last edited by a moderator: Mar 23, 2013
  17. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    My bad, I put 8A, not 80, I tried so many things I don't remember anymore. So I couldn't change the volume with a voice ending with 80 either?

    And why can I change it when it's 8A (which should therefore be exactly the same as 0A, yet other voices never use 0X, but always 8X), but not when it's 00? That's really confusing...
     
  18. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,902
    Location:
    italy
    Let me try again.


    The last 4 bytes of an instrument are the "total level" of the 4 operators. One or more of those 4 bytes are used for the output operators, and hence affect the "volume"; the fourth one is always an output operator, but the other three depend on the algorithm used. Now, the "total level" is a 7-bit value (which means that the first bit is ignored), and it works backwards, so 00 = loud.


    In Sonic 3,


    00 == 80 == the highest possible value


    01 == 81


    02 == 82


    ...


    7F == FF == the lowest possible value


    In Sonic 1 there's a small exception to this rule, but since you're working with Sonic 3 you're not interested into it.


    Replacing 00 with 0A, or 00 with 8A, or 80 with 0A, or 80 with 8A, all result in the same effect: a decrease of the volume of an amount of 0A (given that that byte is the total level of an output operator).
     
  19. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    Yes, I understand that. What I don't understand is why I can't change the volume with a coordination flag when the last byte in a voice is 00.

    I first tried with flag E6, which adds the value after it to the current volume, and the volume was always exactly the same. Then I tried with the coordination flag E4 (set volume) with several values (iirc 0, 8, 10, 40 and 7F), and once again, the volume was always exactly the same. Then I directly changed the volume in the FM header and the result was exactly the same with all the values I tried.

    Then I put 8A in the last byte, and all the volume control flags were working again.

    Well it doesn't matter much, as I said I'm ok as long as it's working.
     
  20. nineko

    nineko I am the Holy Cat Member

    Joined:
    Mar 24, 2008
    Messages:
    1,902
    Location:
    italy
    I'm not sure about the coordination flags because I (almost) never use them, but changing the volume in the header should always work. Weird.
     
Thread Status:
Not open for further replies.