Audio Set Level at Play Not Working - Sugar Cube

Sugarcube 2.31.1

I can’t get the audio level set when playback begins. This should play at 25% volume:
<<audio "track1" volume 0.25 play>>

The track plays, but the volume doesn’t respond.

Thanks, Ben

How are you determining what volume level it’s playing at? I ask because, in some cases, the volume level might not appear to change much until it gets very low. To test that, try this:

<<audio "track1" volume 0.05 play>>

Also, do you have anything, like a volume slider, which might be changing the master volume (i.e. using the SimpleAudio.volume() function)? If so, that could be related.

If that doesn’t help, then if you can link to a simple sample demonstrating the problem, then we can take a look at it.

Hope that helps! :grinning:

Thanks so much for the suggestion. Setting the level really low didn’t have an effect. Here is what I have:

<<fadein 3s (70/$wps) + “s”>> But none if it made a <<link[[difference.|Page 3]]>><<audio "track2" volume 0.05 play>><<audio "track1" fadeout>><</link>><</fadein>>

Thanks! Ben

Are you trying this on a mobile browser? If so, then that’s a, by design, limitation of mobile devices—as noted in the docs.

FYI - Your code is a bit garbled there due to a combination of using inline preformatting and the backticks in your code.

For multiple lines of code or code with backticks in it, you should use multi-line preformatting by selecting two blank lines and then clicking the “preformatted text” button (the </> button) and then putting your code inside that. Alternately, you could put three backticks on each of two lines by themselves, and then put your code on separate lines between them.

Like this?

<<fadein 3s ` (70/$wps) + “s” `>> But none if it made a <<link[[difference.|Page 3]]>><<audio "track2" volume 0.05 play>><<audio "track1" fadeout>><</link>><</fadein>>

I’m on a desktop.

More or less, though you have some extra space at the top and I hope your code isn’t quite like that since this part:

<<fadein 3s ` (70/$wps) + “s” `>>

would be broken. I assume your actual code looks more like this:

<<fadein 3s `(70/$wps) + "s"`>>

Anyways, do you have a link to a simple HTML page which shows the problem? Since it’s a bit hard to debug if the problem lies elsewhere in your code.

Your code blocked example includes curvy (typographical) quotes instead of standard quotes around the s character, and such quotes are invalid when defining a String literal.

this part => ` (70/$wps) + “s” `
should be this `(70/$wps) + "s" `

What you suggest is as it looks like in Twine itself. It just reformatted everything when I used the text block.