Beispiel #1
0
         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), 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", "")
 def display_sound_init_error_message(self, e):
Beispiel #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 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", "")
Beispiel #3
0
    def create_external_programs_config(self):
        it, page_vbox = self.new_page_box(None, _("External Programs"))
        box, category_vbox = gu.hig_category_vbox(_("Converters"))
        page_vbox.pack_start(box, False, False, 0)
        sizegroup = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)

        # midi_to_wav
        self.g_wav_convertor = gu.sComboBox(
            'app', 'midi_to_wav_cmd', ['timidity'])
        self.g_wav_convertor_options = gu.sComboBox(
            'app', 'midi_to_wav_cmd_options', ["-Ow %(in)s -o %(out)s"])
        self.g_wav_convertor_options.set_entry_text_column(0)
        category_vbox.pack_start(
            gu.hig_label_widget(_("MIDI to WAV:"),
                (self.g_wav_convertor, self.g_wav_convertor_options),
                 sizegroup),
            False, False, 0)

        # wav_to_mp3
        self.g_mp3_convertor = gu.sComboBox(
            'app', 'wav_to_mp3_cmd', ["lame"])
        self.g_mp3_convertor_options = gu.sComboBox(
            'app', 'wav_to_mp3_cmd_options', ["%(in)s %(out)s"])
        category_vbox.pack_start(
            gu.hig_label_widget(_("WAV to MP3:"),
                (self.g_mp3_convertor, self.g_mp3_convertor_options),
                sizegroup),
            False, False, 0)

        # wav_to_ogg
        self.g_ogg_convertor = gu.sComboBox(
            "app", "wav_to_ogg_cmd", ["oggenc"])
        self.g_ogg_convertor_options = gu.sComboBox(
            "app", "wav_to_ogg_cmd_options", ["%(in)s"])
        category_vbox.pack_start(
            gu.hig_label_widget(_("WAV to OGG:"),
                (self.g_ogg_convertor, self.g_ogg_convertor_options),
                sizegroup),
            False, False, 0)

        self.add_gui_for_external_programs(page_vbox)
        ########
        # Misc #
        ########
        sizegroup = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)

        box, category_vbox = gu.hig_category_vbox(_("Miscellaneous"))
        page_vbox.pack_start(box, False, False, 0)

        # CSound_("Musical MIDI Accompaniment:")
        for binary, label, bins in (
            ("csound", _("CSound:"), osutils.find_csound_executables()),
            ("mma", "MMA:", osutils.find_mma_executables(
                cfg.get_list("app/win32_ignore_drives"))),
            ("lilypond-book", _("Lilypond-book:"),
             osutils.find_progs(("lilypond-book", "lilypond-book.py"))),
            ("latex", "Latex:", osutils.find_progs(("latex",))),
            ("text-editor", _("Text editor:"), osutils.find_progs(("sensible-editor", "gvim", "gedit", "emacs", "notepad.exe"))),
            ):
            combo = gu.sComboBox("programs", binary, bins)
            def binary_changed_cb(widget, binary):
                widget.warning.props.visible = not bool(
                    osutils.find_progs((cfg.get_string('programs/%s' % binary),)))
            combo.warning = Gtk.Image()
            combo.warning.set_tooltip_text(_("Not found. Much of GNU Solfege will run fine without this program. You will get a message when the program is required, and the user manual will explain what you need it for."))
            combo.warning.set_from_stock(Gtk.STOCK_DIALOG_WARNING,
                                              Gtk.IconSize.SMALL_TOOLBAR)
            box = gu.hig_label_widget(label,
                                      [combo, combo.warning],
                                      sizegroup, True, True)
            category_vbox.pack_start(box, True, True, 0)
            combo.warning.props.no_show_all = True
            binary_changed_cb(combo, binary)
            combo.connect('changed', binary_changed_cb, binary)
Beispiel #4
0
    def create_external_programs_config(self):
        it, page_vbox = self.new_page_box(None, _("External Programs"))
        box, category_vbox = gu.hig_category_vbox(_("Converters"))
        page_vbox.pack_start(box, False)
        sizegroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)

        # midi_to_wav
        self.g_wav_convertor = gtk.ComboBoxEntry(
            gtk.ListStore(gobject.TYPE_STRING))
        self.g_wav_convertor.get_model().append(("timidity",))
        #
        self.g_wav_convertor_options = gtk.ComboBoxEntry(
            gtk.ListStore(gobject.TYPE_STRING))
        self.g_wav_convertor_options.get_model().append(("-Ow %(in)s -o %(out)s",))
        #
        category_vbox.pack_start(
            gu.hig_label_widget(_("MIDI to WAV:"),
               (self.g_wav_convertor, self.g_wav_convertor_options),
               sizegroup, True, True))
        #
        self.g_wav_convertor.child.set_text(
            self.get_string("app/midi_to_wav_cmd"))
        self.g_wav_convertor_options.child.set_text(
            self.get_string("app/midi_to_wav_cmd_options"))
        self.g_wav_convertor.connect('changed',
            lambda w: self.set_string('app/midi_to_wav_cmd',
                w.child.get_text()))
        self.g_wav_convertor_options.connect('changed',
            lambda w: self.set_string('app/midi_to_wav_cmd_options',
                w.child.get_text()))
        # wav_to_mp3
        self.g_mp3_convertor = gtk.ComboBoxEntry(
            gtk.ListStore(gobject.TYPE_STRING))
        self.g_mp3_convertor.get_model().append(("lame",))
        #
        self.g_mp3_convertor_options = gtk.ComboBoxEntry(
            gtk.ListStore(gobject.TYPE_STRING))
        self.g_mp3_convertor_options.get_model().append(("%(in)s %(out)s",))
        #
        category_vbox.pack_start(
            gu.hig_label_widget(_("WAV to MP3:"),
            (self.g_mp3_convertor, self.g_mp3_convertor_options),
            sizegroup, True, True))
        #
        self.g_mp3_convertor.child.set_text(
            self.get_string("app/wav_to_mp3_cmd"))
        self.g_mp3_convertor_options.child.set_text(
            self.get_string("app/wav_to_mp3_cmd_options"))
        self.g_mp3_convertor.connect('changed',
            lambda w: self.set_string('app/wav_to_mp3_cmd',
                w.child.get_text()))
        self.g_mp3_convertor_options.connect('changed',
            lambda w: self.set_string('app/wav_to_mp3_cmd_options',
                w.child.get_text()))
        # wav_to_ogg
        self.g_ogg_convertor = gtk.ComboBoxEntry(
            gtk.ListStore(gobject.TYPE_STRING))
        self.g_ogg_convertor.get_model().append(("oggenc",))
        #
        self.g_ogg_convertor_options = gtk.ComboBoxEntry(
            gtk.ListStore(gobject.TYPE_STRING))
        self.g_ogg_convertor_options.get_model().append(("%(in)s",))
        #
        category_vbox.pack_start(
            gu.hig_label_widget(_("WAV to OGG:"),
            (self.g_ogg_convertor, self.g_ogg_convertor_options),
            sizegroup, True, True))
        #
        self.g_ogg_convertor.child.set_text(
            self.get_string("app/wav_to_ogg_cmd"))
        self.g_ogg_convertor_options.child.set_text(
            self.get_string("app/wav_to_ogg_cmd_options"))
        self.g_ogg_convertor.connect('changed',
            lambda w: self.set_string('app/wav_to_ogg_cmd',
                w.child.get_text()))
        self.g_ogg_convertor_options.connect('changed',
            lambda w: self.set_string('app/wav_to_ogg_cmd_options',
                w.child.get_text()))

        self.add_gui_for_external_programs(page_vbox)
        ########
        # Misc #
        ########
        sizegroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)

        box, category_vbox = gu.hig_category_vbox(_("Miscellaneous"))
        page_vbox.pack_start(box, False)

        # CSound_("Musical MIDI Accompaniment:")
        for bin, label, bins in (
            ("csound", _("CSound:"), osutils.find_csound_executables()),
            ("mma", "MMA:", osutils.find_mma_executables(
                cfg.get_list("app/win32_ignore_drives"))),
            ("lilypond-book", _("Lilypond-book:"),
             osutils.find_progs(("lilypond-book", "lilypond-book.py"))),
            ("latex", "Latex:", osutils.find_progs(("latex",))),
            ("text-editor", "Text editor:", osutils.find_progs(("sensible-editor", "gvim", "gedit", "emacs", "notepad.exe"))),
            ):
            liststore = gtk.ListStore(gobject.TYPE_STRING)
            for p in bins:
                liststore.append((p,))
            cbox_entry = gtk.ComboBoxEntry(liststore)
            cbox_entry.child.set_text(self.get_string("programs/%(bin)s" % locals()))
            def csound_changed_cb(widget, bin):
                self.set_string('programs/%s' % bin, widget.child.get_text())
                widget.warning.props.visible = not bool(
                    osutils.find_progs((cfg.get_string('programs/%s' % bin),)))
            cbox_entry.warning = gtk.Image()
            cbox_entry.warning.set_tooltip_text(_("Not found. Much of GNU Solfege will run fine without this program. You will get a message when the program is required, and the user manual will explain what you need it for."))
            cbox_entry.warning.set_from_stock(gtk.STOCK_DIALOG_WARNING,
                                              gtk.ICON_SIZE_SMALL_TOOLBAR)
            box = gu.hig_label_widget(label,
                                      [cbox_entry, cbox_entry.warning],
                                      sizegroup, True, True)
            category_vbox.pack_start(box)
            cbox_entry.warning.props.no_show_all = True
            csound_changed_cb(cbox_entry, bin)
            cbox_entry.connect('changed', csound_changed_cb, bin)
Beispiel #5
0
    def create_external_programs_config(self):
        it, page_vbox = self.new_page_box(None, _("External Programs"))
        box, category_vbox = gu.hig_category_vbox(_("Converters"))
        page_vbox.pack_start(box, False, False, 0)
        sizegroup = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)

        # midi_to_wav
        self.g_wav_convertor = gu.sComboBox('app', 'midi_to_wav_cmd',
                                            ['timidity'])
        self.g_wav_convertor_options = gu.sComboBox('app',
                                                    'midi_to_wav_cmd_options',
                                                    ["-Ow %(in)s -o %(out)s"])
        self.g_wav_convertor_options.set_entry_text_column(0)
        category_vbox.pack_start(
            gu.hig_label_widget(
                _("MIDI to WAV:"),
                (self.g_wav_convertor, self.g_wav_convertor_options),
                sizegroup), False, False, 0)

        # wav_to_mp3
        self.g_mp3_convertor = gu.sComboBox('app', 'wav_to_mp3_cmd', ["lame"])
        self.g_mp3_convertor_options = gu.sComboBox('app',
                                                    'wav_to_mp3_cmd_options',
                                                    ["%(in)s %(out)s"])
        category_vbox.pack_start(
            gu.hig_label_widget(
                _("WAV to MP3:"),
                (self.g_mp3_convertor, self.g_mp3_convertor_options),
                sizegroup), False, False, 0)

        # wav_to_ogg
        self.g_ogg_convertor = gu.sComboBox("app", "wav_to_ogg_cmd",
                                            ["oggenc"])
        self.g_ogg_convertor_options = gu.sComboBox("app",
                                                    "wav_to_ogg_cmd_options",
                                                    ["%(in)s"])
        category_vbox.pack_start(
            gu.hig_label_widget(
                _("WAV to OGG:"),
                (self.g_ogg_convertor, self.g_ogg_convertor_options),
                sizegroup), False, False, 0)

        self.add_gui_for_external_programs(page_vbox)
        ########
        # Misc #
        ########
        sizegroup = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)

        box, category_vbox = gu.hig_category_vbox(_("Miscellaneous"))
        page_vbox.pack_start(box, False, False, 0)

        # CSound_("Musical MIDI Accompaniment:")
        for binary, label, bins in (
            ("csound", _("CSound:"), osutils.find_csound_executables()),
            ("mma", "MMA:",
             osutils.find_mma_executables(
                 cfg.get_list("app/win32_ignore_drives"))),
            ("lilypond-book", _("Lilypond-book:"),
             osutils.find_progs(("lilypond-book", "lilypond-book.py"))),
            ("latex", "Latex:", osutils.find_progs(("latex", ))),
            ("text-editor", _("Text editor:"),
             osutils.find_progs(("sensible-editor", "gvim", "gedit", "emacs",
                                 "notepad.exe"))),
        ):
            combo = gu.sComboBox("programs", binary, bins)

            def binary_changed_cb(widget, binary):
                widget.warning.props.visible = not bool(
                    osutils.find_progs(
                        (cfg.get_string('programs/%s' % binary), )))

            combo.warning = Gtk.Image()
            combo.warning.set_tooltip_text(
                _("Not found. Much of GNU Solfege will run fine without this program. You will get a message when the program is required, and the user manual will explain what you need it for."
                  ))
            combo.warning.set_from_stock(Gtk.STOCK_DIALOG_WARNING,
                                         Gtk.IconSize.SMALL_TOOLBAR)
            box = gu.hig_label_widget(label, [combo, combo.warning], sizegroup,
                                      True, True)
            category_vbox.pack_start(box, True, True, 0)
            combo.warning.props.no_show_all = True
            binary_changed_cb(combo, binary)
            combo.connect('changed', binary_changed_cb, binary)
Beispiel #6
0
     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), 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", "")
Beispiel #7
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", "")