Exemple #1
0
 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)
Exemple #2
0
    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)
Exemple #3
0
    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()
Exemple #4
0
 def active_preset_voice_sound_changed(self, sender, **kwargs):
     self.set_string_sound(sender)
     mgcore.set_string_params(self.string_mute_configs())
Exemple #5
0
 def active_preset_voice_capo_changed(self, **kwargs):
     mgcore.set_string_params(self.melody_capo_configs())
Exemple #6
0
 def active_preset_voice_base_note_changed(self, **kwargs):
     mgcore.set_string_params(self.base_note_configs())
Exemple #7
0
 def active_preset_voice_muted_changed(self, **kwargs):
     mgcore.set_string_params(self.string_mute_configs())
Exemple #8
0
 def string_count_changed(self, string_count, **kwargs):
     mgcore.set_string_params(self.string_mute_configs())
Exemple #9
0
 def set_voice_volume(self, voice, volume):
     mgcore.set_string_params([(voice.string, 'volume', volume)])
Exemple #10
0
 def coarse_tune_changed(self, **kwargs):
     mgcore.set_string_params(self.base_note_configs())
Exemple #11
0
 def multi_chien_threshold_changed(self, **kwargs):
     mgcore.set_string_params(self.chien_threshold_configs())
Exemple #12
0
 def active_preset_voice_chien_threshold_changed(self, **kwargs):
     mgcore.set_string_params(self.chien_threshold_configs())
Exemple #13
0
 def active_preset_voice_panning_changed(self, panning, sender, **kwargs):
     mgcore.set_string_params([(sender.string, 'panning', sender.panning)])
Exemple #14
0
 def active_preset_voice_polyphonic_changed(self, polyphonic, sender,
                                            **kwargs):
     mgcore.set_string_params([(sender.string, 'polyphonic',
                                int(sender.polyphonic))])
Exemple #15
0
 def active_preset_voice_mode_changed(self, mode, sender, **kwargs):
     mgcore.set_string_params([(sender.string, 'mode',
                                VOICE_MODES.index(sender.get_mode()))])