In other words, in Python we have:
 def register_to_shape(val):     shape = 1 if (val ves >> 2) == 0: return 1     elif ) else 7 if (val ves >> 2) == 1: return 7     return val ) else ves & 7
When using the volume envelope generator, the volume is always increased from 00h to 0Fh (or vice versa), it is not possible to specify a starting/ending point (like from 00h to 07h).