Example #1
0
 def setup_sound(self):
     if sys.platform == 'win32' and \
                 cfg.get_string("sound/type") == "sequencer-device":
         # just in case c:\home\.solfegerc is wrong
         cfg.set_string("sound/type", "winsynth")
     if self.m_options.no_sound \
        or cfg.get_string("sound/type") == "fake-synth":
         soundcard.initialise_using_fake_synth(
             self.m_options.verbose_sound_init)
     elif cfg.get_string("sound/type") == "alsa-sequencer":
         if alsaseq:
             try:
                 clientid, portid = self.get_list("sound/alsa-client-port")
             except ValueError:
                 clientid, portid = (None, None)
             try:
                 soundcard.initialise_alsa_sequencer(
                     (clientid, portid), self.m_options.verbose_sound_init)
             except alsaseq.SequencerError, e:
                 logging.debug(
                     "initialise_alsa_sequencer failed. Using fake synth.")
                 self.display_sound_init_error_message(e)
                 soundcard.initialise_using_fake_synth(True)
                 return
         else:
             if solfege.splash_win:
                 solfege.splash_win.hide()
             gu.dialog_ok(
                 _("The pyalsa Python module is missing"), solfege.win,
                 _("Solfege was configured to use the Python modules from www.alsa-project.org, but the modules were not found. You must reconfigure sound in the preferences window (Ctrl-F12) or restart Solfege in a way that it finds the modules."
                   ))
             soundcard.initialise_using_fake_synth(True)
             if solfege.splash_win:
                 solfege.splash_win.show()
Example #2
0
 def setup_sound(self):
     if sys.platform == 'win32' and \
                 cfg.get_string("sound/type") == "sequencer-device":
         # just in case c:\home\.solfegerc is wrong
         cfg.set_string("sound/type", "winsynth")
     if self.m_options.no_sound \
        or cfg.get_string("sound/type") == "fake-synth":
         soundcard.initialise_using_fake_synth(self.m_options.verbose_sound_init)
     elif cfg.get_string("sound/type") == "alsa-sequencer":
         if alsaseq:
             try:
                 clientid, portid = self.get_list("sound/alsa-client-port")
             except ValueError:
                 clientid, portid = (None, None)
             try:
                 soundcard.initialise_alsa_sequencer((clientid, portid),
                         self.m_options.verbose_sound_init)
             except alsaseq.SequencerError, e:
                 logging.debug("initialise_alsa_sequencer failed. Using fake synth.")
                 self.display_sound_init_error_message(e)
                 soundcard.initialise_using_fake_synth(True)
                 return
         else:
             if solfege.splash_win:
                 solfege.splash_win.hide()
             gu.dialog_ok(_("The pyalsa Python module is missing"),
                 solfege.win,
                 _("Solfege was configured to use the Python modules from www.alsa-project.org, but the modules were not found. You must reconfigure sound in the preferences window (Ctrl-F12) or restart Solfege in a way that it finds the modules."))
             soundcard.initialise_using_fake_synth(True)
             if solfege.splash_win:
                 solfege.splash_win.show()
Example #3
0
 def on_apply(self, *v):
     """Returns -1 if sound init fails."""
     if soundcard.synth:
         soundcard.synth.close()
     if self.g_midiplayer_radio.get_active():
         soundcard.initialise_external_midiplayer()
         soundcard.synth.error_report_cb = solfege.win.display_error_message
     elif self.g_device_radio.get_active():
         try:
             if sys.platform == 'win32':
                 soundcard.initialise_winsynth(self.g_synth.get_active() -
                                               1)
             else:
                 soundcard.initialise_devicefile(
                     self.g_device_file.get_child().get_text(),
                     self.g_synth_num.get_value_as_int())
         except (soundcard.SoundInitException, OSError, ImportError) as e:
             solfege.app.display_sound_init_error_message(e)
             return -1
     elif solfege.soundcard.alsa_sequencer and self.g_alsa_radio.get_active(
     ):
         if self.m_gui_client_port:
             try:
                 soundcard.initialise_alsa_sequencer(self.m_gui_client_port)
             except solfege.soundcard.alsa_sequencer.alsaseq.SequencerError as e:
                 logging.debug("initialise_alsa_sequencer(%s) failed: %s",
                               self.m_gui_client_port, str(e))
                 solfege.app.display_sound_init_error_message(e)
                 return -1
         else:
             return -1
     else:  # no sound
         assert self.g_fakesynth_radio.get_active()
         soundcard.initialise_using_fake_synth(0)
     if self.g_midiplayer_radio.get_active():
         self.set_string("sound/type", "external-midiplayer")
     elif self.g_device_radio.get_active():
         if sys.platform == "win32":
             self.set_string("sound/type", "winsynth")
         else:
             self.set_string("sound/type", "sequencer-device")
     elif solfege.soundcard.alsa_sequencer and self.g_alsa_radio.get_active(
     ):
         self.set_string("sound/type", "alsa-sequencer")
         self.set_list("sound/alsa-client-port", self.m_gui_client_port)
     else:
         assert self.g_fakesynth_radio.get_active()
         self.set_string("sound/type", "fake-synth")
     if sys.platform != 'win32':
         self.set_string("sound/device_file",
                         self.g_device_file.get_child().get_text())
     if soundcard.synth.m_type_major in ('OSS', 'win32'):
         self.set_int("sound/synth_number", soundcard.synth.m_devnum)
         # we set the spin just in case m_devnum was changed by the
         # soundcard setup code, if it was out of range
         if sys.platform != 'win32':
             self.g_synth_num.set_value(soundcard.synth.m_devnum)
         else:
             self.g_synth.set_active(soundcard.synth.m_devnum + 1)
Example #4
0
 def on_apply(self, *v):
     """Returns -1 if sound init fails."""
     if soundcard.synth:
         soundcard.synth.close()
     if self.g_midiplayer_radio.get_active():
         soundcard.initialise_external_midiplayer()
         soundcard.synth.error_report_cb = solfege.win.display_error_message
     elif self.g_device_radio.get_active():
         try:
             if sys.platform == 'win32':
                 soundcard.initialise_winsynth(self.g_synth.get_active() - 1)
             else:
                 soundcard.initialise_devicefile(
                     self.g_device_file.get_child().get_text(),
                     self.g_synth_num.get_value_as_int())
         except (soundcard.SoundInitException, OSError, ImportError) as e:
             solfege.app.display_sound_init_error_message(e)
             return -1
     elif solfege.soundcard.alsa_sequencer and self.g_alsa_radio.get_active():
         if self.m_gui_client_port:
             try:
                 soundcard.initialise_alsa_sequencer(self.m_gui_client_port)
             except solfege.soundcard.alsa_sequencer.alsaseq.SequencerError as e:
                 logging.debug("initialise_alsa_sequencer(%s) failed: %s", self.m_gui_client_port, str(e))
                 solfege.app.display_sound_init_error_message(e)
                 return -1
         else:
             return -1
     else:  # no sound
         assert self.g_fakesynth_radio.get_active()
         soundcard.initialise_using_fake_synth(0)
     if self.g_midiplayer_radio.get_active():
         self.set_string("sound/type", "external-midiplayer")
     elif self.g_device_radio.get_active():
         if sys.platform == "win32":
             self.set_string("sound/type", "winsynth")
         else:
             self.set_string("sound/type", "sequencer-device")
     elif solfege.soundcard.alsa_sequencer and self.g_alsa_radio.get_active():
         self.set_string("sound/type", "alsa-sequencer")
         self.set_list("sound/alsa-client-port", self.m_gui_client_port)
     else:
         assert self.g_fakesynth_radio.get_active()
         self.set_string("sound/type", "fake-synth")
     if sys.platform != 'win32':
         self.set_string("sound/device_file", self.g_device_file.get_child().get_text())
     if soundcard.synth.m_type_major in ('OSS', 'win32'):
         self.set_int("sound/synth_number", soundcard.synth.m_devnum)
         # we set the spin just in case m_devnum was changed by the
         # soundcard setup code, if it was out of range
         if sys.platform != 'win32':
             self.g_synth_num.set_value(soundcard.synth.m_devnum)
         else:
             self.g_synth.set_active(soundcard.synth.m_devnum + 1)
Example #5
0
 def setup_sound(self):
     if sys.platform == 'win32' and \
                 cfg.get_string("sound/type") == "sequencer-device":
         # just in case c:\home\.solfegerc is wrong
         cfg.set_string("sound/type", "winsynth")
     if self.m_options.no_sound \
        or cfg.get_string("sound/type") == "fake-synth":
         soundcard.initialise_using_fake_synth(self.m_options.verbose_sound_init)
     elif cfg.get_string("sound/type") == "alsa-sequencer":
         if alsaseq:
             try:
                 clientid, portid = self.get_list("sound/alsa-client-port")
             except ValueError:
                 clientid, portid = (None, None)
             try:
                 soundcard.initialise_alsa_sequencer((clientid, portid),
                         self.m_options.verbose_sound_init)
             except alsaseq.SequencerError as e:
                 logging.debug("initialise_alsa_sequencer failed. Using fake synth.")
                 self.display_sound_init_error_message(e)
                 soundcard.initialise_using_fake_synth(True)
                 return
         else:
             if solfege.splash_win:
                 solfege.splash_win.hide()
             gu.dialog_ok(_("The pyalsa Python module is missing"),
                 solfege.win,
                 _("Solfege was configured to use the Python modules from www.alsa-project.org, but the modules were not found. You must reconfigure sound in the preferences window (Ctrl-F12) or restart Solfege in a way that it finds the modules."))
             soundcard.initialise_using_fake_synth(True)
             if solfege.splash_win:
                 solfege.splash_win.show()
     elif cfg.get_string("sound/type") == "winsynth":
         try:
             soundcard.initialise_winsynth(cfg.get_int("sound/synth_number"),
                   verbose_init=self.m_options.verbose_sound_init)
         except ImportError as e:
             self.display_sound_init_error_message(e)
             cfg.set_string("sound/type", "fake-synth")
             soundcard.initialise_using_fake_synth(True)
             return
         except RuntimeError as e:
             # We can get here if winmidi.output_devices() in winsynth
             # __init__ returns no devices. Don't know when, but it could
             # happen.
             gu.display_exception_message(e)
             cfg.set_string("sound/type", "fake-synth")
             soundcard.initialise_using_fake_synth(True)
             return
         if cfg.get_int("sound/synth_number") != soundcard.synth.m_devnum:
             solfege.win.display_error_message2(_("MIDI setup"), _("MIDI Device %(olddev)i not available. Will use device %(newdev)i.") % {'olddev': cfg.get_int("sound/synth_number"), 'newdev': soundcard.synth.m_devnum})
             cfg.set_int("sound/synth_number", soundcard.synth.m_devnum)
     elif cfg.get_string("sound/type") == "external-midiplayer":
         soundcard.initialise_external_midiplayer(
                 verbose_init=self.m_options.verbose_sound_init)
         soundcard.synth.error_report_cb = solfege.win.display_error_message
     elif cfg.get_string("sound/type") == '':
         solfege.win.display_error_message(
             _("You should configure sound from the 'Sound' page "
               "of the preferences window."))
     elif cfg.get_string("sound/type") == "sequencer-device":
         try:
             soundcard.initialise_devicefile(
                          cfg.get_string("sound/device_file"),
                          cfg.get_int("sound/synth_number"),
                          verbose_init=self.m_options.verbose_sound_init)
         except (soundcard.SoundInitException, OSError, ImportError) as e:
             self.m_sound_init_exception = e
             soundcard.initialise_using_fake_synth(True)
     if cfg.get_string("programs/csound") == "AUTODETECT":
         for p in osutils.find_csound_executables():
             cfg.set_string("programs/csound", p)
             break
         else:
             # If not csound binary was found, then we set the string empty.
             # This means that autodetection will only happen the first time
             # you run the program. But later will newly installed binaries
             # be shown in the combo box of the preferences window.
             cfg.set_string("programs/csound", "")
     if cfg.get_string("programs/mma") == "AUTODETECT":
         for p in osutils.find_mma_executables(cfg.get_list("app/win32_ignore_drives")):
             cfg.set_string("programs/mma", p)
             break
         else:
             cfg.set_string("programs/mma", "")
Example #6
0
     soundcard.synth.error_report_cb = solfege.win.display_error_message
 elif self.g_device_radio.get_active():
     try:
         if sys.platform == 'win32':
             soundcard.initialise_winsynth(self.g_synth.get_active() - 1)
         else:
             soundcard.initialise_devicefile(
                 self.g_device_file.get_child().get_text(),
                 self.g_synth_num.get_value_as_int())
     except (soundcard.SoundInitException, OSError, ImportError), e:
         solfege.app.display_sound_init_error_message(e)
         return -1
 elif solfege.soundcard.alsa_sequencer and self.g_alsa_radio.get_active():
     if self.m_gui_client_port:
         try:
             soundcard.initialise_alsa_sequencer(self.m_gui_client_port)
         except solfege.soundcard.alsa_sequencer.alsaseq.SequencerError, e:
             logging.debug("initialise_alsa_sequencer(%s) failed: %s", self.m_gui_client_port, str(e))
             solfege.app.display_sound_init_error_message(e)
             return -1
     else:
         return -1
 else: # no sound
     assert self.g_fakesynth_radio.get_active()
     soundcard.initialise_using_fake_synth(0)
 if self.g_midiplayer_radio.get_active():
     self.set_string("sound/type", "external-midiplayer")
 elif self.g_device_radio.get_active():
     if sys.platform == "win32":
         self.set_string("sound/type", "winsynth")
     else:
Example #7
0
     try:
         if sys.platform == 'win32':
             soundcard.initialise_winsynth(self.g_synth.get_active() -
                                           1)
         else:
             soundcard.initialise_devicefile(
                 self.g_device_file.get_child().get_text(),
                 self.g_synth_num.get_value_as_int())
     except (soundcard.SoundInitException, OSError, ImportError), e:
         solfege.app.display_sound_init_error_message(e)
         return -1
 elif solfege.soundcard.alsa_sequencer and self.g_alsa_radio.get_active(
 ):
     if self.m_gui_client_port:
         try:
             soundcard.initialise_alsa_sequencer(self.m_gui_client_port)
         except solfege.soundcard.alsa_sequencer.alsaseq.SequencerError, e:
             logging.debug("initialise_alsa_sequencer(%s) failed: %s",
                           self.m_gui_client_port, str(e))
             solfege.app.display_sound_init_error_message(e)
             return -1
     else:
         return -1
 else:  # no sound
     assert self.g_fakesynth_radio.get_active()
     soundcard.initialise_using_fake_synth(0)
 if self.g_midiplayer_radio.get_active():
     self.set_string("sound/type", "external-midiplayer")
 elif self.g_device_radio.get_active():
     if sys.platform == "win32":
         self.set_string("sound/type", "winsynth")
Example #8
0
 def setup_sound(self):
     if sys.platform == 'win32' and \
                 cfg.get_string("sound/type") == "sequencer-device":
         # just in case c:\home\.solfegerc is wrong
         cfg.set_string("sound/type", "winsynth")
     if self.m_options.no_sound \
        or cfg.get_string("sound/type") == "fake-synth":
         soundcard.initialise_using_fake_synth(
             self.m_options.verbose_sound_init)
     elif cfg.get_string("sound/type") == "alsa-sequencer":
         if alsaseq:
             try:
                 clientid, portid = self.get_list("sound/alsa-client-port")
             except ValueError:
                 clientid, portid = (None, None)
             try:
                 soundcard.initialise_alsa_sequencer(
                     (clientid, portid), self.m_options.verbose_sound_init)
             except alsaseq.SequencerError as e:
                 logging.debug(
                     "initialise_alsa_sequencer failed. Using fake synth.")
                 self.display_sound_init_error_message(e)
                 soundcard.initialise_using_fake_synth(True)
                 return
         else:
             if solfege.splash_win:
                 solfege.splash_win.hide()
             gu.dialog_ok(
                 _("The pyalsa Python module is missing"), solfege.win,
                 _("Solfege was configured to use the Python modules from www.alsa-project.org, but the modules were not found. You must reconfigure sound in the preferences window (Ctrl-F12) or restart Solfege in a way that it finds the modules."
                   ))
             soundcard.initialise_using_fake_synth(True)
             if solfege.splash_win:
                 solfege.splash_win.show()
     elif cfg.get_string("sound/type") == "winsynth":
         try:
             soundcard.initialise_winsynth(
                 cfg.get_int("sound/synth_number"),
                 verbose_init=self.m_options.verbose_sound_init)
         except ImportError as e:
             self.display_sound_init_error_message(e)
             cfg.set_string("sound/type", "fake-synth")
             soundcard.initialise_using_fake_synth(True)
             return
         except RuntimeError as e:
             # We can get here if winmidi.output_devices() in winsynth
             # __init__ returns no devices. Don't know when, but it could
             # happen.
             gu.display_exception_message(e)
             cfg.set_string("sound/type", "fake-synth")
             soundcard.initialise_using_fake_synth(True)
             return
         if cfg.get_int("sound/synth_number") != soundcard.synth.m_devnum:
             solfege.win.display_error_message2(
                 _("MIDI setup"),
                 _("MIDI Device %(olddev)i not available. Will use device %(newdev)i."
                   ) % {
                       'olddev': cfg.get_int("sound/synth_number"),
                       'newdev': soundcard.synth.m_devnum
                   })
             cfg.set_int("sound/synth_number", soundcard.synth.m_devnum)
     elif cfg.get_string("sound/type") == "external-midiplayer":
         soundcard.initialise_external_midiplayer(
             verbose_init=self.m_options.verbose_sound_init)
         soundcard.synth.error_report_cb = solfege.win.display_error_message
     elif cfg.get_string("sound/type") == '':
         solfege.win.display_error_message(
             _("You should configure sound from the 'Sound' page "
               "of the preferences window."))
     elif cfg.get_string("sound/type") == "sequencer-device":
         try:
             soundcard.initialise_devicefile(
                 cfg.get_string("sound/device_file"),
                 cfg.get_int("sound/synth_number"),
                 verbose_init=self.m_options.verbose_sound_init)
         except (soundcard.SoundInitException, OSError, ImportError) as e:
             self.m_sound_init_exception = e
             soundcard.initialise_using_fake_synth(True)
     if cfg.get_string("programs/csound") == "AUTODETECT":
         for p in osutils.find_csound_executables():
             cfg.set_string("programs/csound", p)
             break
         else:
             # If not csound binary was found, then we set the string empty.
             # This means that autodetection will only happen the first time
             # you run the program. But later will newly installed binaries
             # be shown in the combo box of the preferences window.
             cfg.set_string("programs/csound", "")
     if cfg.get_string("programs/mma") == "AUTODETECT":
         for p in osutils.find_mma_executables(
                 cfg.get_list("app/win32_ignore_drives")):
             cfg.set_string("programs/mma", p)
             break
         else:
             cfg.set_string("programs/mma", "")