]> git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/blob - music_sampler/actions/volume.py
Add comment action
[perso/Immae/Projets/Python/MusicSampler.git] / music_sampler / actions / volume.py
1 def run(action, music=None, value=100, fade=0, delta=False, **kwargs):
2 if music is not None:
3 music.set_volume(value, delta=delta, fade=fade)
4 else:
5 action.mapping.set_master_volume(value, delta=delta, fade=fade)
6
7 def description(action, music=None,
8 value=100, delta=False, fade=0, **kwargs):
9 formats = []
10 message = ""
11 if delta:
12 if music is not None:
13 message += "{:+d}% to volume of « {} »"
14 formats.append(value)
15 formats.append(music.name)
16 else:
17 message += "{:+d}% to volume"
18 formats.append(value)
19 else:
20 if music is not None:
21 message += "setting volume of « {} » to {}%"
22 formats.append(music.name)
23 formats.append(value)
24 else:
25 message += "setting volume to {}%"
26 formats.append(value)
27
28 if fade > 0:
29 message += " with {}s fade"
30 formats.append(fade)
31
32 return _(message).format(*formats)