kramlat
Moldy Popcorn
got slack?
Posts: 42
|
Post by kramlat on Dec 3, 2009 7:40:16 GMT -5
easier said than done. 68k variants of smps I can see that as reality. i.e. sonic1, because the pointers in the header are 16-bit relative and the song position is interchangeable, but kramlib uses a z80 variant so the tracker would have to dump the song in sonic1 format and music pointer fixer be used to convert it to the proper format, because z80 variants have the 2nd half of the address (16 bits), byte-swapped as the pointers. example &hC8340 would appear as &h4083 in the music format in kramlib. sound effects strangely enough use the same format as music does. Thus, you would have to know where you are putting the music before you can use it. (within a bank of &h8000) thus the program may have to ask such a thing before dumping a .bin and could make sound effects too, lol. the header is as follows (assuming channel setup is &h0603): Offset | Description | &h00 | voice bank pointer (integer). &hD817 uses universal voice bank (UVB) | &h02 | number of FM channels. &h07 = 6 channels with no DAC(byte) | &h03 | number of PSG channels. &h04 = noise channel exists. (byte) | &h04 | tempo dividing time (byte) | &h05 | main tempo modifier (byte) | &h06 | DAC pointer pointer. similar to channel 10 in MIDI(integer) | &h08 | reserved (integer) | &h0A | FM1 pointer (integer) | &h0C | FM1 pitch (byte) | &h0D | FM1 volume (byte) | &h0E | FM2 pointer (integer) | &h10 | FM2 pitch (byte) | &h11 | FM2 volume (byte) | &h12 | FM3 pointer (integer) | &h14 | FM3 pitch (byte) | &h15 | FM3 volume (byte) | &h16 | FM4 pointer (integer) | &h18 | FM4 pitch (byte) | &h19 | FM4 volume (byte) | &h1A | FM5 pointer (integer) | &h1C | FM5 pitch (byte) | &h1D | FM5 volume (byte) | &h1E | PSG1 pointer (integer) | &h20 | PSG1 pitch (byte) | &h21 | PSG1 volume (byte) | &h22 | PSG1 voice (copy) (byte) | &h23 | PSG1 voice (byte) | &h24 | PSG2 pointer (integer) | &h26 | PSG2 pitch (byte) | &h27 | PSG2 volume (byte) | &h28 | PSG2 voice (copy) (byte) | &h29 | PSG2 voice (byte) | &h2A | PSG3 pointer (integer) | &h2C | PSG3 pitch (byte) | &h2D | PSG3 volume (byte) | &h2E | PSG3 voice (copy) (byte) | &h2F | PSG3 voice (byte) |
expect the coordinance flags in the next post. btw if such an app was made sonic hackers would love it just as much as the developers in this forum do.
|
|
kramlat
Moldy Popcorn
got slack?
Posts: 42
|
Post by kramlat on Dec 3, 2009 8:48:24 GMT -5
these flags keep effect until another of the same class replaces them: &h00 - &h7F = note duration &h80 = rest &h81 - &hDF = notes &hE0xx = AMS, FMS xx.7 = pan left xx.6 = pan right xx.5 - xx.3 = AMS xx.2 - xx.0 = FMS &hE1xx = bend pitch by xx &hE2FF = fade in previous song (needed to be on DAC channel) &hE5xx = change tempo divide by xx &hE6xx =change volume by xx (signed) &hE8xx = set note fill amount to xx &hEAxx = set tempo to xx &hEBxx = change tempo to xx for all channels &hECxx = set channel volume to xx (signed) &hEE = something to do with voice selection &hEFxx = change voice to xx, numbered starting at 0 &hF0wwxxyyzz = modulation ww = wait time xx = modulation speed yy = modulation change per mod. step zz = number of steps in modulation &hF1 = turn on modulation &hF2 = stop track &hF3xx change PSG noise to xx. (valid values are &hE0 - &hE7, works only on PSG noise channel) &hF4 = turn off modulation &hF5xx = change PSG tone to xx (PSG tone channels only) &hFB = change channel key by xx
these flags can only be used for one note at a time: &hE7xx = prevent next note from attacking
these flags are for looping purposes and branching purposes: &hF6yyyy = goto position yyyy &hF7xxyyzzzz = gosub position zzzz, yy times, with loop index xx &hF8xxxx = gosub xxxx &hF9 = return
|
|
kramlat
Moldy Popcorn
got slack?
Posts: 42
|
Post by kramlat on Dec 3, 2009 9:34:11 GMT -5
now a breakdown of the voice format (anyone would like this info ): Offset | Description | Ch. 1/3 register | Ch. 2/4 register | Ch. 3/6 register | &h00 | Feedback (next 3 bits) / Algorithm (lower 3 bits) | &hB0 | &hB1 | &hB2 | &h01 | Detune of operator 4 (nybble 1) / Coarse-frequency of operator 4 (nybble 2) | &h3C | &h3D | &h3E | &h02 | Detune of operator 3 (nybble 1) / Coarse-frequency of operator 3 (nybble 2) | &h38 | &h39 | &h3A | &h03 | Detune of operator 2 (nybble 1) / Coarse-frequency of operator 2 (nybble 2) | &h34 | &h35 | &h36 | &h04 | Detune of operator 1 (nybble 1) / Coarse-frequency of operator 1 (nybble 2) | &h30 | &h31 | &h32 | &h05 | [RS] of operator 4 (upper 2 bits) / Attack rate [AR] of operator 4 (lower 5 bits) | &h5C | &h5D | &h5E | &h06 | [RS] of operator 3 (upper 2 bits) / Attack rate [AR] of operator 3 (lower 5 bits) | &h58 | &h59 | &h5A | &h07 | [RS] of operator 2 (upper 2 bits) / Attack rate [AR] of operator 2 (lower 5 bits) | &h54 | &h55 | &h56 | &h08 | [RS] of operator 1 (upper 2 bits) / Attack rate [AR] of operator 1 (lower 5 bits) | &h50 | &h51 | &h52 | &h09 | [AM] of operator 4 / First decay rate [D1R] of operator 4 (lower 5 bits) | &h6C | &h6D | &h6E | &h0A | [AM] of operator 3 / First decay rate [D1R] of operator 3 (lower 5 bits) | &h68 | &h69 | &h6A | &h0B | [AM] of operator 2 / First decay rate [D1R] of operator 2 (lower 5 bits) | &h64 | &h65 | &h66 | &h0C | [AM] of operator 1 / First decay rate [D1R] of operator 1 (lower 5 bits) | &h60 | &h61 | &h62 | &h0D | Second decay rate [D2R] of operator 4 | &h7C | &h7D | &h7E | &h0E | Second decay rate [D2R] of operator 3 | &h78 | &h79 | &h7A | &h0F | Second decay rate [D2R] of operator 2 | &h74 | &h75 | &h76 | &h10 | Second decay rate [D2R] of operator 1 | &h70 | &h71 | &h72 | &h11 | First decay level [D1L] of operator 4 (nybble 1) / Release rate [RR] of operator 4 (nybble 2) | &h8C | &h8D | &h8E | &h12 | First decay level [D1L] of operator 3 (nybble 1) / Release rate [RR] of operator 3 (nybble 2) | &h88 | &h89 | &h8A | &h13 | First decay level [D1L] of operator 2 (nybble 1) / Release rate [RR] of operator 2 (nybble 2) | &h84 | &h85 | &h86 | &h14 | First decay level [D1L] of operator 1 (nybble 1) / Release rate [RR] of operator 1 (nybble 2) | &h80 | &h81 | &h82 | &h15 | Total level of operator 4 | &h4C | &h4D | &h4E | &h16 | Total level of operator 3 | &h48 | &h49 | &h4A | &h17 | Total level of operator 2 | &h44 | &h45 | &h46 | &h18 | Total level of operator 1 | &h40 | &h41 | &h42 |
each voice is only 25 bytes long and a voice bank has no header, just voices in sequence, starting with voice 0. algorithms are identical to those of the yamaha ymtx81z. the default drumkit and default uvb voices will be in the next post sometime later today.
|
|
kramlat
Moldy Popcorn
got slack?
Posts: 42
|
Post by kramlat on Dec 3, 2009 10:52:48 GMT -5
this the default drumkit: &h81 Snare &h82 High-Tom &h83 Mid-Tom &h84 Low-Tom &h85 Floor Tom &h86 Kick &h87 Muffled Snare &h88 Crash Cymbal &h89 Ride Cymbal &h8A Low Metal Hit &h8B Metal Hit &h8C High Metal Hit &h8D Higher Metal Hit &h8F Clap &h90 Electric High-Tom &h91 Electric Mid-Tom &h92 Electric Low-Tom &h93 Electric Floor Tom &h94 Tight Snare &h95 Mid-pitch Snare &h96 Loose Snare &h97 Looser Snare &h98 Hi-Timpani &h99 Low-Timpani &h9A Mid-Timpani &h9B Quick Loose Snare &h9C Click &h9D Power Kick &h9E Quick Glass Crash &h9F Glass Crash with Snare &hA0 Glass Crash &hA1 Glass Crash with Kick &hA2 Quiet Glass Crash &hA3 Odd Snare with Kick &hA4 Kick with extra bass &hA5 "Come on!" &hA6 Dance Snare &hA7 Loose Kick &hA8 Moderately Loose Kick &hA9 "Woo!" &hAA "Go!" &hAB Snare with voice going "Go!" &hAC Power Tom &hAD Hi-Wood Block &hAE Low-Wood Block &hAF Hi-Hit Drum &hB0 Low-Hit Drum &hB1 Metal Crash Hit &hB2 Echoed Clap Hit &hB3 Lower Echoed Clap Hit &hB4 Hip-Hop style hit with a kick &hB5 Hip-Hop style hit with a Power Kick &hB6 Some Bass with a voice going "Hey!" &hB7 Dance Style Kick &hB8 Hip-Hop hit with a kick &hB9 Hip-Hop hit with a kick &hBA Reverse Fading Wind Sound &hBB Scratch &hBC Loose Snare with noise &hBD Power Kick &hBE Crashing noise with voice going "Woo!" &hBF Quick Hit &hC0 Kick with a voice going "Hey!" &hC1 Power Kick with hit &hC2 Low Power Kick with hit &hC3 Lower Power Kick with hit &hC4 Lowest Power Kick with hit
and here is the default UVB: &h00 Synth Bass 2 &h01 Trumpet 1 &h02 Slap Bass 2 &h03 Synth Bass 1 &h04 Bell Synth 1 &h05 Bell Synth 2 &h06 Synth Brass 1 &h07 Synth like Bassoon &h08 Bell Horn type thing &h09 Synth Bass 3 &h0A Synth Trumpet &h0B Wood Block &h0C Tubular Bell &h0D Strike Bass &h0E Elec Piano &h0F Bright Piano &h10 Church Bell &h11 Synth Brass 2 &h12 Bell Piano &h13 Wet Wood Bass &h14 Silent Bass &h15 Picked Bass &h16 Xylophone &h17 Sine Flute &h18 Pipe Organ &h19 Synth Brass 2 &h1A Harpischord &h1B Metallic Bass &h1C Alternate Metallic Bass &h1D Backdropped Metallic Bass &h1E Sine like Bell &h1F Synth like Metallic with Small Bell. &h20 Nice Synth like lead. &h21 Rock Organ &h22 Strike like Slap Bass
just to let you know though, a voice bank of any kind can have up to 256 voices in it and the drumkit is in 3 banks each with a dac sampling table that contains the whole entire drumkit, but the samples themselves are only in the bank that they belong in.
bank 0 has samples &h81 - &h9A bank 1 has samples &h9B - &hAA bank 2 has samples &hAB - &hC4 here is the drum bank format: (<sample rate (byte)><size (integer)><pointer (integer)>)... ...<sample (4-bit wav-pcm without header)>...
as you can see DAC samples are 4-bit pcm samples and sonic retro has a tool soimewhere in the forums to convert between 4-bit pcm and 8-bit pcm. note: any samples not relevant to the bank will not have sane values.
|
|
|
Post by Mairtrus on Dec 4, 2009 11:59:41 GMT -5
¡Wow! ¡Long time I didn't enter on the forums, and now I see this! Congratulations man, I tested it and works really nice. BTW, I'm currently making a new game. Initially, it had the 68K SMPS(properly modified by me), and some other stuff, but now I'll modify it to put this library on it. Keep your eye on the forums... I dream with the day that BEX could had custom subroutines wich doesn't hang the MD, so mixed with this, well... It will be a very powerfull tool...
|
|
|
Post by TheMVRules on Dec 4, 2009 12:15:43 GMT -5
I would like a smps tracker
|
|
kramlat
Moldy Popcorn
got slack?
Posts: 42
|
Post by kramlat on Dec 4, 2009 21:06:31 GMT -5
Mairtrus - Mi habla poco espanol (in other words I know spanish is your native tongue, but english does not have inverted marks.) on another note: I heard you got a 68k based smps system working, how did you overcome the need for vertical interrupt calls?
TheMVRules - I will see what I can do. I doubt such a tracker would ever look like a midi tracker though, smps is way too powerful for that. probably more like modplug tracker or like hyrule magic's tracker. MIDI import may be possible with a little loss (too many channels, some flags unsupported, etc) and the reverse with massive loss (midi files cannot do internal loops, especially in single tracks for an example) and midi export MUST be midi type 2 due to the nature of smps.
as for voices, with byte re-ordering, we can import or export to and from any MD voice format, sega sound can be made from a wav file of similar size by stripping the header off, and dac samples are 4-bit wav samples without header.
|
|
|
Post by Tom Maneiro on Dec 4, 2009 21:45:47 GMT -5
At the very least, MIDI and WAV import should be there. Anyway, coders can compose their tunes in their favorite trackers or other software, export to MIDI (following the restrictions that you pointed, this should be pointed in some "import spects" that would come with the converter), and convert. Start first with a tiny converter, then, if there is time (and more contributors), write a full-featured tracker or something. This way, life should be easier for those that are no music composers, but know friends that are no game hackers/koders
|
|
kramlat
Moldy Popcorn
got slack?
Posts: 42
|
Post by kramlat on Dec 5, 2009 5:43:24 GMT -5
midi import is easy, but just to let you know, DAC channel might sound strange because samples do not comform to midi, so readjusting is advised, i.e. you might expect a cowbell and get "come on!"
also midi does not loop, so an editor/tracker is needed, I will work on this as soon as I have a table of little endian music pointers to work off of, so that the music can be popped into place. will package with kramlib 1.1 and will output a theme.s with it too.
edit: can someone make a gm.vbk? vbk files will be as follows: "vbank"&h00 <vbank version(for the release will be &h00)> <bank name (0-terminated)> <bank author (0-terminated)> <number of voices (minus 1)> (<voice name(0-terminated)><voice>)...
|
|
|
Post by Mairtrus on Dec 5, 2009 9:55:33 GMT -5
Mairtrus - Mi habla poco espanol (in other words I know spanish is your native tongue, but english does not have inverted marks.) on another note: I heard you got a 68k based smps system working, how did you overcome the need for vertical interrupt calls? Yes, sorry. When I write fast, usually do not put much attention to what I'm doing... ;D And about the 68K SMPS, it's really easy... First, you need the striped Sound Driver. I don't remember where in Sonic Retro it is right now, so get it here. Then, go to BasiEgaXorz, and do something like this: gosub SoundDriverLoad on vblank gosub vint enable interruptvblank
main: goto main
vint: disable interruptvblank asm movem.l d0-a6,-(a7) jsr Init_Sound_Driver end asm datafile s1.asm asm movem.l (a7)+,d0-a6 end asm enable interruptvblank return
SoundDriverLoad: asm nop move.w #$100,($A11100).l ; stop the Z80 move.w #$100,($A11200).l ; reset the Z80 moveq #0,d0 lea (Z80_Driver).l,a0 lea ($A00000).l,a1 move.w #Z80_End-Z80_Driver,d0 sub.w #1,d0
LoadToZ80: move.b (a0)+,(a1)+ dbf d0,LoadToZ80 move.w #0,($A11200).l nop nop nop nop move.w #$100,($A11200).l ; reset the Z80 move.w #0,($A11100).l ; start the Z80 rts
Z80_Driver: incbin z80_dec.bin Z80_End: even end asm Note that I put the decompressed sound driver, just for avoid the necesity of have the Kosinski decompressor. To play a song, just do poke &hFFF00A,SongNumber+&h81 Just a sidenote: The DAC Samples are NOT 4-bit pcm samples, are 8-bit samples compressed to 4-bit and decompressed in real time (I have the disassembled code of the Z80 sound driver, but I don't fully understand yet how this is done). 4-bit pcm samples is what use the GameBoyAdvance on one of his psg channels to create a custom waveform. P.S.: Like 1 year ago, I fully commented the Sound Driver, with a lot of notes of its working, RAM adresses and things like that. But I did it in spanish. If someone want it, I can translate it in less that a week and upload it.
|
|
|
Post by walker7 on Dec 5, 2009 10:46:46 GMT -5
What address do you store the header info for the song (the thing that contains the 0603 that determines the channels used)? What address to you store the 25-byte voices, and how do you access those voices? Would you please give us the ASM code to do so? And where exactly in the Sonic 2 ROM are all the voices stored for the songs?
|
|
|
Post by TheMVRules on Dec 5, 2009 12:10:15 GMT -5
TheMVRules - I will see what I can do. I doubt such a tracker would ever look like a midi tracker though, smps is way too powerful for that. probably more like modplug tracker or like hyrule magic's tracker. MIDI import may be possible with a little loss (too many channels, some flags unsupported, etc) and the reverse with massive loss (midi files cannot do internal loops, especially in single tracks for an example) and midi export MUST be midi type 2 due to the nature of smps. That's all I need. I usually don't use midi trackers. I only use TFM music maker and famitracker.
|
|
kramlat
Moldy Popcorn
got slack?
Posts: 42
|
Post by kramlat on Dec 7, 2009 3:52:22 GMT -5
walker7, lol. the header is at the beginning and "0603" are the 3rd and 4th bytes of the music header. the first two tell you where to find the first voice. (little endian, 16-bit absolute within &h8000)
as for sonic2 voices, for every operator 2 and 3 byte, swap it.
sonic2 beta uses an identical header for music. sonic2 final uses compressed music, except a few music chunks. in compressed music, pointers are based on z80 ram instead of the rom.
also, you do not need asm to edit the music. I am working on a tool. A header may look something like THIS: 708F 0603 017F 6A8F 0000 1190 017F 3F90 016A 5A90 016A 5A90 0A69 7890 017B BF90 00BF E0E0 D890 00BF E4E4 0791 00BF E2E2
red = fm/dac setup orange = psg setup green = pointer (little endian, in other words byte-swapped) purple = divide blue = tempo brown = pitch lime = volume teal = tone
|
|
kramlat
Moldy Popcorn
got slack?
Posts: 42
|
Post by kramlat on Dec 8, 2009 23:31:46 GMT -5
piano: 32 01 33 0D 71 94 5F 99 5F 07 05 05 05 02 02 02 02 A6 11 11 11 00 26 2D 23 |
organ: 76 72 31 34 77 1F 1F 1F 1F 00 00 0A 0F 00 00 00 00 09 09 19 10 14 16 13 34 |
brass: 75 00 00 00 00 18 18 18 0E 0A 0A 0A 0C 00 00 00 00 17 17 17 16 25 0F 0F 23 |
|
|
zephyr
Burger Head
Delphi & Turbo Pascal Coder
Posts: 22
|
Post by zephyr on Dec 20, 2009 15:03:59 GMT -5
kram1024, great work!!! This is a good way to use more sound hardware then Shiru's TFM does!!! I have got real SMD system with flash cart and can test it on real hardware. But I have PAL machine Can somebody explain me how to speed up song a little for a 50Hz hardware?
|
|