First: I apologize for the title, I truly don't know what the correct terms to describe my problem are. If I receive suggestions for a more appropriate title or learn some new terms I will revise it.
I am working on a formula (in Excel) that will control the volume level that is restored when a user un-pauses an audio player. Rather than restore to 100% of the previous volume I want to restore to a percentage of the previous level based on two criteria:
- Previous volume % of max volume (zero previous volume has no effect, full volume would reduce restored volume by 20%. You can see this in the below formula as 0.2 / 120)
- Duration paused within a 0-10 minute scale (0 minutes = 100% restore, 10 minutes = 50%)
I always want to restore volume to a minimum of 50% of the previous level and this is where my current formula is failing me. My current formula looks like this:
Volume = 1 - ((0.5 / 10) * pausedDuration) - ((0.2 / 120) * lastVolume) [ reduce based on pause duration ] [ reduce by last vol. level ]
If pausedDuration is 10 and lastVolume is 120, Volume will be .3 (30%) which is below my 50% minimum. I understand why this happens but I don't know how to structure my formula to correct it.
If pauseDuration is 0 and lastVolume is 120, Volume will be .8 (80%). This is because the pauseDuration is having no reduction in restore levels but the volume was maxed out which reduced the restore volume by 20%. If the lastVolume had been 50 the restore level would be 0.916 (91.6%)
I don't want to simply clamp the value with a MAX() function as that will result in a flat output when the minimum is reach and I want a linear scale across the entire range. I'm starting suspect this needs to be broken up into two calculations: first the percentage from
My question: How can I have two values on their own scales combine to reduce a value by 0 - 0.5?
Update: I thought about breaking this calculation up to better illustrate what I'm trying to achieve and I was able to make it work as two calculations.
Working Google Spreadsheet for experimentation (change the two light blue cells to see the calculation)
First calculate the pause duration adjustment (0-50%) adj1 = (0.5 / 10) * pausedDuration Next calculate the additional volume level adjustment relative to the pause duration adjustment adj2 = (0.5 - adj1) / 0.5 * ((0.2 / 120) * lastVolume) Finally you have the total restore offset volume = 1.0 - adj2
Now that is one convoluted and ugly calculation! Now that I have a working example I'm hoping someone can suggest an elegant way to accomplish the same result.