MK3 sound encode algorytm? (genesis\megadrive)
Posted: Fri Oct 30, 2020 5:10 pm
last time i am ask to help with move some data from original MK3 rom, but then i am do this my own... it was interesting experience. it was made not realy correct, but fine for me (i have not realy romhacking knowledge, just very basic )
it was made for this case: i want to make some sound manager for MK3 GEMS. MK3 have non standart GEMS audio driver and my multi game GEMS GUI is not working with it. it like ZT sound manager - ZT have standart GEMS only for songs, but sfx is lay in special table. so i want to do same like ZT, but for MK3 (WWF Arcade have same - probably in a future i can make it too). so that MK3 have additional banks - it have not only standart 4 banks: samples, sequences, modulations and instruments - but additional samples and additional sequences. second nonstandart item is - 4bit DPCM samples.
so my plan was:
1. move that data at the end of rom a little higher. for write GEMS banks at the end of file. done (not realy 100% work probably, but it is fine)
2. unpack GEMS banks with r57shell's splitter-combaine done
3. make GUI for easy access to replace sound with online GEMS database almost done
4. decode 4bit DPCM into standart 8bit PCM (just for demo playing with GUI - because i have standart GEMS core, that cant play MK3's DPCM) done
5. additional check and reencode samples, if they have non 6.5mhz frequency (MK3 samples is playing with this frequency) - when i make some replacing sound. done
6. dismorale thing, that is killing all my plans about conquer the universe, without take attentions of doctors in psychiatry clinic. - how to make encode samples?????? not done
i have decode table, that makes 4bit DPCM into 8bit PCM - it is fine and easy to understand and i encode all original samples for my GUI for playing with standart samples playing. then i try to make backward operation - and it is work... i am dancing all this time, until... until i decide add some another song into MK3... as i found out my procedure work fine with original samples. i mean from 4 to 8 bit and back 8 to 4bit. because that samples was prepeared by creators of the game! but when i try to encode another samples, not MK3's - this my encode procedure makes wrong sound it have some scratch, hiss, noice and etc ugly things. i have some ideas, that fly in my head... but i cant capture it. system is - take two bytes, make second - first, then find value from table for this residue. the problem is table have values 0, 1, 3, 7... and etc. but real residue can have 2, or 4, or 5 and etc "between" value. so when i encode 8bit into 4bit, then try to decode this 4bit into 8bit - new 8bit is not a same as old one 8bit. and it cant be 100% same, but i need as much close to original.
so if some one is make somekind of this task - any advice will be nice or ready to eat algorytm... so now i start think about residue from... residue and keep it for next residue )) but it is not sure... i am like Scarlett O'Hara - will think about it tomorrow. (now nothing going into my head)
it was made for this case: i want to make some sound manager for MK3 GEMS. MK3 have non standart GEMS audio driver and my multi game GEMS GUI is not working with it. it like ZT sound manager - ZT have standart GEMS only for songs, but sfx is lay in special table. so i want to do same like ZT, but for MK3 (WWF Arcade have same - probably in a future i can make it too). so that MK3 have additional banks - it have not only standart 4 banks: samples, sequences, modulations and instruments - but additional samples and additional sequences. second nonstandart item is - 4bit DPCM samples.
so my plan was:
1. move that data at the end of rom a little higher. for write GEMS banks at the end of file. done (not realy 100% work probably, but it is fine)
2. unpack GEMS banks with r57shell's splitter-combaine done
3. make GUI for easy access to replace sound with online GEMS database almost done
4. decode 4bit DPCM into standart 8bit PCM (just for demo playing with GUI - because i have standart GEMS core, that cant play MK3's DPCM) done
5. additional check and reencode samples, if they have non 6.5mhz frequency (MK3 samples is playing with this frequency) - when i make some replacing sound. done
6. dismorale thing, that is killing all my plans about conquer the universe, without take attentions of doctors in psychiatry clinic. - how to make encode samples?????? not done
i have decode table, that makes 4bit DPCM into 8bit PCM - it is fine and easy to understand and i encode all original samples for my GUI for playing with standart samples playing. then i try to make backward operation - and it is work... i am dancing all this time, until... until i decide add some another song into MK3... as i found out my procedure work fine with original samples. i mean from 4 to 8 bit and back 8 to 4bit. because that samples was prepeared by creators of the game! but when i try to encode another samples, not MK3's - this my encode procedure makes wrong sound it have some scratch, hiss, noice and etc ugly things. i have some ideas, that fly in my head... but i cant capture it. system is - take two bytes, make second - first, then find value from table for this residue. the problem is table have values 0, 1, 3, 7... and etc. but real residue can have 2, or 4, or 5 and etc "between" value. so when i encode 8bit into 4bit, then try to decode this 4bit into 8bit - new 8bit is not a same as old one 8bit. and it cant be 100% same, but i need as much close to original.
so if some one is make somekind of this task - any advice will be nice or ready to eat algorytm... so now i start think about residue from... residue and keep it for next residue )) but it is not sure... i am like Scarlett O'Hara - will think about it tomorrow. (now nothing going into my head)