Max numerical value of any audio stream?

Post your questions and help other users.

Moderator: Martin

akhileshg1988
Posts: 109
Joined: 16 Apr 2014 04:57

Max numerical value of any audio stream?

Post by akhileshg1988 » 13 Dec 2017 05:05

How can I know the maximum numerical value of any audio stream?
In some custom roms that I used earlier, there was an option in the settings called 'Volume Steps'.
In such roms, I could easily get the maximum value of any audio stream by using the action 'Init Variable System Setting' --> Category 'System' --> Name 'volume_steps_alarm' --> Variable 'alm_vol'.
This way, the variable 'alm_vol' returned the max numerical value of the alarm audio stream on my device.
However, now I'm using a custom rom that doesn't have the option 'Volume Steps' in the settings menu.
Please help.

Akhilesh Chandra Gairola

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Max numerical value of any audio stream?

Post by Desmanto » 13 Dec 2017 15:50

You can try to loop the value and check it.
1. First set the alarm value to 0. Initiate value prev_vol = 0.
2. Use action set audio volume - raise
3. Use action store audio volume, only alarm, save to next_vol.
4. Compare if next_vol (1) bigger that prev_vol (0). If yes, set prev_vol to next_vol (prev_vol becomes 1), and loop back to volume raise.
5. Until the last result where raise volume won't increase the value of next_vol anymore (false branch), then it is max vol already. Max_vol = next_vol.

I think it is better you check the value manually everytime you flash new cusrom. If you are willing to go through the hassle of changing the rom, you shouldn't mind to check it manually after every flash, in the action set audio volume. Simply slide it to the max and see what is the max value.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
Bingwu
Posts: 114
Joined: 26 Feb 2016 10:26

Re: Max numerical value of any audio stream?

Post by Bingwu » 13 Dec 2017 16:44

Hello!

I chose this option for me:

1. Action: Store Audio Volumes (to restore the current volume - a variable other than point 3.)
2. Action: Set Audio Stream Volume -> Volume = 999 (or another unlikely high value)
3. Action: Store Audio Volumes (That's the highest possible value ... and not 999 - a variable other than point 1.)
4. Action: Set Audio Stream Volume -> Volume (Variable from point 1. to restore the original volume)

This works on all my devices without any problems.
I hope that I did not make a mistake in the translation.

I wish you success!
Peter

akhileshg1988
Posts: 109
Joined: 16 Apr 2014 04:57

Re: Max numerical value of any audio stream?

Post by akhileshg1988 » 14 Dec 2017 09:15

Desmanto wrote:You can try to loop the value and check it.
1. First set the alarm value to 0. Initiate value prev_vol = 0.
2. Use action set audio volume - raise
3. Use action store audio volume, only alarm, save to next_vol.
4. Compare if next_vol (1) bigger that prev_vol (0). If yes, set prev_vol to next_vol (prev_vol becomes 1), and loop back to volume raise.
5. Until the last result where raise volume won't increase the value of next_vol anymore (false branch), then it is max vol already. Max_vol = next_vol.
Thanks a lot. That did the job flawlessly.

akhileshg1988
Posts: 109
Joined: 16 Apr 2014 04:57

Re: Max numerical value of any audio stream?

Post by akhileshg1988 » 14 Dec 2017 09:17

Desmanto wrote:I think it is better you check the value manually everytime you flash new cusrom. If you are willing to go through the hassle of changing the rom, you shouldn't mind to check it manually after every flash, in the action set audio volume. Simply slide it to the max and see what is the max value.
I always mind. That's why the query.

akhileshg1988
Posts: 109
Joined: 16 Apr 2014 04:57

Re: Max numerical value of any audio stream?

Post by akhileshg1988 » 14 Dec 2017 09:19

Bingwu wrote:Hello!

I chose this option for me:

1. Action: Store Audio Volumes (to restore the current volume - a variable other than point 3.)
2. Action: Set Audio Stream Volume -> Volume = 999 (or another unlikely high value)
3. Action: Store Audio Volumes (That's the highest possible value ... and not 999 - a variable other than point 1.)
4. Action: Set Audio Stream Volume -> Volume (Variable from point 1. to restore the original volume)

This works on all my devices without any problems.
I hope that I did not make a mistake in the translation.

I wish you success!
Peter
Brother Peter, really sorry, I didn't quite get your point. Could you please clarify?

Thanks.

User avatar
Bingwu
Posts: 114
Joined: 26 Feb 2016 10:26

Re: Max numerical value of any audio stream?

Post by Bingwu » 14 Dec 2017 10:09

Hello akhileshg1988!

I am sorry, but it is a small mistake in my example! :(
In the action "Set Audio Stream Volume" it is not (no longer?) possible to enter a too high value as a number.
But that's no problem if you set the value with a variable.

I have attached a flow as an example. (The elements are in German, but after saving again in English.)

Regards
Peter
Attachments
flow_highest_value_audio.xml
(4.92 KiB) Downloaded 887 times

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Max numerical value of any audio stream?

Post by Desmanto » 14 Dec 2017 15:26

@Bingwu : Nice idea there. I was lost in the loop, your method is much better. I can comment only one thing. The script to set alarm_value_too_high is not needed actually. We can just put {999} directly at the Set Audio Volume. {999} will evaluated to 999 for the volume. So, total only 2 elements needed to check the maximum volume.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
Bingwu
Posts: 114
Joined: 26 Feb 2016 10:26

Re: Max numerical value of any audio stream?

Post by Bingwu » 14 Dec 2017 15:36

Hello Desmanto!

Your idea with the curly braces is good!
Learned something again! :-)

Regards
Peter

akhileshg1988
Posts: 109
Joined: 16 Apr 2014 04:57

Re: Max numerical value of any audio stream?

Post by akhileshg1988 » 15 Dec 2017 04:46

Desmanto wrote:@Bingwu : Nice idea there. I was lost in the loop, your method is much better. I can comment only one thing. The script to set alarm_value_too_high is not needed actually. We can just put {999} directly at the Set Audio Volume. {999} will evaluated to 999 for the volume. So, total only 2 elements needed to check the maximum volume.
Hi brother!
Don't know how or why did you get lost in the loop. I successfully used the loop method to set all the audio stream volumes to max.

Thanks

Akhilesh

Post Reply