Changing sound volume while playing?

Is it possible to change the volume of a looping playing sound?

When you call sound(...), it returns an instance of the sound, which you can control, i.e.

s = sound(...)

s.volume = 0.5

Thank you!
Is there any particular difference between using music or sound? I am using a wav of a couple of seconds, which seems to work fine using either so I was wondering what might be the best choice, or if it matters at all?

@Kirl I don’t think you can even use wav files with music(), wav is intended for short sound effects, because they’re lossless they have higher quality but take up significantly more space.

It does, wav seems to work fine for me using music as well! :slight_smile:
So I was wondering if there were any behind the scenes differences, except for the available parameters.

@Kirl Huh, I thought wav was only used for sound().

Here’s all the functions for sound objects I found when I looked into it nearly a year ago.

Printing out all the values I could find in the reference for sound() and music(), here’s what it said:

volume: 1.0
pan: 0.0
currentTime: nil
paused: false
muted: false
duration: nil
channels: nil
name: nil
loop: nil
pitch: 1.0
seed: nil
parameterTable: nil
buffer: nil

So, it appears there are only these:

volume - number
pan - number
paused - boolean
muted - boolean
pitch - number

Fun fact: the official name for sound instances are “soundsources,” they’re referenced when you call tostring() on it, and in error messages, for instance, when you call pairs() on it.