def active_preset_changed(self, **kwargs): self.configure_all_voices() self.set_synth_gain(self.state.synth.gain) mgcore.set_pitchbend_range(self.state.pitchbend_range) mgcore.set_string_params(self.chien_threshold_configs()) self.set_reverb_volume(self.state.reverb_volume) self.set_reverb_panning(self.state.reverb_panning)
def set_string_sound(self, voice): mgcore.set_string_params([(voice.string, 'mute', 1)]) sound = voice.get_sound() if not sound: self.fluid.clear_channel_sound(voice.channel) return self.fluid.set_channel_sound(voice.channel, sound.soundfont.filename, voice.bank, voice.program) configs = [ (voice.string, 'mode', VOICE_MODES.index(voice.get_mode())), (voice.string, 'bank', voice.bank), (voice.string, 'program', voice.program), ] muted = voice.muted or voice.number > self.state.string_count if not muted: configs.append((voice.string, 'mute', 0)) mgcore.set_string_params(configs) self.set_voice_fine_tune(voice)
def configure_all_voices(self, clear_sounds=False): mgcore.halt_outputs() try: if clear_sounds: self.fluid.clear_all_channel_sounds() self.fluid.unload_unused_soundfonts() configs = [] for voice in self.state.preset.voices: string = voice.string if voice.get_sound(): self.fluid.set_channel_sound(voice.channel, voice.soundfont_id, voice.bank, voice.program) muted = voice.muted or voice.number > self.state.string_count configs.append((string, 'mute', int(muted))) configs.append((string, 'bank', voice.bank)) configs.append((string, 'program', voice.program)) else: self.fluid.clear_channel_sound(voice.channel) configs.append((string, 'mute', 1)) configs.append((string, 'volume', voice.volume)) configs.append((string, 'panning', voice.panning)) configs.append( (string, 'mode', VOICE_MODES.index(voice.get_mode()))) configs.append( (string, 'base_note', self.get_effective_base_note(voice))) if voice.type == 'melody': configs.append((string, 'capo', voice.capo)) configs.append( (string, 'polyphonic', int(voice.polyphonic))) mgcore.set_string_params(configs) self.fluid.unload_unused_soundfonts() finally: mgcore.resume_outputs()
def active_preset_voice_sound_changed(self, sender, **kwargs): self.set_string_sound(sender) mgcore.set_string_params(self.string_mute_configs())
def active_preset_voice_capo_changed(self, **kwargs): mgcore.set_string_params(self.melody_capo_configs())
def active_preset_voice_base_note_changed(self, **kwargs): mgcore.set_string_params(self.base_note_configs())
def active_preset_voice_muted_changed(self, **kwargs): mgcore.set_string_params(self.string_mute_configs())
def string_count_changed(self, string_count, **kwargs): mgcore.set_string_params(self.string_mute_configs())
def set_voice_volume(self, voice, volume): mgcore.set_string_params([(voice.string, 'volume', volume)])
def coarse_tune_changed(self, **kwargs): mgcore.set_string_params(self.base_note_configs())
def multi_chien_threshold_changed(self, **kwargs): mgcore.set_string_params(self.chien_threshold_configs())
def active_preset_voice_chien_threshold_changed(self, **kwargs): mgcore.set_string_params(self.chien_threshold_configs())
def active_preset_voice_panning_changed(self, panning, sender, **kwargs): mgcore.set_string_params([(sender.string, 'panning', sender.panning)])
def active_preset_voice_polyphonic_changed(self, polyphonic, sender, **kwargs): mgcore.set_string_params([(sender.string, 'polyphonic', int(sender.polyphonic))])
def active_preset_voice_mode_changed(self, mode, sender, **kwargs): mgcore.set_string_params([(sender.string, 'mode', VOICE_MODES.index(sender.get_mode()))])