コード例 #1
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)
コード例 #2
0
ファイル: configwindow.py プロジェクト: tcamundsen/solfege
 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)
コード例 #3
0
ファイル: configwindow.py プロジェクト: PauloJava2016/Solfege
 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), e:
             solfege.app.display_sound_init_error_message(e)
             return -1
コード例 #4
0
ファイル: configwindow.py プロジェクト: yuanyelele/solfege
 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), e:
             solfege.app.display_sound_init_error_message(e)
             return -1
コード例 #5
0
ファイル: application.py プロジェクト: tcamundsen/solfege
 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", "")
コード例 #6
0
ファイル: mpd-test.py プロジェクト: this-is-allan/Solfege
        self.g_displayer.display(t, 20)

    def on_display_first_notes(self, _o):
        t = self.m_buf.get_text(self.m_buf.get_start_iter(),
                                self.m_buf.get_end_iter(), True)
        self.save(t)
        self.g_displayer.display(t, 20, mpd.Rat(0, 1))

    def on_play(self, _o):
        t = self.m_buf.get_text(self.m_buf.get_start_iter(),
                                self.m_buf.get_end_iter(), True)
        self.save(t)
        utils.play_music(t, (120, 4), 0, 100)

    def on_play_first(self, _o):
        t = self.m_buf.get_text(self.m_buf.get_start_iter(),
                                self.m_buf.get_end_iter(), True)
        tr = mpd.music_to_tracklist(t, mpd.Rat(0, 1), mpd.Rat(1, 8))
        soundcard.synth.play_track(*tr)


#soundcard.initialise_devicefile("/dev/sequencer", 0)
#soundcard.initialise_devicefile("/dev/music", 0)
#soundcard.initialise_using_fake_synth()
soundcard.initialise_external_midiplayer()

w = DisplaytestWindow()
w.connect('destroy', gtk.main_quit)
w.show()
gtk.main()
コード例 #7
0
ファイル: test.py プロジェクト: tcamundsen/solfege
cfg.set_int('config/lowest_instrument', 1)
cfg.set_int('config/middle_instrument', 2)
cfg.set_int('config/highest_instrument', 3)
cfg.set_int('config/lowest_instrument_volume', 121)
cfg.set_int('config/middle_instrument_volume', 122)
cfg.set_int('config/highest_instrument_volume', 123)
cfg.set_bool('config/override_default_instrument', False)
cfg.set_bool('testing/may_play_sound', False)

if os.path.exists(testlib.outdir):
    shutil.rmtree(testlib.outdir)
os.mkdir(testlib.outdir)

from solfege import soundcard
from solfege.osutils import *
soundcard.initialise_external_midiplayer()

soundcard.synth.start_testmode()


import solfege.mpd.tests
import solfege.soundcard.tests
import solfege.tests
import solfege.tests.test_cfg

# test_cfg has to be called last because it changes the cfg database.
suite = unittest.TestSuite((
    solfege.mpd.tests.suite,
    solfege.soundcard.tests.suite,
    solfege.tests.suite,
    solfege.tests.test_cfg.suite,
コード例 #8
0
ファイル: application.py プロジェクト: PauloJava2016/Solfege
         cfg.set_string("sound/type", "fake-synth")
         soundcard.initialise_using_fake_synth(True)
         return
     except RuntimeError, 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), e:
         self.m_sound_init_exception = e
         soundcard.initialise_using_fake_synth(True)
 if cfg.get_string("programs/csound") == "AUTODETECT":
コード例 #9
0
ファイル: application.py プロジェクト: yuanyelele/solfege
         # 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), e:
         self.m_sound_init_exception = e
         soundcard.initialise_using_fake_synth(True)
 if cfg.get_string("programs/csound") == "AUTODETECT":
コード例 #10
0
ファイル: application.py プロジェクト: gitGNU/gnu_solfege
 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", "")