X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=helpers%2Fmapping.py;h=3622f9d8d42086369d59702cf45e6e3cd03fa9d5;hb=a8340c5d43bcfc3d78c2e00ab26c0596d7ffe85e;hp=9420acff8b4f07ab69023cab62af0965eb2f30d8;hpb=9925ce3b588fc449a3e0f5a6506a2d29207928d3;p=perso%2FImmae%2FProjets%2FPython%2FMusicSampler.git 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 from .music_file import * from .mixer import Mixer from . import Config, gain, error_print +from .music_effect import GainEffect class Mapping(RelativeLayout): expected_keys = NumericProperty(0) @@ -32,13 +33,22 @@ class Mapping(RelativeLayout): def master_gain(self): return gain(self.master_volume) - def set_master_volume(self, value, delta=False): + def set_master_volume(self, value, delta=False, fade=0): [db_gain, self.master_volume] = gain( value + int(delta) * self.master_volume, self.master_volume) for music in self.open_files.values(): - music.set_gain(db_gain) + if fade > 0: + music.gain_effects.append(GainEffect( + "fade", + music.current_audio_segment, + music.current_loop, + music.sound_position, + music.sound_position + fade, + gain=db_gain)) + else: + music.set_gain(db_gain) def _keyboard_closed(self): self._keyboard.unbind(on_key_down=self._on_keyboard_down)