how setVolume to max?

Hi,

The API doc says I can set volume via audio.setVolume (Number), and:

   Number. The new volume level you want to apply. Valid numbers range

   from 0.0 to 1.0, where 1.0 is the maximum value.

 

But … through actual testing, I see that values of ‘Number’ larger than 1 are meaningful … 2 is louder than 1,

3 is louder than 2, etc.  I haven’t wanted to try it exhaustively (or to binary search for an answer :slight_smile:

 

So, what *is* the maximum?

 

Or, am I being misled by the simulator (on a Mac)? 

(I.e., on a real device, perhaps the volume really does range from 0 to 1)

 

thanks,

 

Stan

You’re being mislead.

If the docs say 0.0 to 1.0, then believe them.

Remember, the simulator is not 100% gurateed to reflect what you’ll see (and in this case hear) on the device(s).

It is an awesome simulator, but at the end of the day it is still just a simulator.

Tip: It is always a good idea to follow the specs and not to rely on ‘found side-effects’.   Why?  If you find a ‘hidden or unspecified behavior’ and start using it you may later lose that functionality with no recourse.

I can now confirm that an Android (Samsung Galaxy S5) also supports volumes larger than 1 … and each one is louder and louder.

Perhaps the man page is accurate only for iOS, but my guess now is: it’s just wrong :slight_smile:

Again, go with the spec and you’ll be just fine.

I feel like this is a bit of a rabbit hole discussion, but I sense you may be worried about this still so do this experiment.

  1. Make a small demo app with three buttons with these labels  1.0, 2.0, 5.0

  2. Have the buttons: 

a. call audio.setVolume() with the sound level shown on the button.

b. play a sound file.  Something with an even tone that doesn’t vary.

  1. Build it, install it…

  2. Set the volume of your device to maximum using the volume switch on the device.

  3. Run the app and try the buttons one at a time.

Question: Is there a difference?

Try values over 1.0 for setVolume()

Does it make a difference?

I’ll say one more thing, because I don’t want you to think that I’m belittling your interest in this.

It is likely that the spec say 0.0 to 1.0, because it can guarantee that those values will be supported, AND more importantly, that all libraries that are used (regardless of device and OS) those values will represent 0% and 100% respectively.

Yeah, but why are higher values supported in some situations and what is going on?

Now, I’m really guessing here (but it’s a guess based on experience coding up engines)…

on some OSes Corona is using libraries that support values higher than 1.0 and in fact probably all the way up to the largest number supported by the OS. 

What this is doing is simple.  It is multiplying the sound by the value, but capping it internally at some unpublished maximum.  Alternately, there is no limit and sounds will eventually clip, but I kind of doubt this last idea.

@ Other devs and sound folks,

If anyone wants to weigh in here, please do.  

To close my comment/response, I want to go back to my original point.  As long as you follow the spec, you’ll be fine and you’ll get consistent behavior.  If you stray outside of that and it malfunctions in some cases, that is going to be on you.

Question - It occurred to me at the end that maybe you’re trying to find the maximum value you can dial a sound up to before it clips?  If that is the case, please say so.  I will say that audio.* is not meant or that kind of ‘find the max volume w/o clipping’ kind of work. 

@roaminggamer … thanks for the comments.  I’d been trying to implement volume up/down buttons for a very very simple

clip player (one I intend to use during a magic performance), and I initially bumped the volume up by 0.1 for every ‘up’ …

but noticed (a) it wasn’t much of a change, and (b) I could go past 5 to 10 bumps … clearly past the number 1.0.

I then realized that I didn’t even know what the starting volume was … a quick test later showed it was 1 on both the

simulator and my Android.

I’m actually using the android to push a clip out to a small Bluetooth speaker that I can conceal in my hand :slight_smile:

thanks,

Stan

You’re being mislead.

If the docs say 0.0 to 1.0, then believe them.

Remember, the simulator is not 100% gurateed to reflect what you’ll see (and in this case hear) on the device(s).

It is an awesome simulator, but at the end of the day it is still just a simulator.

Tip: It is always a good idea to follow the specs and not to rely on ‘found side-effects’.   Why?  If you find a ‘hidden or unspecified behavior’ and start using it you may later lose that functionality with no recourse.

I can now confirm that an Android (Samsung Galaxy S5) also supports volumes larger than 1 … and each one is louder and louder.

Perhaps the man page is accurate only for iOS, but my guess now is: it’s just wrong :slight_smile:

Again, go with the spec and you’ll be just fine.

I feel like this is a bit of a rabbit hole discussion, but I sense you may be worried about this still so do this experiment.

  1. Make a small demo app with three buttons with these labels  1.0, 2.0, 5.0

  2. Have the buttons: 

a. call audio.setVolume() with the sound level shown on the button.

b. play a sound file.  Something with an even tone that doesn’t vary.

  1. Build it, install it…

  2. Set the volume of your device to maximum using the volume switch on the device.

  3. Run the app and try the buttons one at a time.

Question: Is there a difference?

Try values over 1.0 for setVolume()

Does it make a difference?

I’ll say one more thing, because I don’t want you to think that I’m belittling your interest in this.

It is likely that the spec say 0.0 to 1.0, because it can guarantee that those values will be supported, AND more importantly, that all libraries that are used (regardless of device and OS) those values will represent 0% and 100% respectively.

Yeah, but why are higher values supported in some situations and what is going on?

Now, I’m really guessing here (but it’s a guess based on experience coding up engines)…

on some OSes Corona is using libraries that support values higher than 1.0 and in fact probably all the way up to the largest number supported by the OS. 

What this is doing is simple.  It is multiplying the sound by the value, but capping it internally at some unpublished maximum.  Alternately, there is no limit and sounds will eventually clip, but I kind of doubt this last idea.

@ Other devs and sound folks,

If anyone wants to weigh in here, please do.  

To close my comment/response, I want to go back to my original point.  As long as you follow the spec, you’ll be fine and you’ll get consistent behavior.  If you stray outside of that and it malfunctions in some cases, that is going to be on you.

Question - It occurred to me at the end that maybe you’re trying to find the maximum value you can dial a sound up to before it clips?  If that is the case, please say so.  I will say that audio.* is not meant or that kind of ‘find the max volume w/o clipping’ kind of work. 

@roaminggamer … thanks for the comments.  I’d been trying to implement volume up/down buttons for a very very simple

clip player (one I intend to use during a magic performance), and I initially bumped the volume up by 0.1 for every ‘up’ …

but noticed (a) it wasn’t much of a change, and (b) I could go past 5 to 10 bumps … clearly past the number 1.0.

I then realized that I didn’t even know what the starting volume was … a quick test later showed it was 1 on both the

simulator and my Android.

I’m actually using the android to push a clip out to a small Bluetooth speaker that I can conceal in my hand :slight_smile:

thanks,

Stan