diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2016-07-21 09:26:20 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2016-07-21 09:26:20 +0200 |
commit | a8340c5d43bcfc3d78c2e00ab26c0596d7ffe85e (patch) | |
tree | 0142753a5c6f8ce25ec2c456309b96c6e721d485 /helpers/mapping.py | |
parent | 9925ce3b588fc449a3e0f5a6506a2d29207928d3 (diff) | |
download | MusicSampler-a8340c5d43bcfc3d78c2e00ab26c0596d7ffe85e.tar.gz MusicSampler-a8340c5d43bcfc3d78c2e00ab26c0596d7ffe85e.tar.zst MusicSampler-a8340c5d43bcfc3d78c2e00ab26c0596d7ffe85e.zip |
Handle fade for master volume
Diffstat (limited to 'helpers/mapping.py')
-rw-r--r-- | helpers/mapping.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/helpers/mapping.py b/helpers/mapping.py index 9420acf..3622f9d 100644 --- a/helpers/mapping.py +++ b/helpers/mapping.py | |||
@@ -10,6 +10,7 @@ import sys | |||
10 | from .music_file import * | 10 | from .music_file import * |
11 | from .mixer import Mixer | 11 | from .mixer import Mixer |
12 | from . import Config, gain, error_print | 12 | from . import Config, gain, error_print |
13 | from .music_effect import GainEffect | ||
13 | 14 | ||
14 | class Mapping(RelativeLayout): | 15 | class Mapping(RelativeLayout): |
15 | expected_keys = NumericProperty(0) | 16 | expected_keys = NumericProperty(0) |
@@ -32,13 +33,22 @@ class Mapping(RelativeLayout): | |||
32 | def master_gain(self): | 33 | def master_gain(self): |
33 | return gain(self.master_volume) | 34 | return gain(self.master_volume) |
34 | 35 | ||
35 | def set_master_volume(self, value, delta=False): | 36 | def set_master_volume(self, value, delta=False, fade=0): |
36 | [db_gain, self.master_volume] = gain( | 37 | [db_gain, self.master_volume] = gain( |
37 | value + int(delta) * self.master_volume, | 38 | value + int(delta) * self.master_volume, |
38 | self.master_volume) | 39 | self.master_volume) |
39 | 40 | ||
40 | for music in self.open_files.values(): | 41 | for music in self.open_files.values(): |
41 | music.set_gain(db_gain) | 42 | if fade > 0: |
43 | music.gain_effects.append(GainEffect( | ||
44 | "fade", | ||
45 | music.current_audio_segment, | ||
46 | music.current_loop, | ||
47 | music.sound_position, | ||
48 | music.sound_position + fade, | ||
49 | gain=db_gain)) | ||
50 | else: | ||
51 | music.set_gain(db_gain) | ||
42 | 52 | ||
43 | def _keyboard_closed(self): | 53 | def _keyboard_closed(self): |
44 | self._keyboard.unbind(on_key_down=self._on_keyboard_down) | 54 | self._keyboard.unbind(on_key_down=self._on_keyboard_down) |