YM2612 shape of envelope attack
Posted: Fri May 27, 2011 10:24 pm
Maybe this is already well understood but it's all new to me so I though it doesn't hurt to share.
After quite a bit of research, I've found this interesting patent:
http://www.google.com/patents?id=2S4pAA ... CCgQ6AEwAA
It explains why the "default" shape of the attack part of an envelope expressed in decibel is not desiderable, and provides two different methods to correct the problem.
The first method uses a conversion table to adjust the envelope value, whereas the second method is very clever and uses the upper bits of the envelope value itself to adjust the attack rate (the envelope starts at 1023 i.e. all 1's and goes towards 0, so it provides a good "kick" to the attack rate).
I can't test that on a real chip but I think it's very much possible that the YM2612 is using one of these two methods.
I've hacked a quick simulation in JavaScript. This simulation uses the tables published in the famous "OPLx decapsulated" post, that we know are inside the YM2612. It plots the table approach in blue and the approximated approach in green... they are very close! (The two curves are offset by 30 pixels so it's easier to compare them visually).
Sorry for bad code style and magic constants, I was too curious to try and coded that in a hurry! It also requires a browser such as Safari or FF 3.6+ that understands the "canvas" element.
http://www.ascotti.org/programming/temp/attack.html
After quite a bit of research, I've found this interesting patent:
http://www.google.com/patents?id=2S4pAA ... CCgQ6AEwAA
It explains why the "default" shape of the attack part of an envelope expressed in decibel is not desiderable, and provides two different methods to correct the problem.
The first method uses a conversion table to adjust the envelope value, whereas the second method is very clever and uses the upper bits of the envelope value itself to adjust the attack rate (the envelope starts at 1023 i.e. all 1's and goes towards 0, so it provides a good "kick" to the attack rate).
I can't test that on a real chip but I think it's very much possible that the YM2612 is using one of these two methods.
I've hacked a quick simulation in JavaScript. This simulation uses the tables published in the famous "OPLx decapsulated" post, that we know are inside the YM2612. It plots the table approach in blue and the approximated approach in green... they are very close! (The two curves are offset by 30 pixels so it's easier to compare them visually).
Sorry for bad code style and magic constants, I was too curious to try and coded that in a hurry! It also requires a browser such as Safari or FF 3.6+ that understands the "canvas" element.
http://www.ascotti.org/programming/temp/attack.html