← Back to context

Comment by javajosh

5 years ago

You've given me an idea for a volume control - enter a function like x^2 or x^3, which is graphed (on a linear scale). Then pick an x. The y value will be your volume. (The component should reverse any platform specific non-linearity first.)

How would you compute the current volume level? You would have to either store the current x value (which could desync if you change the volume level using the OS volume control), or derive the nearest x from the current y value (which may be possible on PulseAudio, but I haven't checked if you're stuck to the nearest 1% or if you can get a more precise or dB level).

  • Well if the function you put in is continuous, single-valued , then you can invert it and compute x(y). At the end of the day if the volume is represented as a syscall with a float between 0 and 1 you can play arbitrary games with any bijective function to make setting that number arbitrarily complicated.