added a clamp function
changed min/max to fmin/fmax so that it would work
Shortened volume function by using clamp