0

Essentially, I want to get the exact audio output volume in macOS without any rounding to an integer.

I am already aware that I can execute the following to get an output volume:

osascript -e "output volume of (get volume settings)"

However, the problem with this volume is that it is very evidently rounded to the nearest integer.

This can be proven using the knowledge that each increment of volume on macOS is 1/16 = 0.0625 = 6.25%.

Output of above command given the number of bars highlighted starting from a volume of 0:

Number of bars Expected volume Command output
0 0.00 0
1 6.25 6
2 12.50 13
3 18.75 19
4 25.00 25
5 31.25 31
6 37.50 38
... ... ...

This table is quite indicative that the volume is not an integer but is being rounded when outputted through osascript.

As such, is there any way I can retrieve the actual macOS volume with the fractional/decimal component included? It doesn't have to be using built-in methods. I would be happy to consider the use of libraries like Python's pyobjc, too.

0

You must log in to answer this question.

Browse other questions tagged .